RageFile -> RageFileBasic
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "CryptHelpers.h"
|
#include "CryptHelpers.h"
|
||||||
|
#include "RageFile.h"
|
||||||
|
|
||||||
// crypt headers
|
// crypt headers
|
||||||
#include "crypto51/files.h"
|
#include "crypto51/files.h"
|
||||||
|
|
||||||
|
RageFileStore::ReadErr::ReadErr( const RageFileBasic &f ):
|
||||||
|
Err( "RageFileStore read error: " + f.GetError() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
RageFileStore::RageFileStore()
|
RageFileStore::RageFileStore()
|
||||||
{
|
{
|
||||||
@@ -20,7 +25,7 @@ RageFileStore::RageFileStore( const RageFileStore &cpy ):
|
|||||||
FilterPutSpaceHelper(cpy)
|
FilterPutSpaceHelper(cpy)
|
||||||
{
|
{
|
||||||
if( cpy.m_pFile != NULL )
|
if( cpy.m_pFile != NULL )
|
||||||
m_pFile = new RageFile( *cpy.m_pFile );
|
m_pFile = cpy.m_pFile->Copy();
|
||||||
else
|
else
|
||||||
m_pFile = NULL;
|
m_pFile = NULL;
|
||||||
|
|
||||||
@@ -34,8 +39,9 @@ void RageFileStore::StoreInitialize(const NameValuePairs ¶meters)
|
|||||||
const char *fileName;
|
const char *fileName;
|
||||||
if( parameters.GetValue("InputFileName", fileName) )
|
if( parameters.GetValue("InputFileName", fileName) )
|
||||||
{
|
{
|
||||||
m_pFile = new RageFile;
|
RageFile *pFile = new RageFile;
|
||||||
if( !m_pFile->Open(fileName, RageFile::READ) )
|
m_pFile = pFile;
|
||||||
|
if( !pFile->Open(fileName, RageFile::READ) )
|
||||||
throw OpenErr( fileName );
|
throw OpenErr( fileName );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -47,7 +53,7 @@ void RageFileStore::StoreInitialize(const NameValuePairs ¶meters)
|
|||||||
|
|
||||||
unsigned long RageFileStore::MaxRetrievable() const
|
unsigned long RageFileStore::MaxRetrievable() const
|
||||||
{
|
{
|
||||||
if( m_pFile == NULL || !m_pFile->IsGood() )
|
if( m_pFile == NULL || m_pFile->AtEOF() || !m_pFile->GetError().empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return m_pFile->GetFileSize() - m_pFile->Tell();
|
return m_pFile->GetFileSize() - m_pFile->Tell();
|
||||||
@@ -55,7 +61,7 @@ unsigned long RageFileStore::MaxRetrievable() const
|
|||||||
|
|
||||||
unsigned int RageFileStore::TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel, bool blocking)
|
unsigned int RageFileStore::TransferTo2(BufferedTransformation &target, unsigned long &transferBytes, const std::string &channel, bool blocking)
|
||||||
{
|
{
|
||||||
if( m_pFile == NULL || !m_pFile->IsGood() )
|
if( m_pFile == NULL || m_pFile->AtEOF() || !m_pFile->GetError().empty() )
|
||||||
{
|
{
|
||||||
transferBytes = 0;
|
transferBytes = 0;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -93,7 +99,7 @@ output:
|
|||||||
|
|
||||||
unsigned int RageFileStore::CopyRangeTo2(BufferedTransformation &target, unsigned long &begin, unsigned long end, const std::string &channel, bool blocking) const
|
unsigned int RageFileStore::CopyRangeTo2(BufferedTransformation &target, unsigned long &begin, unsigned long end, const std::string &channel, bool blocking) const
|
||||||
{
|
{
|
||||||
if( m_pFile == NULL || !m_pFile->IsGood() )
|
if( m_pFile == NULL || m_pFile->AtEOF() || !m_pFile->GetError().empty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if( begin == 0 && end == 1 )
|
if( begin == 0 && end == 1 )
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
#ifndef CryptHelpers_H
|
#ifndef CryptHelpers_H
|
||||||
#define CryptHelpers_H
|
#define CryptHelpers_H
|
||||||
|
|
||||||
#include "RageFile.h"
|
|
||||||
|
|
||||||
// crypt headers
|
// crypt headers
|
||||||
#include "crypto51/files.h"
|
#include "crypto51/files.h"
|
||||||
#include "crypto51/filters.h"
|
#include "crypto51/filters.h"
|
||||||
#include "crypto51/cryptlib.h"
|
#include "crypto51/cryptlib.h"
|
||||||
|
|
||||||
using namespace CryptoPP;
|
using namespace CryptoPP;
|
||||||
|
class RageFileBasic;
|
||||||
|
|
||||||
//! .
|
//! .
|
||||||
class RageFileStore : public Store, private FilterPutSpaceHelper
|
class RageFileStore : public Store, private FilterPutSpaceHelper
|
||||||
@@ -20,7 +19,7 @@ public:
|
|||||||
Err(const std::string &s) : Exception(IO_ERROR, s) {}
|
Err(const std::string &s) : Exception(IO_ERROR, s) {}
|
||||||
};
|
};
|
||||||
class OpenErr : public Err {public: OpenErr(const std::string &filename) : Err("FileStore: error opening file for reading: " + filename) {}};
|
class OpenErr : public Err {public: OpenErr(const std::string &filename) : Err("FileStore: error opening file for reading: " + filename) {}};
|
||||||
struct ReadErr : public Err { ReadErr(const RageFile &f) : Err("RageFileStore(" + f.GetPath() + "): read error: " + f.GetError() ) {}};
|
struct ReadErr : public Err { ReadErr( const RageFileBasic &f ); };
|
||||||
|
|
||||||
RageFileStore();
|
RageFileStore();
|
||||||
~RageFileStore();
|
~RageFileStore();
|
||||||
@@ -35,7 +34,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void StoreInitialize(const NameValuePairs ¶meters);
|
void StoreInitialize(const NameValuePairs ¶meters);
|
||||||
|
|
||||||
mutable RageFile *m_pFile; // mutable because reading from a file is not a const operation
|
mutable RageFileBasic *m_pFile; // mutable because reading from a file is not a const operation
|
||||||
byte *m_space;
|
byte *m_space;
|
||||||
int m_len;
|
int m_len;
|
||||||
bool m_waiting;
|
bool m_waiting;
|
||||||
|
|||||||
Reference in New Issue
Block a user