0ad/source/ps/CVFSFile.h
janwas 7838627cd2 - vfs_load now returns error code and takes FileIOBuf; that must be freed via file_buf_free. if Handle is needed, use mem_wrap.
- remove ScEd hacks and CFont et al macro rename
- fix accursed bug in VFS buffer management that was causing ReadFile to
fail without error (not allocating enough padding)
- vfs_tree: bugfix in tree_lookup
- waio: temporarily disable sector size determination (pending better
approach - need to determine if using DVD drive)

This was SVN commit r3421.
2006-01-24 08:16:29 +00:00

34 lines
812 B
C++
Executable File

// OO wrapper around VFS file Handles, to simplify common usages
#include "lib/res/handle.h"
#include "lib/res/file/file.h"
#include "ps/CStr.h"
#include "ps/Errors.h"
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.
PSRETURN Load(const char* filename, uint flags = 0);
// These die if called when no file has been successfully loaded.
const void* GetBuffer() const;
size_t GetBufferSize() const;
CStr GetAsString() const;
private:
FileIOBuf m_Buffer;
size_t m_BufferSize;
};