2004-07-29 18:10:33 +02:00
|
|
|
// OO wrapper around VFS file Handles, to simplify common usages
|
|
|
|
|
2004-10-06 16:12:10 +02:00
|
|
|
#include "lib/res/handle.h"
|
2006-01-24 09:16:29 +01:00
|
|
|
#include "lib/res/file/file.h"
|
2004-07-29 18:10:33 +02:00
|
|
|
#include "ps/CStr.h"
|
|
|
|
|
2005-01-17 05:52:02 +01:00
|
|
|
#include "ps/Errors.h"
|
2005-01-07 01:47:44 +01:00
|
|
|
|
2004-07-29 18:10:33 +02:00
|
|
|
ERROR_GROUP(CVFSFile);
|
|
|
|
ERROR_TYPE(CVFSFile, LoadFailed);
|
|
|
|
ERROR_TYPE(CVFSFile, AlreadyLoaded);
|
|
|
|
ERROR_TYPE(CVFSFile, InvalidBufferAccess);
|
|
|
|
|
|
|
|
// Reads a file, then gives read-only access to the contents
|
|
|
|
class CVFSFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CVFSFile();
|
|
|
|
~CVFSFile();
|
|
|
|
|
|
|
|
// Returns either PSRETURN_OK or PSRETURN_CVFSFile_LoadFailed.
|
|
|
|
// Dies if a file has already been successfully loaded.
|
2004-08-05 14:44:29 +02:00
|
|
|
PSRETURN Load(const char* filename, uint flags = 0);
|
2004-07-29 18:10:33 +02:00
|
|
|
|
|
|
|
// These die if called when no file has been successfully loaded.
|
|
|
|
const void* GetBuffer() const;
|
2006-01-24 09:16:29 +01:00
|
|
|
size_t GetBufferSize() const;
|
2004-07-29 18:10:33 +02:00
|
|
|
CStr GetAsString() const;
|
|
|
|
|
|
|
|
private:
|
2006-01-24 09:16:29 +01:00
|
|
|
FileIOBuf m_Buffer;
|
2004-07-29 18:10:33 +02:00
|
|
|
size_t m_BufferSize;
|
2004-08-05 15:07:51 +02:00
|
|
|
};
|