mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
- Virtual File System (VFS) by birdflu. This is needed for Multiplayer and is also used for Single Player. Very neat system :-) - Multiplayer Version 1.1 + some additional features and bugfixes * INFO: If you compile a new EXE and want to test, be sure to also use the latest SVN GameDir files in your JA2 install directory * git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2961 3b4a5df2-a311-0410-b5c6-a8a6f20db521
73 lines
2.2 KiB
C++
73 lines
2.2 KiB
C++
#ifndef _VFS_FILE_H_
|
|
#define _VFS_FILE_H_
|
|
|
|
#include "../vfs_types.h"
|
|
#include "../Interface/vfs_file_interface.h"
|
|
|
|
#include <fstream>
|
|
|
|
typedef std::basic_fstream<wchar_t> wfstream;
|
|
|
|
namespace vfs
|
|
{
|
|
/******************************************************************/
|
|
/******************************************************************/
|
|
|
|
class CFile : public vfs::IFileTemplate<IReadable,IWriteable>
|
|
{
|
|
public :
|
|
CFile(vfs::Path const& sFileName);
|
|
virtual ~CFile();
|
|
|
|
virtual bool Close();
|
|
virtual bool GetFileSize(UInt32& uiFileSize);
|
|
|
|
virtual bool IsOpenRead();
|
|
virtual bool OpenRead();
|
|
virtual bool Read(vfs::Byte* pData, vfs::UInt32 uiBytesToRead, vfs::UInt32& uiBytesRead);
|
|
|
|
virtual vfs::UInt32 GetReadLocation();
|
|
virtual bool SetReadLocation(UInt32 uiPositionInBytes);
|
|
virtual bool SetReadLocation(Int32 uiOffsetInBytes, IBaseFile::ESeekDir eSeekDir);
|
|
|
|
virtual bool IsOpenWrite();
|
|
virtual bool OpenWrite(bool bCreateWhenNotExist = false, bool bTruncate = false);
|
|
virtual bool Write(const vfs::Byte* pData, vfs::UInt32 uiBytesToWrite, vfs::UInt32& uiBytesWritten);
|
|
|
|
virtual vfs::UInt32 GetWriteLocation();
|
|
virtual bool SetWriteLocation(Int32 uiPositionInBytes);
|
|
virtual bool SetWriteLocation(Int32 uiOffsetInBytes, IBaseFile::ESeekDir eSeekDir);
|
|
|
|
virtual bool Delete();
|
|
protected:
|
|
std::fstream m_oFile;
|
|
bool m_bIsOpen_read, m_bIsOpen_write;
|
|
};
|
|
|
|
/******************************************************************/
|
|
/******************************************************************/
|
|
|
|
class CTextFile : public CFile
|
|
{
|
|
public:
|
|
CTextFile(vfs::Path const& sFileName)
|
|
: CFile(sFileName)
|
|
{};
|
|
virtual ~CTextFile()
|
|
{};
|
|
|
|
virtual bool OpenRead();
|
|
virtual bool OpenWrite(bool bCreateWhenNotExist = false, bool bTruncate = false);
|
|
|
|
virtual bool Read(Byte* pData, vfs::UInt32 uiBytesToRead, vfs::UInt32& uiBytesRead);
|
|
virtual bool ReadLine(std::string &sLine, vfs::UInt32 uiMaxNumChars);
|
|
|
|
virtual bool Write(const vfs::Byte* pData, vfs::UInt32 uiBytesToWrite, vfs::UInt32& uiBytesWritten);
|
|
virtual bool WriteLine(std::string const& sLine);
|
|
};
|
|
|
|
} // end namespace
|
|
|
|
#endif // _VFS_FILE_H_
|
|
|