1
0
forked from 0ad/0ad
0ad/source/lib/file/file.h
janwas 8667ea74c8 fixes and improvements
- directoryPosix: replace most methods with boost filesystem (but not
all: the latter cannot efficiently enumerate files AND query their
size/mtime)
- AllocatorChecker: better name for member functions
- file: move the File class here
- trace: bugfix
- io: move UnalignedWriter to write_buffer.cpp (basically the same
thing)
- vfs: remove unnecessary "vfs" warts from variable names
- vfs_tree: VfsFile now stores single Name/Size/MTime fields instead of
the FileInfo record (less clunky)
- vfs_path: use boost filesystem's version of the basename/extension
functions
- lf_alloc: remove (no longer necessary, won't be finished - not worth
the trouble)
- path_util: remove path_foreach_component (replaced by better path
traversal logic) and PathPackage (obsoleted by fs::path)

! resource loading code now receives VfsPath as its filename. there is
also OsPath (native absolute path) and Path (relative to binaries/data)

- tex is now independent of file loading code; it just en/decodes
in-memory buffers
- wdll_ver: clean up, use smart pointer to simplify bailout code
- wsdl: remove nonexistent failure path from calc_gamma (cruised by here
because SDL_SetGamme is failing once after a cold boot at work)
- wsnd: simplify OpenAL DLL search, use boost::filesystem
- wutil: Wow64 redirection is now packaged in a (RAII) class

This was SVN commit r5525.
2007-12-22 18:15:52 +00:00

58 lines
1.2 KiB
C++

/**
* =========================================================================
* File : file.h
* Project : 0 A.D.
* Description : simple POSIX file wrapper.
* =========================================================================
*/
// license: GPL; see lib/license.txt
#ifndef INCLUDED_FILE
#define INCLUDED_FILE
#include "path.h"
namespace ERR
{
const LibError FILE_ACCESS = -110200;
const LibError IO = -110201;
}
class LIB_API File
{
public:
File();
~File();
LibError Open(const Path& pathname, char mode);
void Close();
const Path& Pathname() const
{
return m_pathname;
}
char Mode() const
{
return m_mode;
}
LibError Issue(aiocb& req, off_t alignedOfs, u8* alignedBuf, size_t alignedSize) const;
static LibError WaitUntilComplete(aiocb& req, u8*& alignedBuf, size_t& alignedSize);
LibError Read(off_t ofs, u8* buf, size_t size) const;
LibError Write(off_t ofs, const u8* buf, size_t size) const;
private:
LibError IO(off_t ofs, u8* buf, size_t size) const;
Path m_pathname;
char m_mode;
int m_fd;
};
typedef shared_ptr<File> PFile;
#endif // #ifndef INCLUDED_FILE