Integrated FileIO as part of Common instead of a separate subproject
This commit is contained in:
parent
336744ed49
commit
bdf0d188c3
|
@ -2,9 +2,9 @@
|
|||
#define CASSETID_H
|
||||
|
||||
#include "EGame.h"
|
||||
#include "FileIO.h"
|
||||
#include "TString.h"
|
||||
#include "types.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
|
||||
enum EIDLength
|
||||
{
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#ifndef CCOLOR_H
|
||||
#define CCOLOR_H
|
||||
|
||||
#include "Common/FileIO/IInputStream.h"
|
||||
#include "Common/FileIO/IOutputStream.h"
|
||||
#include "Common/Serialization/IArchive.h"
|
||||
#include "types.h"
|
||||
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <FileIO/IOutputStream.h>
|
||||
|
||||
class CColor
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
#define CFOURCC_H
|
||||
|
||||
#include "AssertMacro.h"
|
||||
#include "FileIO.h"
|
||||
#include "types.h"
|
||||
#include "TString.h"
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <FileIO/IOutputStream.h>
|
||||
|
||||
#define FOURCC_FROM_TEXT(Text) (Text[0] << 24 | Text[1] << 16 | Text[2] << 8 | Text[3])
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include "AssertMacro.h"
|
||||
#include "CAssetID.h"
|
||||
#include "CColor.h"
|
||||
#include "CFourCC.h"
|
||||
#include "CHashFNV1A.h"
|
||||
#include "CScopedTimer.h"
|
||||
#include "CTimer.h"
|
||||
#include "EGame.h"
|
||||
#include "EKeyInputs.h"
|
||||
#include "EMouseInputs.h"
|
||||
#include "FileIO.h"
|
||||
#include "FileUtil.h"
|
||||
#include "Flags.h"
|
||||
#include "Log.h"
|
||||
#include "TString.h"
|
||||
#include "types.h"
|
||||
#include "Serialization/Binary.h"
|
||||
#include "Serialization/XML.h"
|
||||
|
||||
#endif // COMMON_H
|
|
@ -23,14 +23,8 @@ CONFIG (debug, debug|release) {
|
|||
TARGET = Commond
|
||||
|
||||
# Debug Libs
|
||||
LIBS += -L$$BUILD_DIR/FileIO/ -lFileIOd \
|
||||
-L$$EXTERNALS_DIR/boost_1_63_0/lib64-msvc-14.0 -llibboost_filesystem-vc140-mt-gd-1_63 \
|
||||
LIBS += -L$$EXTERNALS_DIR/boost_1_63_0/lib64-msvc-14.0 -llibboost_filesystem-vc140-mt-gd-1_63 \
|
||||
-L$$EXTERNALS_DIR/tinyxml2/lib -ltinyxml2d
|
||||
|
||||
# Debug Target Dependencies
|
||||
win32 {
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/FileIO/FileIOd.lib
|
||||
}
|
||||
}
|
||||
|
||||
CONFIG (release, debug|release) {
|
||||
|
@ -39,14 +33,8 @@ CONFIG (release, debug|release) {
|
|||
TARGET = Common
|
||||
|
||||
# Release Libs
|
||||
LIBS += -L$$BUILD_DIR/FileIO/ -lFileIO \
|
||||
-L$$EXTERNALS_DIR/boost_1_63_0/lib64-msvc-14.0 -llibboost_filesystem-vc140-mt-1_63 \
|
||||
LIBS += -L$$EXTERNALS_DIR/boost_1_63_0/lib64-msvc-14.0 -llibboost_filesystem-vc140-mt-1_63 \
|
||||
-L$$EXTERNALS_DIR/tinyxml2/lib -ltinyxml2
|
||||
|
||||
# Release Target Dependencies
|
||||
win32 {
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/FileIO/FileIO.lib
|
||||
}
|
||||
}
|
||||
|
||||
# Include Paths
|
||||
|
@ -81,7 +69,21 @@ HEADERS += \
|
|||
Serialization/CBinaryReader.h \
|
||||
Serialization/CSerialVersion.h \
|
||||
Serialization/XML.h \
|
||||
Serialization/Binary.h
|
||||
Serialization/Binary.h \
|
||||
FileIO\CFileInStream.h \
|
||||
FileIO\CFileOutStream.h \
|
||||
FileIO\CMemoryInStream.h \
|
||||
FileIO\CMemoryOutStream.h \
|
||||
FileIO\CTextInStream.h \
|
||||
FileIO\CTextOutStream.h \
|
||||
FileIO\CVectorOutStream.h \
|
||||
FileIO\IOUtil.h \
|
||||
FileIO\IInputStream.h \
|
||||
FileIO\IOutputStream.h \
|
||||
FileIO\CBitStreamInWrapper.h \
|
||||
FileIO\CFileLock.h \
|
||||
FileIO.h \
|
||||
Common.h
|
||||
|
||||
# Source Files
|
||||
SOURCES += \
|
||||
|
@ -92,4 +94,15 @@ SOURCES += \
|
|||
FileUtil.cpp \
|
||||
CAssetID.cpp \
|
||||
EGame.cpp \
|
||||
Serialization/CSerialVersion.cpp
|
||||
Serialization/CSerialVersion.cpp \
|
||||
FileIO\CFileInStream.cpp \
|
||||
FileIO\CFileOutStream.cpp \
|
||||
FileIO\CMemoryInStream.cpp \
|
||||
FileIO\CMemoryOutStream.cpp \
|
||||
FileIO\CTextInStream.cpp \
|
||||
FileIO\CTextOutStream.cpp \
|
||||
FileIO\CVectorOutStream.cpp \
|
||||
FileIO\IOUtil.cpp \
|
||||
FileIO\IInputStream.cpp \
|
||||
FileIO\IOutputStream.cpp \
|
||||
FileIO\CBitStreamInWrapper.cpp
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef FILEIO_H
|
||||
#define FILEIO_H
|
||||
|
||||
#include "Common/FileIO/IOUtil.h"
|
||||
|
||||
#include "Common/FileIO/IInputStream.h"
|
||||
#include "Common/FileIO/CFileInStream.h"
|
||||
#include "Common/FileIO/CMemoryInStream.h"
|
||||
#include "Common/FileIO/CTextInStream.h"
|
||||
|
||||
#include "Common/FileIO/IOutputStream.h"
|
||||
#include "Common/FileIO/CFileOutStream.h"
|
||||
#include "Common/FileIO/CMemoryOutStream.h"
|
||||
#include "Common/FileIO/CVectorOutStream.h"
|
||||
#include "Common/FileIO/CTextOutStream.h"
|
||||
|
||||
#include "Common/FileIO/CBitStreamInWrapper.h"
|
||||
|
||||
#endif // FILEIO
|
|
@ -13,11 +13,11 @@ void CBitStreamInWrapper::SetChunkSize(EChunkSize Size)
|
|||
mChunkSize = Size;
|
||||
}
|
||||
|
||||
long CBitStreamInWrapper::ReadBits(long NumBits, bool ExtendSignBit /*= true*/)
|
||||
long CBitStreamInWrapper::ReadBits(u32 NumBits, bool ExtendSignBit /*= true*/)
|
||||
{
|
||||
long BitsRemaining = NumBits;
|
||||
long Out = 0;
|
||||
long Shift = 0;
|
||||
u32 BitsRemaining = NumBits;
|
||||
u32 Out = 0;
|
||||
u32 Shift = 0;
|
||||
|
||||
while (BitsRemaining > 0)
|
||||
{
|
|
@ -14,13 +14,13 @@ public:
|
|||
private:
|
||||
IInputStream *mpSourceStream;
|
||||
EChunkSize mChunkSize;
|
||||
unsigned long mBitPool;
|
||||
long mBitsRemaining;
|
||||
u32 mBitPool;
|
||||
u32 mBitsRemaining;
|
||||
|
||||
public:
|
||||
CBitStreamInWrapper(IInputStream *pStream, EChunkSize ChunkSize = e32Bit);
|
||||
void SetChunkSize(EChunkSize Size);
|
||||
long ReadBits(long NumBits, bool ExtendSignBit = true);
|
||||
long ReadBits(u32 NumBits, bool ExtendSignBit = true);
|
||||
bool ReadBit();
|
||||
|
||||
private:
|
|
@ -5,13 +5,13 @@ CFileInStream::CFileInStream()
|
|||
{
|
||||
}
|
||||
|
||||
CFileInStream::CFileInStream(const std::string& rkFile)
|
||||
CFileInStream::CFileInStream(const TString& rkFile)
|
||||
: mpFStream(nullptr)
|
||||
{
|
||||
Open(rkFile, IOUtil::eBigEndian);
|
||||
}
|
||||
|
||||
CFileInStream::CFileInStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
CFileInStream::CFileInStream(const TString& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
: mpFStream(nullptr)
|
||||
{
|
||||
Open(rkFile, FileEndianness);
|
||||
|
@ -32,12 +32,13 @@ CFileInStream::~CFileInStream()
|
|||
Close();
|
||||
}
|
||||
|
||||
void CFileInStream::Open(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
void CFileInStream::Open(const TString& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
{
|
||||
if (IsValid())
|
||||
Close();
|
||||
|
||||
fopen_s(&mpFStream, rkFile.c_str(), "rb");
|
||||
TWideString WideFile = rkFile.ToUTF16();
|
||||
_wfopen_s(&mpFStream, *WideFile, L"rb");
|
||||
mName = rkFile;
|
||||
mDataEndianness = FileEndianness;
|
||||
|
||||
|
@ -50,8 +51,7 @@ void CFileInStream::Open(const std::string& rkFile, IOUtil::EEndianness FileEndi
|
|||
else
|
||||
mFileSize = 0;
|
||||
|
||||
size_t EndPath = rkFile.find_last_of("\\/");
|
||||
SetSourceString(rkFile.substr(EndPath + 1, rkFile.length() - EndPath));
|
||||
SetSourceString(rkFile.GetFileName());
|
||||
}
|
||||
|
||||
void CFileInStream::Close()
|
||||
|
@ -61,31 +61,31 @@ void CFileInStream::Close()
|
|||
mpFStream = nullptr;
|
||||
}
|
||||
|
||||
void CFileInStream::ReadBytes(void *pDst, unsigned long Count)
|
||||
void CFileInStream::ReadBytes(void *pDst, u32 Count)
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
fread(pDst, 1, Count, mpFStream);
|
||||
}
|
||||
|
||||
bool CFileInStream::Seek(long Offset, long Origin)
|
||||
bool CFileInStream::Seek(s32 Offset, u32 Origin)
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
return (fseek(mpFStream, Offset, Origin) != 0);
|
||||
}
|
||||
|
||||
bool CFileInStream::Seek64(long long Offset, long Origin)
|
||||
bool CFileInStream::Seek64(s64 Offset, u32 Origin)
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
return (_fseeki64(mpFStream, Offset, Origin) != 0);
|
||||
}
|
||||
|
||||
long CFileInStream::Tell() const
|
||||
u32 CFileInStream::Tell() const
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
return ftell(mpFStream);
|
||||
}
|
||||
|
||||
long long CFileInStream::Tell64() const
|
||||
u64 CFileInStream::Tell64() const
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
return _ftelli64(mpFStream);
|
||||
|
@ -101,12 +101,12 @@ bool CFileInStream::IsValid() const
|
|||
return (mpFStream != 0);
|
||||
}
|
||||
|
||||
long CFileInStream::Size() const
|
||||
u32 CFileInStream::Size() const
|
||||
{
|
||||
return mFileSize;
|
||||
}
|
||||
|
||||
std::string CFileInStream::FileName() const
|
||||
TString CFileInStream::FileName() const
|
||||
{
|
||||
return mName;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef CFILEINSTREAM_H
|
||||
#define CFILEINSTREAM_H
|
||||
|
||||
#include "IInputStream.h"
|
||||
#include "IOUtil.h"
|
||||
|
||||
class CFileInStream : public IInputStream
|
||||
{
|
||||
private:
|
||||
FILE *mpFStream;
|
||||
TString mName;
|
||||
u32 mFileSize;
|
||||
|
||||
public:
|
||||
CFileInStream();
|
||||
CFileInStream(const TString& rkFile);
|
||||
CFileInStream(const TString& rkFile, IOUtil::EEndianness FileEndianness);
|
||||
CFileInStream(const CFileInStream& rkSrc);
|
||||
~CFileInStream();
|
||||
void Open(const TString& rkFile, IOUtil::EEndianness FileEndianness);
|
||||
void Close();
|
||||
|
||||
void ReadBytes(void *pDst, u32 Count);
|
||||
bool Seek(s32 Offset, u32 Origin);
|
||||
bool Seek64(s64 Offset, u32 Origin);
|
||||
u32 Tell() const;
|
||||
u64 Tell64() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
u32 Size() const;
|
||||
TString FileName() const;
|
||||
};
|
||||
|
||||
#endif // CFILEINSTREAM_H
|
|
@ -2,6 +2,7 @@
|
|||
#define CFILELOCK_H
|
||||
|
||||
#include <cstdio>
|
||||
#include "Common/TString.h"
|
||||
|
||||
// Maintain a file handle to prevent other processes from accessing the file.
|
||||
class CFileLock
|
||||
|
@ -18,10 +19,11 @@ public:
|
|||
Release();
|
||||
}
|
||||
|
||||
void Lock(const char *pkPath)
|
||||
void Lock(const TString& rkPath)
|
||||
{
|
||||
Release();
|
||||
mpFile = fopen(pkPath, "a+");
|
||||
TWideString WidePath = rkPath.ToUTF16();
|
||||
mpFile = _wfopen(*WidePath, L"a+");
|
||||
}
|
||||
|
||||
void Release()
|
|
@ -6,13 +6,13 @@ CFileOutStream::CFileOutStream()
|
|||
{
|
||||
}
|
||||
|
||||
CFileOutStream::CFileOutStream(const std::string& rkFile)
|
||||
CFileOutStream::CFileOutStream(const TString& rkFile)
|
||||
: mpFStream(nullptr)
|
||||
{
|
||||
Open(rkFile, IOUtil::eBigEndian);
|
||||
}
|
||||
|
||||
CFileOutStream::CFileOutStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
CFileOutStream::CFileOutStream(const TString& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
: mpFStream(nullptr)
|
||||
{
|
||||
Open(rkFile, FileEndianness);
|
||||
|
@ -33,23 +33,25 @@ CFileOutStream::~CFileOutStream()
|
|||
Close();
|
||||
}
|
||||
|
||||
void CFileOutStream::Open(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
void CFileOutStream::Open(const TString& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
{
|
||||
if (IsValid())
|
||||
Close();
|
||||
|
||||
fopen_s(&mpFStream, rkFile.c_str(), "wb");
|
||||
TWideString WideFile = rkFile.ToUTF16();
|
||||
_wfopen_s(&mpFStream, *WideFile, L"wb");
|
||||
mName = rkFile;
|
||||
mDataEndianness = FileEndianness;
|
||||
mSize = 0;
|
||||
}
|
||||
|
||||
void CFileOutStream::Update(const std::string& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
void CFileOutStream::Update(const TString& rkFile, IOUtil::EEndianness FileEndianness)
|
||||
{
|
||||
if (IsValid())
|
||||
Close();
|
||||
|
||||
fopen_s(&mpFStream, rkFile.c_str(), "rb+");
|
||||
TWideString WideFile = rkFile.ToUTF16();
|
||||
_wfopen_s(&mpFStream, *WideFile, L"rb+");
|
||||
mName = rkFile;
|
||||
mDataEndianness = FileEndianness;
|
||||
Seek(0x0, SEEK_END);
|
||||
|
@ -65,32 +67,32 @@ void CFileOutStream::Close()
|
|||
mSize = 0;
|
||||
}
|
||||
|
||||
void CFileOutStream::WriteBytes(const void *pkSrc, unsigned long Count)
|
||||
void CFileOutStream::WriteBytes(const void *pkSrc, u32 Count)
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
fwrite(pkSrc, 1, Count, mpFStream);
|
||||
if ((unsigned long) Tell() > mSize) mSize = Tell();
|
||||
if (Tell() > mSize) mSize = Tell();
|
||||
}
|
||||
|
||||
bool CFileOutStream::Seek(long Offset, long Origin)
|
||||
bool CFileOutStream::Seek(s32 Offset, u32 Origin)
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
return (fseek(mpFStream, Offset, Origin) != 0);
|
||||
}
|
||||
|
||||
bool CFileOutStream::Seek64(long long Offset, long Origin)
|
||||
bool CFileOutStream::Seek64(s64 Offset, u32 Origin)
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
return (_fseeki64(mpFStream, Offset, Origin) != 0);
|
||||
}
|
||||
|
||||
long CFileOutStream::Tell() const
|
||||
u32 CFileOutStream::Tell() const
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
return ftell(mpFStream);
|
||||
}
|
||||
|
||||
long long CFileOutStream::Tell64() const
|
||||
u64 CFileOutStream::Tell64() const
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
return _ftelli64(mpFStream);
|
||||
|
@ -106,13 +108,13 @@ bool CFileOutStream::IsValid() const
|
|||
return (mpFStream != 0);
|
||||
}
|
||||
|
||||
long CFileOutStream::Size() const
|
||||
u32 CFileOutStream::Size() const
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
return mSize;
|
||||
}
|
||||
|
||||
std::string CFileOutStream::FileName() const
|
||||
TString CFileOutStream::FileName() const
|
||||
{
|
||||
return mName;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef CFILEOUTSTREAM_H
|
||||
#define CFILEOUTSTREAM_H
|
||||
|
||||
#include "IOutputStream.h"
|
||||
|
||||
class CFileOutStream : public IOutputStream
|
||||
{
|
||||
private:
|
||||
FILE *mpFStream;
|
||||
TString mName;
|
||||
u32 mSize;
|
||||
|
||||
public:
|
||||
CFileOutStream();
|
||||
CFileOutStream(const TString& rkFile);
|
||||
CFileOutStream(const TString& rkFile, IOUtil::EEndianness FileEndianness);
|
||||
CFileOutStream(const CFileOutStream& rkSrc);
|
||||
~CFileOutStream();
|
||||
void Open(const TString& rkFile, IOUtil::EEndianness);
|
||||
void Update(const TString& rkFile, IOUtil::EEndianness FileEndianness);
|
||||
void Close();
|
||||
|
||||
void WriteBytes(const void *pkSrc, u32 Count);
|
||||
bool Seek(s32 Offset, u32 Origin);
|
||||
bool Seek64(s64 Offset, u32 Origin);
|
||||
u32 Tell() const;
|
||||
u64 Tell64() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
u32 Size() const;
|
||||
TString FileName() const;
|
||||
};
|
||||
|
||||
#endif // CFILEOUTSTREAM_H
|
|
@ -6,31 +6,31 @@ CMemoryInStream::CMemoryInStream()
|
|||
, mPos(0)
|
||||
{
|
||||
}
|
||||
CMemoryInStream::CMemoryInStream(const void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
|
||||
CMemoryInStream::CMemoryInStream(const void *pkData, u32 Size, IOUtil::EEndianness DataEndianness)
|
||||
{
|
||||
SetData(pData, Size, DataEndianness);
|
||||
SetData(pkData, Size, DataEndianness);
|
||||
}
|
||||
|
||||
CMemoryInStream::~CMemoryInStream()
|
||||
{
|
||||
}
|
||||
|
||||
void CMemoryInStream::SetData(const void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
|
||||
void CMemoryInStream::SetData(const void *pkData, u32 Size, IOUtil::EEndianness DataEndianness)
|
||||
{
|
||||
mpDataStart = static_cast<const char*>(pData);
|
||||
mpDataStart = (const char*) pkData;
|
||||
mDataSize = Size;
|
||||
mPos = 0;
|
||||
mDataEndianness = DataEndianness;
|
||||
}
|
||||
|
||||
void CMemoryInStream::ReadBytes(void *pDst, unsigned long Count)
|
||||
void CMemoryInStream::ReadBytes(void *pDst, u32 Count)
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
memcpy(pDst, mpDataStart + mPos, Count);
|
||||
mPos += Count;
|
||||
}
|
||||
|
||||
bool CMemoryInStream::Seek(long Offset, long Origin)
|
||||
bool CMemoryInStream::Seek(s32 Offset, u32 Origin)
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
switch (Origin)
|
||||
|
@ -66,7 +66,7 @@ bool CMemoryInStream::Seek(long Offset, long Origin)
|
|||
return true;
|
||||
}
|
||||
|
||||
long CMemoryInStream::Tell() const
|
||||
u32 CMemoryInStream::Tell() const
|
||||
{
|
||||
return mPos;
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ bool CMemoryInStream::IsValid() const
|
|||
return (mpDataStart != nullptr);
|
||||
}
|
||||
|
||||
long CMemoryInStream::Size() const
|
||||
u32 CMemoryInStream::Size() const
|
||||
{
|
||||
return mDataSize;
|
||||
}
|
||||
|
||||
void CMemoryInStream::SetSize(unsigned long Size)
|
||||
void CMemoryInStream::SetSize(u32 Size)
|
||||
{
|
||||
mDataSize = Size;
|
||||
if (mPos > mDataSize)
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef CMEMORYINSTREAM_H
|
||||
#define CMEMORYINSTREAM_H
|
||||
|
||||
#include "IInputStream.h"
|
||||
|
||||
class CMemoryInStream : public IInputStream
|
||||
{
|
||||
const char *mpDataStart;
|
||||
u32 mDataSize;
|
||||
u32 mPos;
|
||||
|
||||
public:
|
||||
CMemoryInStream();
|
||||
CMemoryInStream(const void *pkData, u32 Size, IOUtil::EEndianness dataEndianness);
|
||||
~CMemoryInStream();
|
||||
void SetData(const void *pkData, u32 Size, IOUtil::EEndianness dataEndianness);
|
||||
|
||||
void ReadBytes(void *pDst, u32 Count);
|
||||
bool Seek(s32 Offset, u32 Origin);
|
||||
u32 Tell() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
u32 Size() const;
|
||||
void SetSize(u32 Size);
|
||||
const void* Data() const;
|
||||
const void* DataAtPosition() const;
|
||||
};
|
||||
|
||||
#endif // CMEMORYINSTREAM_H
|
|
@ -8,7 +8,7 @@ CMemoryOutStream::CMemoryOutStream()
|
|||
{
|
||||
}
|
||||
|
||||
CMemoryOutStream::CMemoryOutStream(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
|
||||
CMemoryOutStream::CMemoryOutStream(void *pData, u32 Size, IOUtil::EEndianness DataEndianness)
|
||||
{
|
||||
SetData(pData, Size, DataEndianness);
|
||||
}
|
||||
|
@ -17,16 +17,16 @@ CMemoryOutStream::~CMemoryOutStream()
|
|||
{
|
||||
}
|
||||
|
||||
void CMemoryOutStream::SetData(void *pData, unsigned long Size, IOUtil::EEndianness DataEndianness)
|
||||
void CMemoryOutStream::SetData(void *pData, u32 Size, IOUtil::EEndianness DataEndianness)
|
||||
{
|
||||
mpDataStart = static_cast<char*>(pData);
|
||||
mpDataStart = (char*) pData;
|
||||
mDataSize = Size;
|
||||
mPos = 0;
|
||||
mUsed = 0;
|
||||
mDataEndianness = DataEndianness;
|
||||
}
|
||||
|
||||
void CMemoryOutStream::WriteBytes(const void *pkSrc, unsigned long Count)
|
||||
void CMemoryOutStream::WriteBytes(const void *pkSrc, u32 Count)
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
|
@ -35,7 +35,7 @@ void CMemoryOutStream::WriteBytes(const void *pkSrc, unsigned long Count)
|
|||
if (mPos > mUsed) mUsed = mPos;
|
||||
}
|
||||
|
||||
bool CMemoryOutStream::Seek(long Offset, long Origin)
|
||||
bool CMemoryOutStream::Seek(s32 Offset, u32 Origin)
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
|
||||
|
@ -72,7 +72,7 @@ bool CMemoryOutStream::Seek(long Offset, long Origin)
|
|||
return true;
|
||||
}
|
||||
|
||||
long CMemoryOutStream::Tell() const
|
||||
u32 CMemoryOutStream::Tell() const
|
||||
{
|
||||
return mPos;
|
||||
}
|
||||
|
@ -87,17 +87,17 @@ bool CMemoryOutStream::IsValid() const
|
|||
return (mpDataStart != nullptr);
|
||||
}
|
||||
|
||||
long CMemoryOutStream::Size() const
|
||||
u32 CMemoryOutStream::Size() const
|
||||
{
|
||||
return mDataSize;
|
||||
}
|
||||
|
||||
long CMemoryOutStream::SpaceUsed() const
|
||||
u32 CMemoryOutStream::SpaceUsed() const
|
||||
{
|
||||
return mUsed;
|
||||
}
|
||||
|
||||
void CMemoryOutStream::SetSize(unsigned long Size)
|
||||
void CMemoryOutStream::SetSize(u32 Size)
|
||||
{
|
||||
mDataSize = Size;
|
||||
if (mPos > mDataSize)
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef CMEMORYOUTSTREAM_H
|
||||
#define CMEMORYOUTSTREAM_H
|
||||
|
||||
#include "IOutputStream.h"
|
||||
|
||||
class CMemoryOutStream : public IOutputStream
|
||||
{
|
||||
char *mpDataStart;
|
||||
u32 mDataSize;
|
||||
u32 mPos;
|
||||
u32 mUsed;
|
||||
|
||||
public:
|
||||
CMemoryOutStream();
|
||||
CMemoryOutStream(void *pData, u32 Size, IOUtil::EEndianness mDataEndianness);
|
||||
~CMemoryOutStream();
|
||||
void SetData(void *pData, u32 Size, IOUtil::EEndianness mDataEndianness);
|
||||
|
||||
void WriteBytes(const void *pkSrc, u32 Count);
|
||||
bool Seek(s32 Offset, u32 Origin);
|
||||
u32 Tell() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
u32 Size() const;
|
||||
u32 SpaceUsed() const;
|
||||
void SetSize(u32 Size);
|
||||
void* Data() const;
|
||||
void* DataAtPosition() const;
|
||||
};
|
||||
|
||||
#endif // CMEMORYOUTSTREAM_H
|
|
@ -7,7 +7,7 @@ CTextInStream::CTextInStream()
|
|||
{
|
||||
}
|
||||
|
||||
CTextInStream::CTextInStream(const std::string& rkFile)
|
||||
CTextInStream::CTextInStream(const TString& rkFile)
|
||||
: mpFStream(nullptr)
|
||||
{
|
||||
Open(rkFile);
|
||||
|
@ -28,12 +28,13 @@ CTextInStream::~CTextInStream()
|
|||
Close();
|
||||
}
|
||||
|
||||
void CTextInStream::Open(const std::string& rkFile)
|
||||
void CTextInStream::Open(const TString& rkFile)
|
||||
{
|
||||
if (IsValid())
|
||||
Close();
|
||||
|
||||
fopen_s(&mpFStream, rkFile.c_str(), "r");
|
||||
TWideString WideFile = rkFile.ToUTF16();
|
||||
_wfopen_s(&mpFStream, *WideFile, L"r");
|
||||
mFileName = rkFile;
|
||||
|
||||
if (IsValid())
|
||||
|
@ -68,7 +69,7 @@ char CTextInStream::GetChar()
|
|||
return (char) fgetc(mpFStream);
|
||||
}
|
||||
|
||||
std::string CTextInStream::GetString()
|
||||
TString CTextInStream::GetString()
|
||||
{
|
||||
if (!IsValid()) return "";
|
||||
|
||||
|
@ -77,13 +78,13 @@ std::string CTextInStream::GetString()
|
|||
return std::string(Buf);
|
||||
}
|
||||
|
||||
long CTextInStream::Seek(long Offset, long Origin)
|
||||
u32 CTextInStream::Seek(s32 Offset, u32 Origin)
|
||||
{
|
||||
if (!IsValid()) return 1;
|
||||
return fseek(mpFStream, Offset, Origin);
|
||||
}
|
||||
|
||||
long CTextInStream::Tell() const
|
||||
u32 CTextInStream::Tell() const
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
return ftell(mpFStream);
|
||||
|
@ -99,7 +100,7 @@ bool CTextInStream::IsValid() const
|
|||
return (mpFStream != 0);
|
||||
}
|
||||
|
||||
long CTextInStream::Size() const
|
||||
u32 CTextInStream::Size() const
|
||||
{
|
||||
return mFileSize;
|
||||
}
|
|
@ -2,31 +2,31 @@
|
|||
#define CTEXTINSTREAM_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include "Common/TString.h"
|
||||
|
||||
class CTextInStream
|
||||
{
|
||||
FILE *mpFStream;
|
||||
std::string mFileName;
|
||||
TString mFileName;
|
||||
long mFileSize;
|
||||
|
||||
public:
|
||||
CTextInStream();
|
||||
CTextInStream(const std::string& rkFile);
|
||||
CTextInStream(const TString& rkFile);
|
||||
CTextInStream(const CTextInStream& rkSrc);
|
||||
~CTextInStream();
|
||||
void Open(const std::string& rkFile);
|
||||
void Open(const TString& rkFile);
|
||||
void Close();
|
||||
|
||||
void Scan(const char *pkFormat, ... );
|
||||
char GetChar();
|
||||
std::string GetString();
|
||||
TString GetString();
|
||||
|
||||
long Seek(long Offset, long Origin);
|
||||
long Tell() const;
|
||||
u32 Seek(s32 Offset, u32 Origin);
|
||||
u32 Tell() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
long Size() const;
|
||||
u32 Size() const;
|
||||
};
|
||||
|
||||
#endif // CTEXTINSTREAM_H
|
|
@ -7,10 +7,10 @@ CTextOutStream::CTextOutStream()
|
|||
{
|
||||
}
|
||||
|
||||
CTextOutStream::CTextOutStream(const std::string& rkFile)
|
||||
CTextOutStream::CTextOutStream(const TString& rkFile)
|
||||
: mpFStream(nullptr)
|
||||
{
|
||||
Open(rkFile.c_str());
|
||||
Open(rkFile);
|
||||
}
|
||||
|
||||
CTextOutStream::CTextOutStream(const CTextOutStream& rkSrc)
|
||||
|
@ -28,9 +28,10 @@ CTextOutStream::~CTextOutStream()
|
|||
Close();
|
||||
}
|
||||
|
||||
void CTextOutStream::Open(const std::string& rkFile)
|
||||
void CTextOutStream::Open(const TString& rkFile)
|
||||
{
|
||||
fopen_s(&mpFStream, rkFile.c_str(), "w");
|
||||
TWideString WideFile = rkFile.ToUTF16();
|
||||
_wfopen_s(&mpFStream, *WideFile, L"w");
|
||||
mFileName = rkFile;
|
||||
mSize = 0;
|
||||
}
|
||||
|
@ -56,23 +57,23 @@ void CTextOutStream::WriteChar(char Chr)
|
|||
{
|
||||
if (!IsValid()) return;
|
||||
fputc(Chr, mpFStream);
|
||||
if ((unsigned long) Tell() > mSize) mSize = Tell();
|
||||
if (Tell() > mSize) mSize = Tell();
|
||||
}
|
||||
|
||||
void CTextOutStream::WriteString(const std::string& rkStr)
|
||||
void CTextOutStream::WriteString(const TString& rkStr)
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
fputs(rkStr.c_str(), mpFStream);
|
||||
if ((unsigned long) Tell() > mSize) mSize = Tell();
|
||||
fputs(*rkStr, mpFStream);
|
||||
if (Tell() > mSize) mSize = Tell();
|
||||
}
|
||||
|
||||
bool CTextOutStream::Seek(long Offset, long Origin)
|
||||
bool CTextOutStream::Seek(s32 Offset, u32 Origin)
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
return (fseek(mpFStream, Offset, Origin) != 0);
|
||||
}
|
||||
|
||||
long CTextOutStream::Tell() const
|
||||
u32 CTextOutStream::Tell() const
|
||||
{
|
||||
if (!IsValid()) return 0;
|
||||
return ftell(mpFStream);
|
||||
|
@ -88,7 +89,7 @@ bool CTextOutStream::IsValid() const
|
|||
return (mpFStream != 0);
|
||||
}
|
||||
|
||||
long CTextOutStream::Size() const
|
||||
u32 CTextOutStream::Size() const
|
||||
{
|
||||
return mSize;
|
||||
}
|
|
@ -1,31 +1,31 @@
|
|||
#ifndef CTEXTOUTSTREAM_H
|
||||
#define CTEXTOUTSTREAM_H
|
||||
|
||||
#include <string>
|
||||
#include "Common/TString.h"
|
||||
|
||||
class CTextOutStream
|
||||
{
|
||||
FILE *mpFStream;
|
||||
std::string mFileName;
|
||||
TString mFileName;
|
||||
unsigned long mSize;
|
||||
|
||||
public:
|
||||
CTextOutStream();
|
||||
CTextOutStream(const std::string& rkFile);
|
||||
CTextOutStream(const TString& rkFile);
|
||||
CTextOutStream(const CTextOutStream& rkSrc);
|
||||
~CTextOutStream();
|
||||
void Open(const std::string& rkFile);
|
||||
void Open(const TString& rkFile);
|
||||
void Close();
|
||||
|
||||
void Print(const char *pkFormat, ... );
|
||||
void WriteChar(char Chr);
|
||||
void WriteString(const std::string& rkStr);
|
||||
void WriteString(const TString& rkStr);
|
||||
|
||||
bool Seek(long Offset, long Origin);
|
||||
long Tell() const;
|
||||
bool Seek(s32 Offset, u32 Origin);
|
||||
u32 Tell() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
long Size() const;
|
||||
u32 Size() const;
|
||||
};
|
||||
|
||||
#endif // CTEXTOUTSTREAM_H
|
|
@ -18,7 +18,7 @@ CVectorOutStream::CVectorOutStream(IOUtil::EEndianness DataEndianness)
|
|||
mDataEndianness = DataEndianness;
|
||||
}
|
||||
|
||||
CVectorOutStream::CVectorOutStream(unsigned long InitialSize, IOUtil::EEndianness DataEndianness)
|
||||
CVectorOutStream::CVectorOutStream(u32 InitialSize, IOUtil::EEndianness DataEndianness)
|
||||
: mpVector(new std::vector<char>(InitialSize))
|
||||
, mOwnsVector(true)
|
||||
, mPos(0)
|
||||
|
@ -41,7 +41,7 @@ CVectorOutStream::~CVectorOutStream()
|
|||
if (mOwnsVector) delete mpVector;
|
||||
}
|
||||
|
||||
void CVectorOutStream::WriteBytes(const void *pkSrc, unsigned long Count)
|
||||
void CVectorOutStream::WriteBytes(const void *pkSrc, u32 Count)
|
||||
{
|
||||
if (!IsValid()) return;
|
||||
|
||||
|
@ -53,7 +53,7 @@ void CVectorOutStream::WriteBytes(const void *pkSrc, unsigned long Count)
|
|||
if (mPos > mUsed) mUsed = mPos;
|
||||
}
|
||||
|
||||
bool CVectorOutStream::Seek(long Offset, long Origin)
|
||||
bool CVectorOutStream::Seek(s32 Offset, u32 Origin)
|
||||
{
|
||||
if (!IsValid()) return false;
|
||||
|
||||
|
@ -84,13 +84,13 @@ bool CVectorOutStream::Seek(long Offset, long Origin)
|
|||
if (mPos > mUsed)
|
||||
mUsed = mPos;
|
||||
|
||||
if (mPos > (signed long) mpVector->size())
|
||||
if (mPos > mpVector->size())
|
||||
mpVector->resize(mPos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
long CVectorOutStream::Tell() const
|
||||
u32 CVectorOutStream::Tell() const
|
||||
{
|
||||
return mPos;
|
||||
}
|
||||
|
@ -105,12 +105,12 @@ bool CVectorOutStream::IsValid() const
|
|||
return true;
|
||||
}
|
||||
|
||||
long CVectorOutStream::Size() const
|
||||
u32 CVectorOutStream::Size() const
|
||||
{
|
||||
return mUsed;
|
||||
}
|
||||
|
||||
long CVectorOutStream::SizeRemaining() const
|
||||
u32 CVectorOutStream::SizeRemaining() const
|
||||
{
|
||||
return mpVector->size() - mPos;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ void* CVectorOutStream::DataAtPosition()
|
|||
return mpVector->data() + mPos;
|
||||
}
|
||||
|
||||
void CVectorOutStream::Expand(unsigned long Amount)
|
||||
void CVectorOutStream::Expand(u32 Amount)
|
||||
{
|
||||
mpVector->resize(mpVector->size() + Amount);
|
||||
}
|
|
@ -8,27 +8,27 @@ class CVectorOutStream : public IOutputStream
|
|||
{
|
||||
std::vector<char> *mpVector;
|
||||
bool mOwnsVector;
|
||||
long mPos;
|
||||
long mUsed;
|
||||
u32 mPos;
|
||||
u32 mUsed;
|
||||
|
||||
public:
|
||||
CVectorOutStream();
|
||||
CVectorOutStream(IOUtil::EEndianness DataEndianness);
|
||||
CVectorOutStream(unsigned long InitialSize, IOUtil::EEndianness DataEndianness);
|
||||
CVectorOutStream(u32 InitialSize, IOUtil::EEndianness DataEndianness);
|
||||
CVectorOutStream(std::vector<char> *pVector, IOUtil::EEndianness DataEndianness);
|
||||
~CVectorOutStream();
|
||||
|
||||
void WriteBytes(const void *pkSrc, unsigned long Count);
|
||||
bool Seek(long Offset, long Origin);
|
||||
long Tell() const;
|
||||
void WriteBytes(const void *pkSrc, u32 Count);
|
||||
bool Seek(s32 Offset, u32 Origin);
|
||||
u32 Tell() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
long Size() const;
|
||||
long SizeRemaining() const;
|
||||
u32 Size() const;
|
||||
u32 SizeRemaining() const;
|
||||
void SetVector(std::vector<char> *pVector);
|
||||
void *Data();
|
||||
void *DataAtPosition();
|
||||
void Expand(unsigned long Amount);
|
||||
void Expand(u32 Amount);
|
||||
void Shrink();
|
||||
void Reset();
|
||||
void Clear();
|
|
@ -68,68 +68,60 @@ long IInputStream::ReadFourCC()
|
|||
return Val;
|
||||
}
|
||||
|
||||
std::string IInputStream::ReadString()
|
||||
TString IInputStream::ReadString()
|
||||
{
|
||||
std::string Str;
|
||||
char Chr = 1;
|
||||
TString Str;
|
||||
char Chr;
|
||||
|
||||
while ((Chr != 0) && (!EoF()))
|
||||
do
|
||||
{
|
||||
Chr = ReadByte();
|
||||
if (Chr != 0) Str.push_back(Chr);
|
||||
if (Chr != 0) Str.Append(Chr);
|
||||
}
|
||||
while ((Chr != 0) && (!EoF()));
|
||||
|
||||
return Str;
|
||||
}
|
||||
|
||||
std::string IInputStream::ReadString(unsigned long Count)
|
||||
TString IInputStream::ReadString(u32 Count)
|
||||
{
|
||||
std::string Str(Count, 0);
|
||||
|
||||
for (unsigned long iChr = 0; iChr < Count; iChr++)
|
||||
Str[iChr] = ReadByte();
|
||||
|
||||
TString Str(Count, 0);
|
||||
ReadBytes(&Str[0], Count);
|
||||
return Str;
|
||||
}
|
||||
|
||||
std::string IInputStream::ReadSizedString()
|
||||
TString IInputStream::ReadSizedString()
|
||||
{
|
||||
unsigned int StringSize = ReadLong();
|
||||
std::string Str(StringSize, 0);
|
||||
ReadBytes(&Str[0], Str.size());
|
||||
return Str;
|
||||
u32 StringSize = ReadLong();
|
||||
return ReadString(StringSize);
|
||||
}
|
||||
|
||||
std::wstring IInputStream::ReadWString()
|
||||
TWideString IInputStream::ReadWString()
|
||||
{
|
||||
std::wstring WStr;
|
||||
TWideString WStr;
|
||||
short Chr = 1;
|
||||
|
||||
while (Chr != 0)
|
||||
do
|
||||
{
|
||||
Chr = ReadShort();
|
||||
if (Chr != 0) WStr.push_back(Chr);
|
||||
if (Chr != 0) WStr.Append(Chr);
|
||||
}
|
||||
while (Chr != 0 && !EoF());
|
||||
|
||||
return WStr;
|
||||
}
|
||||
|
||||
std::wstring IInputStream::ReadWString(unsigned long Count)
|
||||
TWideString IInputStream::ReadWString(u32 Count)
|
||||
{
|
||||
std::wstring WStr(Count, 0);
|
||||
|
||||
for (unsigned long c = 0; c < Count; c++)
|
||||
WStr[c] = ReadShort();
|
||||
|
||||
TWideString WStr(Count, 0);
|
||||
ReadBytes(&WStr[0], WStr.Size() * 2);
|
||||
return WStr;
|
||||
}
|
||||
|
||||
std::wstring IInputStream::ReadSizedWString()
|
||||
TWideString IInputStream::ReadSizedWString()
|
||||
{
|
||||
unsigned int StringSize = ReadLong();
|
||||
std::wstring WStr(StringSize, 0);
|
||||
ReadBytes(&WStr[0], WStr.size() * 2);
|
||||
return WStr;
|
||||
u32 StringSize = ReadLong();
|
||||
return ReadWString(StringSize);
|
||||
}
|
||||
|
||||
char IInputStream::PeekByte()
|
||||
|
@ -181,19 +173,19 @@ long IInputStream::PeekFourCC()
|
|||
return Val;
|
||||
}
|
||||
|
||||
bool IInputStream::GoTo(long Address)
|
||||
bool IInputStream::GoTo(u32 Address)
|
||||
{
|
||||
return Seek(Address, SEEK_SET);
|
||||
}
|
||||
|
||||
bool IInputStream::Skip(long SkipAmount)
|
||||
bool IInputStream::Skip(s32 SkipAmount)
|
||||
{
|
||||
return Seek(SkipAmount, SEEK_CUR);
|
||||
}
|
||||
|
||||
void IInputStream::SeekToBoundary(unsigned long Boundary)
|
||||
void IInputStream::SeekToBoundary(u32 Boundary)
|
||||
{
|
||||
long Num = Boundary - (Tell() % Boundary);
|
||||
u32 Num = Boundary - (Tell() % Boundary);
|
||||
if (Num == Boundary) return;
|
||||
else Seek(Num, SEEK_CUR);
|
||||
}
|
||||
|
@ -203,7 +195,7 @@ void IInputStream::SetEndianness(IOUtil::EEndianness Endianness)
|
|||
mDataEndianness = Endianness;
|
||||
}
|
||||
|
||||
void IInputStream::SetSourceString(const std::string& rkSource)
|
||||
void IInputStream::SetSourceString(const TString& rkSource)
|
||||
{
|
||||
mDataSource = rkSource;
|
||||
}
|
||||
|
@ -213,17 +205,17 @@ IOUtil::EEndianness IInputStream::GetEndianness() const
|
|||
return mDataEndianness;
|
||||
}
|
||||
|
||||
std::string IInputStream::GetSourceString() const
|
||||
TString IInputStream::GetSourceString() const
|
||||
{
|
||||
return mDataSource;
|
||||
}
|
||||
|
||||
bool IInputStream::Seek64(long long Offset, long Origin)
|
||||
bool IInputStream::Seek64(s64 Offset, u32 Origin)
|
||||
{
|
||||
return Seek((long) Offset, Origin);
|
||||
return Seek((s32) Offset, Origin);
|
||||
}
|
||||
|
||||
long long IInputStream::Tell64() const
|
||||
u64 IInputStream::Tell64() const
|
||||
{
|
||||
return (long long) Tell();
|
||||
return (u64) Tell();
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
#ifndef IINPUTSTREAM_H
|
||||
#define IINPUTSTREAM_H
|
||||
|
||||
#include "IOUtil.h"
|
||||
#include "Common/TString.h"
|
||||
#include "Common/types.h"
|
||||
#include <vector>
|
||||
|
||||
class IInputStream
|
||||
{
|
||||
protected:
|
||||
IOUtil::EEndianness mDataEndianness;
|
||||
TString mDataSource;
|
||||
|
||||
public:
|
||||
bool ReadBool();
|
||||
char ReadByte();
|
||||
short ReadShort();
|
||||
long ReadLong();
|
||||
long long ReadLongLong();
|
||||
float ReadFloat();
|
||||
double ReadDouble();
|
||||
long ReadFourCC();
|
||||
TString ReadString();
|
||||
TString ReadString(u32 Count);
|
||||
TString ReadSizedString();
|
||||
TWideString ReadWString();
|
||||
TWideString ReadWString(u32 Count);
|
||||
TWideString ReadSizedWString();
|
||||
|
||||
char PeekByte();
|
||||
short PeekShort();
|
||||
long PeekLong();
|
||||
long long PeekLongLong();
|
||||
float PeekFloat();
|
||||
double PeekDouble();
|
||||
long PeekFourCC();
|
||||
|
||||
bool GoTo(u32 Address);
|
||||
bool Skip(s32 SkipAmount);
|
||||
|
||||
void SeekToBoundary(u32 Boundary);
|
||||
void SetEndianness(IOUtil::EEndianness Endianness);
|
||||
void SetSourceString(const TString& rkSource);
|
||||
IOUtil::EEndianness GetEndianness() const;
|
||||
TString GetSourceString() const;
|
||||
|
||||
virtual ~IInputStream();
|
||||
virtual void ReadBytes(void *pDst, u32 Count) = 0;
|
||||
virtual bool Seek(s32 Offset, u32 Origin) = 0;
|
||||
virtual bool Seek64(s64 Offset, u32 Origin);
|
||||
virtual u32 Tell() const = 0;
|
||||
virtual u64 Tell64() const;
|
||||
virtual bool EoF() const = 0;
|
||||
virtual bool IsValid() const = 0;
|
||||
virtual u32 Size() const = 0;
|
||||
};
|
||||
|
||||
#endif // IINPUTSTREAM_H
|
|
@ -0,0 +1,144 @@
|
|||
#include "IOutputStream.h"
|
||||
|
||||
IOutputStream::~IOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
void IOutputStream::WriteBool(bool Val)
|
||||
{
|
||||
char ChrVal = (Val ? 1 : 0);
|
||||
WriteBytes(&ChrVal, 1);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteByte(char Val)
|
||||
{
|
||||
WriteBytes(&Val, 1);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteShort(short Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 2);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteLong(long Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 4);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteLongLong(long long Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 8);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteFloat(float Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 4);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteDouble(double Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 8);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteFourCC(long Val)
|
||||
{
|
||||
if (IOUtil::kSystemEndianness == IOUtil::eLittleEndian) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 4);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteString(const TString& rkVal)
|
||||
{
|
||||
WriteBytes(rkVal.Data(), rkVal.Size());
|
||||
|
||||
if (rkVal.IsEmpty() || rkVal.Back() != '\0')
|
||||
WriteByte(0);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteString(const TString& rkVal, u32 Count, bool Terminate)
|
||||
{
|
||||
WriteBytes(rkVal.Data(), Count);
|
||||
|
||||
if (Terminate && (Count == 0 || rkVal.Back() != '\0'))
|
||||
WriteByte(0);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteSizedString(const TString& rkVal)
|
||||
{
|
||||
WriteLong(rkVal.Size());
|
||||
WriteBytes(rkVal.Data(), rkVal.Size());
|
||||
}
|
||||
|
||||
void IOutputStream::WriteWideString(const TWideString& rkVal)
|
||||
{
|
||||
WriteBytes(rkVal.Data(), rkVal.Size() * 2);
|
||||
|
||||
if (rkVal.IsEmpty() || rkVal.Back() != '\0')
|
||||
WriteShort(0);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteWideString(const TWideString& rkVal, u32 Count, bool Terminate)
|
||||
{
|
||||
WriteBytes(rkVal.Data(), Count * 2);
|
||||
|
||||
if (Terminate && (Count == 0 || rkVal.Back() != 0))
|
||||
WriteShort(0);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteSizedWideString(const TWideString& rkVal)
|
||||
{
|
||||
WriteLong(rkVal.Size());
|
||||
WriteBytes(rkVal.Data(), rkVal.Size() * 2);
|
||||
}
|
||||
|
||||
bool IOutputStream::GoTo(u32 Address)
|
||||
{
|
||||
return Seek(Address, SEEK_SET);
|
||||
}
|
||||
|
||||
bool IOutputStream::Skip(s32 SkipAmount)
|
||||
{
|
||||
return Seek(SkipAmount, SEEK_CUR);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteToBoundary(u32 Boundary, u8 Fill)
|
||||
{
|
||||
u32 Num = Boundary - (Tell() % Boundary);
|
||||
if (Num == Boundary) return;
|
||||
for (u32 iByte = 0; iByte < Num; iByte++)
|
||||
WriteByte(Fill);
|
||||
}
|
||||
|
||||
void IOutputStream::SetEndianness(IOUtil::EEndianness Endianness)
|
||||
{
|
||||
mDataEndianness = Endianness;
|
||||
}
|
||||
|
||||
void IOutputStream::SetDestString(const TString& rkDest)
|
||||
{
|
||||
mDataDest = rkDest;
|
||||
}
|
||||
|
||||
IOUtil::EEndianness IOutputStream::GetEndianness() const
|
||||
{
|
||||
return mDataEndianness;
|
||||
}
|
||||
|
||||
TString IOutputStream::GetDestString() const
|
||||
{
|
||||
return mDataDest;
|
||||
}
|
||||
|
||||
bool IOutputStream::Seek64(s64 Offset, u32 Origin)
|
||||
{
|
||||
return Seek((s32) Offset, Origin);
|
||||
}
|
||||
|
||||
u64 IOutputStream::Tell64() const
|
||||
{
|
||||
return (u64) (Tell());
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef IOUTPUTSTREAM_H
|
||||
#define IOUTPUTSTREAM_H
|
||||
|
||||
#include "IOUtil.h"
|
||||
#include "Common/TString.h"
|
||||
|
||||
class IOutputStream
|
||||
{
|
||||
protected:
|
||||
IOUtil::EEndianness mDataEndianness;
|
||||
TString mDataDest;
|
||||
|
||||
public:
|
||||
void WriteBool(bool Val);
|
||||
void WriteByte(char Val);
|
||||
void WriteShort(short Val);
|
||||
void WriteLong(long Val);
|
||||
void WriteLongLong(long long Val);
|
||||
void WriteFloat(float Val);
|
||||
void WriteDouble(double Val);
|
||||
void WriteFourCC(long Val);
|
||||
void WriteString(const TString& rkVal);
|
||||
void WriteString(const TString& rkVal, u32 Count, bool Terminate = false);
|
||||
void WriteSizedString(const TString& rkVal);
|
||||
void WriteWideString(const TWideString& rkVal);
|
||||
void WriteWideString(const TWideString& rkVal, u32 Count, bool Terminate = false);
|
||||
void WriteSizedWideString(const TWideString& rkVal);
|
||||
|
||||
bool GoTo(u32 Address);
|
||||
bool Skip(s32 SkipAmount);
|
||||
|
||||
void WriteToBoundary(u32 Boundary, u8 Fill);
|
||||
void SetEndianness(IOUtil::EEndianness Endianness);
|
||||
void SetDestString(const TString& rkDest);
|
||||
IOUtil::EEndianness GetEndianness() const;
|
||||
TString GetDestString() const;
|
||||
|
||||
virtual ~IOutputStream();
|
||||
virtual void WriteBytes(const void *pkSrc, u32 Count) = 0;
|
||||
virtual bool Seek(s32 Offset, u32 Origin) = 0;
|
||||
virtual bool Seek64(s64 Offset, u32 Origin);
|
||||
virtual u32 Tell() const = 0;
|
||||
virtual u64 Tell64() const;
|
||||
virtual bool EoF() const = 0;
|
||||
virtual bool IsValid() const = 0;
|
||||
virtual u32 Size() const = 0;
|
||||
};
|
||||
#endif // COUTPUTSTREAM_H
|
|
@ -4,7 +4,7 @@
|
|||
#include "IArchive.h"
|
||||
#include "CSerialVersion.h"
|
||||
#include "Common/CFourCC.h"
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include "Common/FileIO/IInputStream.h"
|
||||
|
||||
// This is a basic binary reader that doesn't do any checks on parameter names.
|
||||
// This is the fastest serializer, but it relies entirely on parameter order so
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "IArchive.h"
|
||||
#include "Common/CFourCC.h"
|
||||
#include <FileIO/IOutputStream.h>
|
||||
#include "Common/FileIO/IOutputStream.h"
|
||||
|
||||
// This is a basic binary reader that doesn't do any checks on parameter names.
|
||||
// This is the fastest serializer, but it relies entirely on parameter order so
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#define CSERIALVERSION
|
||||
|
||||
#include "Common/EGame.h"
|
||||
#include "Common/FileIO.h"
|
||||
#include "Common/types.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
|
||||
class CSerialVersion
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define TSTRING_H
|
||||
|
||||
#include "types.h"
|
||||
#include <FileIO/IOUtil.h>
|
||||
#include "Common/FileIO/IOUtil.h"
|
||||
|
||||
#include <cstdarg>
|
||||
#include <iomanip>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef COMPRESSIONUTIL_H
|
||||
#define COMPRESSIONUTIL_H
|
||||
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
#include <Common/TString.h>
|
||||
#include <Common/types.h>
|
||||
|
||||
|
|
|
@ -24,8 +24,7 @@ CONFIG (debug, debug|release) {
|
|||
TARGET = Cored
|
||||
|
||||
# Debug Libs
|
||||
LIBS += -L$$BUILD_DIR/FileIO/ -lFileIOd \
|
||||
-L$$BUILD_DIR/Common/ -lCommond \
|
||||
LIBS += -L$$BUILD_DIR/Common/ -lCommond \
|
||||
-L$$BUILD_DIR/Math/ -lMathd \
|
||||
-L$$EXTERNALS_DIR/assimp/lib/ -lassimp-vc140-mtd \
|
||||
-L$$EXTERNALS_DIR/lzo-2.09/lib/ -llzo2d \
|
||||
|
@ -36,8 +35,7 @@ CONFIG (debug, debug|release) {
|
|||
|
||||
# Debug Target Dependencies
|
||||
win32 {
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/FileIO/FileIOd.lib \
|
||||
$$BUILD_DIR/Common/Commond.lib \
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/Common/Commond.lib \
|
||||
$$BUILD_DIR/Math/Mathd.lib
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +46,7 @@ CONFIG (release, debug|release) {
|
|||
TARGET = Core
|
||||
|
||||
# Release Libs
|
||||
LIBS += -L$$BUILD_DIR/FileIO/ -lFileIO \
|
||||
-L$$BUILD_DIR/Common/ -lCommon \
|
||||
LIBS += -L$$BUILD_DIR/Common/ -lCommon \
|
||||
-L$$BUILD_DIR/Math/ -lMath \
|
||||
-L$$EXTERNALS_DIR/assimp/lib/ -lassimp-vc140-mt \
|
||||
-L$$EXTERNALS_DIR/lzo-2.09/lib/ -llzo2 \
|
||||
|
@ -60,8 +57,7 @@ CONFIG (release, debug|release) {
|
|||
|
||||
# Release Target Dependencies
|
||||
win32 {
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/FileIO/FileIO.lib \
|
||||
$$BUILD_DIR/Common/Common.lib \
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/Common/Common.lib \
|
||||
$$BUILD_DIR/Math/Math.lib
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#define CDEPENDENCYTREE
|
||||
|
||||
#include "CResourceEntry.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/AssertMacro.h>
|
||||
#include <Common/CAssetID.h>
|
||||
#include <Common/FileIO.h>
|
||||
|
||||
class CScriptLayer;
|
||||
class CScriptObject;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include "Core/CompressionUtil.h"
|
||||
#include "Core/Resource/CWorld.h"
|
||||
#include "Core/Resource/Script/CMasterTemplate.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/AssertMacro.h>
|
||||
#include <Common/CScopedTimer.h>
|
||||
#include <Common/FileIO.h>
|
||||
#include <Common/FileUtil.h>
|
||||
#include <Common/Serialization/CXMLWriter.h>
|
||||
#include <tinyxml2.h>
|
||||
|
|
|
@ -198,7 +198,7 @@ CGameProject* CGameProject::LoadProject(const TWideString& rkProjPath)
|
|||
}
|
||||
|
||||
CTemplateLoader::LoadGameTemplates(pProj->mGame);
|
||||
pProj->mProjFileLock.Lock(*ProjPath);
|
||||
pProj->mProjFileLock.Lock(ProjPath);
|
||||
pProj->mpGameInfo->LoadGameInfo(pProj->mGame);
|
||||
pProj->mpAudioManager->LoadAssets();
|
||||
return pProj;
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
#include "CResourceStore.h"
|
||||
#include "Core/CAudioManager.h"
|
||||
#include "Core/Resource/Script/CMasterTemplate.h"
|
||||
#include <FileIO/CFileLock.h>
|
||||
#include <Common/CAssetID.h>
|
||||
#include <Common/EGame.h>
|
||||
#include <Common/FileUtil.h>
|
||||
#include <Common/TString.h>
|
||||
#include <Common/types.h>
|
||||
#include <Common/FileIO/CFileLock.h>
|
||||
|
||||
class CGameProject
|
||||
{
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include "CGameProject.h"
|
||||
#include "Core/CompressionUtil.h"
|
||||
#include "Core/Resource/Cooker/CWorldCooker.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/AssertMacro.h>
|
||||
#include <Common/FileIO.h>
|
||||
#include <Common/FileUtil.h>
|
||||
#include <Common/Serialization/XML.h>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Core/Resource/CResource.h"
|
||||
#include "Core/Resource/Cooker/CResourceCooker.h"
|
||||
#include "Core/Resource/Factory/CResourceFactory.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
#include <Common/FileUtil.h>
|
||||
#include <Common/TString.h>
|
||||
#include <Common/Serialization/CXMLReader.h>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <Common/Log.h>
|
||||
#include <Common/TString.h>
|
||||
#include <Common/types.h>
|
||||
#include <FileIO/CTextInStream.h>
|
||||
#include <Common/FileIO/CTextInStream.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef CLIGHT_H
|
||||
#define CLIGHT_H
|
||||
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <Common/CColor.h>
|
||||
#include <Common/FileIO/IInputStream.h>
|
||||
#include <Math/CVector3f.h>
|
||||
|
||||
/* CLight is currently heavily based on the lights system from Metroid Prime,
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <Common/EGame.h>
|
||||
#include <Common/Flags.h>
|
||||
#include <Common/types.h>
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <Common/FileIO/IInputStream.h>
|
||||
|
||||
class CMaterialSet;
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "CMaterial.h"
|
||||
#include "CTexture.h"
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <Common/EGame.h>
|
||||
#include <Common/FileIO/IInputStream.h>
|
||||
|
||||
class CMaterialSet
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "CResource.h"
|
||||
#include "ETexelFormat.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
#include <Common/types.h>
|
||||
#include <Math/CVector2f.h>
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "CSectionMgrOut.h"
|
||||
#include "Core/Resource/Area/CGameArea.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/EGame.h>
|
||||
#include <Common/FileIO.h>
|
||||
|
||||
class CAreaCooker
|
||||
{
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#define CMODELCOOKER_H
|
||||
|
||||
#include "Core/Resource/Model/CModel.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/EGame.h>
|
||||
#include <Common/FileIO.h>
|
||||
|
||||
class CModelCooker
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define CPOITOWORLDCOOKER_H
|
||||
|
||||
#include "Core/Resource/CPoiToWorld.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
|
||||
class CPoiToWorldCooker
|
||||
{
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "Core/Resource/Script/CScriptLayer.h"
|
||||
#include "Core/Resource/Script/CScriptObject.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/EGame.h>
|
||||
#include <Common/FileIO.h>
|
||||
|
||||
class CScriptCooker
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define CBLOCKMGROUT_H
|
||||
|
||||
#include <Common/types.h>
|
||||
#include <FileIO/IOutputStream.h>
|
||||
#include <Common/FileIO/IOutputStream.h>
|
||||
#include <vector>
|
||||
|
||||
// Small class to manage file sections for CMDL/MREA output
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
#include "Core/Resource/Area/CGameArea.h"
|
||||
#include "Core/Resource/Script/CLink.h"
|
||||
#include <Common/EGame.h>
|
||||
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
|
||||
class CAreaLoader
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Core/Resource/CMaterialSet.h"
|
||||
#include <Common/EGame.h>
|
||||
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
class CMaterialLoader
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#include "Core/Resource/Model/CBasicModel.h"
|
||||
#include "Core/Resource/Model/CModel.h"
|
||||
#include <Common/EGame.h>
|
||||
#include <Common/FileIO.h>
|
||||
#include <Common/Flags.h>
|
||||
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
class CModelLoader
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef CSECTIONMGRIN_H
|
||||
#define CSECTIONMGRIN_H
|
||||
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <Common/types.h>
|
||||
#include <Common/FileIO/IInputStream.h>
|
||||
#include <vector>
|
||||
|
||||
// The purpose of this class is to keep track of data block navigation - required to read CMDL and MREA files correctly
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <Common/CColor.h>
|
||||
#include <Common/types.h>
|
||||
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
|
||||
class CTextureDecoder
|
||||
{
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
#include "Core/GameProject/CResourceStore.h"
|
||||
#include "Core/Resource/CWorld.h"
|
||||
#include <Common/EGame.h>
|
||||
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
|
||||
class CWorldLoader
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Core/Resource/Script/CScriptLayer.h"
|
||||
#include "Core/CRayCollisionTester.h"
|
||||
|
||||
#include <FileIO/CFileInStream.h>
|
||||
#include <Common/FileIO/CFileInStream.h>
|
||||
#include <Common/TString.h>
|
||||
#include <Math/CRay.h>
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@ CONFIG(debug, debug|release) {
|
|||
TARGET = PrimeWorldEditor-debug
|
||||
|
||||
# Debug Libs
|
||||
LIBS += -L$$BUILD_DIR/FileIO/ -lFileIOd \
|
||||
-L$$BUILD_DIR/Common/ -lCommond \
|
||||
LIBS += -L$$BUILD_DIR/Common/ -lCommond \
|
||||
-L$$BUILD_DIR/Math/ -lMathd \
|
||||
-L$$BUILD_DIR/Core/ -lCored \
|
||||
-L$$EXTERNALS_DIR/assimp/lib/ -lassimp-vc140-mtd \
|
||||
|
@ -42,8 +41,7 @@ CONFIG(debug, debug|release) {
|
|||
|
||||
# Debug Target Dependencies
|
||||
win32 {
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/FileIO/FileIOd.lib \
|
||||
$$BUILD_DIR/Common/Commond.lib \
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/Common/Commond.lib \
|
||||
$$BUILD_DIR/Math/Mathd.lib \
|
||||
$$BUILD_DIR/Core/Cored.lib
|
||||
}
|
||||
|
@ -57,8 +55,7 @@ CONFIG(release, debug|release) {
|
|||
TARGET = PrimeWorldEditor
|
||||
|
||||
# Release Libs
|
||||
LIBS += -L$$BUILD_DIR/FileIO/ -lFileIO \
|
||||
-L$$BUILD_DIR/Common/ -lCommon \
|
||||
LIBS += -L$$BUILD_DIR/Common/ -lCommon \
|
||||
-L$$BUILD_DIR/Math/ -lMath \
|
||||
-L$$BUILD_DIR/Core/ -lCore \
|
||||
-L$$EXTERNALS_DIR/assimp/lib/ -lassimp-vc140-mt \
|
||||
|
@ -71,8 +68,7 @@ CONFIG(release, debug|release) {
|
|||
|
||||
# Release Target Dependencies
|
||||
win32 {
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/FileIO/FileIO.lib \
|
||||
$$BUILD_DIR/Common/Common.lib \
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/Common/Common.lib \
|
||||
$$BUILD_DIR/Math/Math.lib \
|
||||
$$BUILD_DIR/Core/Core.lib
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "CDeleteSelectionCommand.h"
|
||||
#include "Editor/CSelectionIterator.h"
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
#include <Core/Resource/Cooker/CScriptCooker.h>
|
||||
#include <Core/Resource/Factory/CScriptLoader.h>
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#ifndef CFILEINSTREAM_H
|
||||
#define CFILEINSTREAM_H
|
||||
|
||||
#include "IInputStream.h"
|
||||
#include "IOUtil.h"
|
||||
|
||||
class CFileInStream : public IInputStream
|
||||
{
|
||||
private:
|
||||
FILE *mpFStream;
|
||||
std::string mName;
|
||||
long mFileSize;
|
||||
|
||||
public:
|
||||
CFileInStream();
|
||||
CFileInStream(const std::string& rkFile);
|
||||
CFileInStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
|
||||
CFileInStream(const CFileInStream& rkSrc);
|
||||
~CFileInStream();
|
||||
void Open(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
|
||||
void Close();
|
||||
|
||||
void ReadBytes(void *pDst, unsigned long Count);
|
||||
bool Seek(long Offset, long Origin);
|
||||
bool Seek64(long long Offset, long Origin);
|
||||
long Tell() const;
|
||||
long long Tell64() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
long Size() const;
|
||||
std::string FileName() const;
|
||||
};
|
||||
|
||||
#endif // CFILEINSTREAM_H
|
|
@ -1,35 +0,0 @@
|
|||
#ifndef CFILEOUTSTREAM_H
|
||||
#define CFILEOUTSTREAM_H
|
||||
|
||||
#include "IOutputStream.h"
|
||||
#include "IOUtil.h"
|
||||
|
||||
class CFileOutStream : public IOutputStream
|
||||
{
|
||||
private:
|
||||
FILE *mpFStream;
|
||||
std::string mName;
|
||||
unsigned long mSize;
|
||||
|
||||
public:
|
||||
CFileOutStream();
|
||||
CFileOutStream(const std::string& rkFile);
|
||||
CFileOutStream(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
|
||||
CFileOutStream(const CFileOutStream& rkSrc);
|
||||
~CFileOutStream();
|
||||
void Open(const std::string& rkFile, IOUtil::EEndianness);
|
||||
void Update(const std::string& rkFile, IOUtil::EEndianness FileEndianness);
|
||||
void Close();
|
||||
|
||||
void WriteBytes(const void *pkSrc, unsigned long Count);
|
||||
bool Seek(long Offset, long Origin);
|
||||
bool Seek64(long long Offset, long Origin);
|
||||
long Tell() const;
|
||||
long long Tell64() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
long Size() const;
|
||||
std::string FileName() const;
|
||||
};
|
||||
|
||||
#endif // CFILEOUTSTREAM_H
|
|
@ -1,30 +0,0 @@
|
|||
#ifndef CMEMORYINSTREAM_H
|
||||
#define CMEMORYINSTREAM_H
|
||||
|
||||
#include "IInputStream.h"
|
||||
#include "IOUtil.h"
|
||||
|
||||
class CMemoryInStream : public IInputStream
|
||||
{
|
||||
const char *mpDataStart;
|
||||
long mDataSize;
|
||||
long mPos;
|
||||
|
||||
public:
|
||||
CMemoryInStream();
|
||||
CMemoryInStream(const void *pData, unsigned long Size, IOUtil::EEndianness dataEndianness);
|
||||
~CMemoryInStream();
|
||||
void SetData(const void *pData, unsigned long Size, IOUtil::EEndianness dataEndianness);
|
||||
|
||||
void ReadBytes(void *pDst, unsigned long Count);
|
||||
bool Seek(long Offset, long Origin);
|
||||
long Tell() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
long Size() const;
|
||||
void SetSize(unsigned long Size);
|
||||
const void* Data() const;
|
||||
const void* DataAtPosition() const;
|
||||
};
|
||||
|
||||
#endif // CMEMORYINSTREAM_H
|
|
@ -1,31 +0,0 @@
|
|||
#ifndef CMEMORYOUTSTREAM_H
|
||||
#define CMEMORYOUTSTREAM_H
|
||||
|
||||
#include "IOutputStream.h"
|
||||
|
||||
class CMemoryOutStream : public IOutputStream
|
||||
{
|
||||
char *mpDataStart;
|
||||
long mDataSize;
|
||||
long mPos;
|
||||
long mUsed;
|
||||
|
||||
public:
|
||||
CMemoryOutStream();
|
||||
CMemoryOutStream(void *pData, unsigned long Size, IOUtil::EEndianness mDataEndianness);
|
||||
~CMemoryOutStream();
|
||||
void SetData(void *pData, unsigned long Size, IOUtil::EEndianness mDataEndianness);
|
||||
|
||||
void WriteBytes(const void *pkSrc, unsigned long Count);
|
||||
bool Seek(long Offset, long Origin);
|
||||
long Tell() const;
|
||||
bool EoF() const;
|
||||
bool IsValid() const;
|
||||
long Size() const;
|
||||
long SpaceUsed() const;
|
||||
void SetSize(unsigned long Size);
|
||||
void* Data() const;
|
||||
void* DataAtPosition() const;
|
||||
};
|
||||
|
||||
#endif // CMEMORYOUTSTREAM_H
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef FILEIO_H
|
||||
#define FILEIO_H
|
||||
|
||||
#include "IOUtil.h"
|
||||
|
||||
#include "IInputStream.h"
|
||||
#include "CFileInStream.h"
|
||||
#include "CMemoryInStream.h"
|
||||
#include "CTextInStream.h"
|
||||
|
||||
#include "IOutputStream.h"
|
||||
#include "CFileOutStream.h"
|
||||
#include "CMemoryOutStream.h"
|
||||
#include "CVectorOutStream.h"
|
||||
#include "CTextOutStream.h"
|
||||
|
||||
#include "CBitStreamInWrapper.h"
|
||||
|
||||
#endif // FILEIO
|
|
@ -1,59 +0,0 @@
|
|||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-12-16T12:35:06
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT -= core gui
|
||||
DEFINES += PWE_FILEIO
|
||||
|
||||
CONFIG += staticlib
|
||||
TEMPLATE = lib
|
||||
DESTDIR = $$BUILD_DIR/FileIO
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
INSTALLS += target
|
||||
}
|
||||
|
||||
CONFIG (debug, debug|release) {
|
||||
# Debug Config
|
||||
OBJECTS_DIR = $$BUILD_DIR/FileIO/debug
|
||||
TARGET = FileIOd
|
||||
}
|
||||
|
||||
CONFIG (release, debug|release) {
|
||||
# Release Config
|
||||
OBJECTS_DIR = $$BUILD_DIR/FileIO/release
|
||||
TARGET = FileIO
|
||||
}
|
||||
|
||||
# Header Files
|
||||
HEADERS += \
|
||||
CFileInStream.h \
|
||||
CFileOutStream.h \
|
||||
CMemoryInStream.h \
|
||||
CMemoryOutStream.h \
|
||||
CTextInStream.h \
|
||||
CTextOutStream.h \
|
||||
CVectorOutStream.h \
|
||||
FileIO.h \
|
||||
IOUtil.h \
|
||||
IInputStream.h \
|
||||
IOutputStream.h \
|
||||
CBitStreamInWrapper.h \
|
||||
CFileLock.h
|
||||
|
||||
# Source Files
|
||||
SOURCES += \
|
||||
CFileInStream.cpp \
|
||||
CFileOutStream.cpp \
|
||||
CMemoryInStream.cpp \
|
||||
CMemoryOutStream.cpp \
|
||||
CTextInStream.cpp \
|
||||
CTextOutStream.cpp \
|
||||
CVectorOutStream.cpp \
|
||||
IOUtil.cpp \
|
||||
IInputStream.cpp \
|
||||
IOutputStream.cpp \
|
||||
CBitStreamInWrapper.cpp
|
|
@ -1,58 +0,0 @@
|
|||
#ifndef IINPUTSTREAM_H
|
||||
#define IINPUTSTREAM_H
|
||||
|
||||
#include "IOUtil.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class IInputStream
|
||||
{
|
||||
protected:
|
||||
IOUtil::EEndianness mDataEndianness;
|
||||
std::string mDataSource;
|
||||
|
||||
public:
|
||||
bool ReadBool();
|
||||
char ReadByte();
|
||||
short ReadShort();
|
||||
long ReadLong();
|
||||
long long ReadLongLong();
|
||||
float ReadFloat();
|
||||
double ReadDouble();
|
||||
long ReadFourCC();
|
||||
std::string ReadString();
|
||||
std::string ReadString(unsigned long Count);
|
||||
std::string ReadSizedString();
|
||||
std::wstring ReadWString();
|
||||
std::wstring ReadWString(unsigned long Count);
|
||||
std::wstring ReadSizedWString();
|
||||
|
||||
char PeekByte();
|
||||
short PeekShort();
|
||||
long PeekLong();
|
||||
long long PeekLongLong();
|
||||
float PeekFloat();
|
||||
double PeekDouble();
|
||||
long PeekFourCC();
|
||||
|
||||
bool GoTo(long Address);
|
||||
bool Skip(long SkipAmount);
|
||||
|
||||
void SeekToBoundary(unsigned long Boundary);
|
||||
void SetEndianness(IOUtil::EEndianness Endianness);
|
||||
void SetSourceString(const std::string& rkSource);
|
||||
IOUtil::EEndianness GetEndianness() const;
|
||||
std::string GetSourceString() const;
|
||||
|
||||
virtual ~IInputStream();
|
||||
virtual void ReadBytes(void *pDst, unsigned long Count) = 0;
|
||||
virtual bool Seek(long Offset, long Origin) = 0;
|
||||
virtual bool Seek64(long long Offset, long Origin);
|
||||
virtual long Tell() const = 0;
|
||||
virtual long long Tell64() const;
|
||||
virtual bool EoF() const = 0;
|
||||
virtual bool IsValid() const = 0;
|
||||
virtual long Size() const = 0;
|
||||
};
|
||||
|
||||
#endif // IINPUTSTREAM_H
|
|
@ -1,148 +0,0 @@
|
|||
#include "IOutputStream.h"
|
||||
|
||||
IOutputStream::~IOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
void IOutputStream::WriteBool(bool Val)
|
||||
{
|
||||
char ChrVal = (Val ? 1 : 0);
|
||||
WriteBytes(&ChrVal, 1);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteByte(char Val)
|
||||
{
|
||||
WriteBytes(&Val, 1);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteShort(short Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 2);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteLong(long Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 4);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteLongLong(long long Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 8);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteFloat(float Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 4);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteDouble(double Val)
|
||||
{
|
||||
if (mDataEndianness != IOUtil::kSystemEndianness) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 8);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteFourCC(long Val)
|
||||
{
|
||||
if (IOUtil::kSystemEndianness == IOUtil::eLittleEndian) IOUtil::SwapBytes(Val);
|
||||
WriteBytes(&Val, 4);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteString(const std::string& rkVal)
|
||||
{
|
||||
for (unsigned int i = 0; i < rkVal.size(); i++)
|
||||
WriteByte(rkVal[i]);
|
||||
|
||||
if (rkVal.empty() || rkVal.back() != '\0')
|
||||
WriteByte(0);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteString(const std::string& rkVal, unsigned long Count, bool Terminate)
|
||||
{
|
||||
for (unsigned int iChr = 0; iChr < Count; iChr++)
|
||||
WriteByte(rkVal[iChr]);
|
||||
|
||||
if (Terminate && (Count == 0 || rkVal[Count-1] != '\0'))
|
||||
WriteByte(0);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteSizedString(const std::string& rkVal)
|
||||
{
|
||||
WriteLong(rkVal.size());
|
||||
WriteBytes(rkVal.data(), rkVal.size());
|
||||
}
|
||||
|
||||
void IOutputStream::WriteWideString(const std::wstring& rkVal)
|
||||
{
|
||||
for (unsigned int iChr = 0; iChr < rkVal.size(); iChr++)
|
||||
WriteShort(rkVal[iChr]);
|
||||
|
||||
if (rkVal.empty() || rkVal.back() != '\0')
|
||||
WriteShort(0);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteWideString(const std::wstring& rkVal, unsigned long Count, bool Terminate)
|
||||
{
|
||||
for (unsigned int iChr = 0; iChr < Count; iChr++)
|
||||
WriteShort(rkVal[iChr]);
|
||||
|
||||
if (Terminate && (Count == 0 || rkVal[Count-1] != 0))
|
||||
WriteShort(0);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteSizedWideString(const std::wstring& rkVal)
|
||||
{
|
||||
WriteLong(rkVal.size());
|
||||
WriteBytes(rkVal.data(), rkVal.size() * 2);
|
||||
}
|
||||
|
||||
bool IOutputStream::GoTo(long Address)
|
||||
{
|
||||
return Seek(Address, SEEK_SET);
|
||||
}
|
||||
|
||||
bool IOutputStream::Skip(long SkipAmount)
|
||||
{
|
||||
return Seek(SkipAmount, SEEK_CUR);
|
||||
}
|
||||
|
||||
void IOutputStream::WriteToBoundary(unsigned long Boundary, unsigned char Fill)
|
||||
{
|
||||
long Num = Boundary - (Tell() % Boundary);
|
||||
if (Num == Boundary) return;
|
||||
for (int iByte = 0; iByte < Num; iByte++)
|
||||
WriteByte(Fill);
|
||||
}
|
||||
|
||||
void IOutputStream::SetEndianness(IOUtil::EEndianness Endianness)
|
||||
{
|
||||
mDataEndianness = Endianness;
|
||||
}
|
||||
|
||||
void IOutputStream::SetDestString(const std::string& rkDest)
|
||||
{
|
||||
mDataDest = rkDest;
|
||||
}
|
||||
|
||||
IOUtil::EEndianness IOutputStream::GetEndianness() const
|
||||
{
|
||||
return mDataEndianness;
|
||||
}
|
||||
|
||||
std::string IOutputStream::GetDestString() const
|
||||
{
|
||||
return mDataDest;
|
||||
}
|
||||
|
||||
bool IOutputStream::Seek64(long long Offset, long Origin)
|
||||
{
|
||||
return Seek((long) Offset, Origin);
|
||||
}
|
||||
|
||||
long long IOutputStream::Tell64() const
|
||||
{
|
||||
return (long long) (Tell());
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
#ifndef IOUTPUTSTREAM_H
|
||||
#define IOUTPUTSTREAM_H
|
||||
|
||||
#include "IOUtil.h"
|
||||
#include <string>
|
||||
|
||||
class IOutputStream
|
||||
{
|
||||
protected:
|
||||
IOUtil::EEndianness mDataEndianness;
|
||||
std::string mDataDest;
|
||||
|
||||
public:
|
||||
void WriteBool(bool Val);
|
||||
void WriteByte(char Val);
|
||||
void WriteShort(short Val);
|
||||
void WriteLong(long Val);
|
||||
void WriteLongLong(long long Val);
|
||||
void WriteFloat(float Val);
|
||||
void WriteDouble(double Val);
|
||||
void WriteFourCC(long Val);
|
||||
void WriteString(const std::string& rkVal);
|
||||
void WriteString(const std::string& rkVal, unsigned long Count, bool Terminate = false);
|
||||
void WriteSizedString(const std::string& rkVal);
|
||||
void WriteWideString(const std::wstring& rkVal);
|
||||
void WriteWideString(const std::wstring& rkVal, unsigned long Count, bool Terminate = false);
|
||||
void WriteSizedWideString(const std::wstring& rkVal);
|
||||
|
||||
bool GoTo(long Address);
|
||||
bool Skip(long SkipAmount);
|
||||
|
||||
void WriteToBoundary(unsigned long Boundary, unsigned char Fill);
|
||||
void SetEndianness(IOUtil::EEndianness Endianness);
|
||||
void SetDestString(const std::string& rkDest);
|
||||
IOUtil::EEndianness GetEndianness() const;
|
||||
std::string GetDestString() const;
|
||||
|
||||
virtual ~IOutputStream();
|
||||
virtual void WriteBytes(const void *pkSrc, unsigned long Count) = 0;
|
||||
virtual bool Seek(long Offset, long Origin) = 0;
|
||||
virtual bool Seek64(long long Offset, long Origin);
|
||||
virtual long Tell() const = 0;
|
||||
virtual long long Tell64() const;
|
||||
virtual bool EoF() const = 0;
|
||||
virtual bool IsValid() const = 0;
|
||||
virtual long Size() const = 0;
|
||||
};
|
||||
#endif // COUTPUTSTREAM_H
|
|
@ -2,9 +2,9 @@
|
|||
#define CAABOX_H
|
||||
|
||||
#include "CVector3f.h"
|
||||
#include <Common/FileIO/IInputStream.h>
|
||||
#include <Common/FileIO/IOutputStream.h>
|
||||
#include <Common/Serialization/IArchive.h>
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <FileIO/IOutputStream.h>
|
||||
#include <utility>
|
||||
|
||||
class CRay;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef CTRANSFORM4F_H
|
||||
#define CTRANSFORM4F_H
|
||||
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/FileIO.h>
|
||||
#include <Common/Serialization/IArchive.h>
|
||||
#include "CMatrix4f.h"
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef CVECTOR2F
|
||||
#define CVECTOR2F
|
||||
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <FileIO/IOutputStream.h>
|
||||
#include <Common/FileIO/IInputStream.h>
|
||||
#include <Common/FileIO/IOutputStream.h>
|
||||
|
||||
class CVector2f
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef CVECTOR2I_H
|
||||
#define CVECTOR2I_H
|
||||
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <FileIO/IOutputStream.h>
|
||||
#include <Common/FileIO/IInputStream.h>
|
||||
#include <Common/FileIO/IOutputStream.h>
|
||||
|
||||
class CVector2i
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef CVECTOR3F_H
|
||||
#define CVECTOR3F_H
|
||||
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <FileIO/IOutputStream.h>
|
||||
#include <Common/FileIO/IInputStream.h>
|
||||
#include <Common/FileIO/IOutputStream.h>
|
||||
#include <Common/Serialization/IArchive.h>
|
||||
#include <ostream>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef CVECTOR4F
|
||||
#define CVECTOR4F
|
||||
|
||||
#include <FileIO/IInputStream.h>
|
||||
#include <FileIO/IOutputStream.h>
|
||||
#include <Common/FileIO/IInputStream.h>
|
||||
#include <Common/FileIO/IOutputStream.h>
|
||||
|
||||
class CMatrix4f;
|
||||
class CTransform4f;
|
||||
|
|
|
@ -23,14 +23,12 @@ CONFIG (debug, debug|release) {
|
|||
TARGET = Mathd
|
||||
|
||||
# Debug Libs
|
||||
LIBS += -L$$BUILD_DIR/FileIO/ -lFileIOd \
|
||||
-L$$BUILD_DIR/Common/ -lCommond \
|
||||
LIBS += -L$$BUILD_DIR/Common/ -lCommond \
|
||||
-L$$EXTERNALS_DIR/tinyxml2/lib/ -ltinyxml2d
|
||||
|
||||
# Debug Target Dependencies
|
||||
win32 {
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/FileIO/FileIOd.lib \
|
||||
$$BUILD_DIR/Common/Commond.lib
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/Common/Commond.lib
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,14 +38,12 @@ CONFIG (release, debug|release) {
|
|||
TARGET = Math
|
||||
|
||||
# Release Libs
|
||||
LIBS += -L$$BUILD_DIR/FileIO/ -lFileIO \
|
||||
-L$$BUILD_DIR/Common/ -lCommon \
|
||||
LIBS += -L$$BUILD_DIR/Common/ -lCommon \
|
||||
-L$$EXTERNALS_DIR/tinyxml2/lib/ -ltinyxml2
|
||||
|
||||
# Release Target Dependencies
|
||||
win32 {
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/FileIO/FileIO.lib \
|
||||
$$BUILD_DIR/Common/Common.lib
|
||||
PRE_TARGETDEPS += $$BUILD_DIR/Common/Common.lib
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
FileIO \
|
||||
Common \
|
||||
Math \
|
||||
Core \
|
||||
|
|
Loading…
Reference in New Issue