0ad/source/ps/CVFSFile.h
janwas f4adce44bf cleanup:
- callbacks now have a uintptr_t "cbData" parameter (instead of
haphazard void*/uintptr_t, cb/ctx/data)
- resource loading code now more uniformly deals with u8* pointers
instead of void*

allocators: add support for page_aligned_alloc via boost::shared_ptr.
add evil hack to avoid the need for default ctor and ensure alignment in
SingleAllocator
archive: improve Decompressor
compression:
. near complete rewrite (previous code was a poorly factored mess)
. fix bug related to buffer allocation
. no longer provide get_output API (prone to abuse)
. add call to get max. size of output buffer (for preallocation)

This was SVN commit r5370.
2007-09-25 09:39:20 +00:00

34 lines
810 B
C++

// 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 u8* GetBuffer() const;
size_t GetBufferSize() const;
CStr GetAsString() const;
private:
FileIOBuf m_Buffer;
size_t m_BufferSize;
};