1
0
forked from 0ad/0ad
0ad/source/ps/Filesystem.h
janwas e2eb5b2610 part4: adapt codebase to changes in lib/
mostly straightforward except for CVSFile / Filesystem. moved the former
into the newly created latter component. removed VFSUtil entirely (that
functionality is available from lib/file/file_system_util.h)

Xeromyces.cpp: simplify buffer handling since smart pointers are now in
play. also use WriteBuffer instead of membuffer.

This was SVN commit r5519.
2007-12-20 20:21:45 +00:00

45 lines
1.0 KiB
C++

#ifndef INCLUDED_FILESYSTEM
#define INCLUDED_FILESYSTEM
#include "lib/path_util.h"
#include "lib/file/path.h"
#include "lib/file/vfs/vfs.h"
#include "lib/file/file_system_util.h"
#include "lib/file/io/io.h"
#include "lib/file/io/write_buffer.h"
#include "ps/CStr.h"
#include "ps/Errors.h"
extern PIVFS g_VFS;
extern bool FileExists(const char* pathname);
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);
// These die if called when no file has been successfully loaded.
const u8* GetBuffer() const;
size_t GetBufferSize() const;
CStr GetAsString() const;
private:
shared_ptr<u8> m_Buffer;
size_t m_BufferSize;
};
#endif // #ifndef INCLUDED_FILESYSTEM