This commit is contained in:
2025-05-13 02:46:21 +03:00
parent 143e16692e
commit 86914b7fcc
610 changed files with 92343 additions and 2 deletions
+77
View File
@@ -0,0 +1,77 @@
#ifndef IPAKSTREAM_H__
#define IPAKSTREAM_H__
#include "../../IDataStream.h"
#include "../../LString.h"
#include <assert.h>
#include "pak_io/PakFile.h"
namespace LifeCore
{
class IPakStream : public IDataStream
{
private:
PakFile* source;
entry_info info;
int openMode;
size_t stmLength;
PakEntryHandle entry;
public:
~IPakStream(){}
void Close()
{
source->fclose(entry);
openMode = 0;
}
IPakStream(PakFile* file, String& entryName, int fileAccessMode)
{
source = file;
openMode = fileAccessMode;
// source->CloseCurrentEntry();
if (fileAccessMode == FA_READ)
{
entry = source->fopen(entryName);
// source->LocateEntry(entry);
//info = source->GetEntryInfo();
stmLength = source->fget_size(entry);
//source->OpenCurrentEntry();
}
else
{
throw "Creation of new PAK entry is not implemented! IPakStream.h";
//source->NewFileEntry(entry);
}
}
size_t Read(void* pBuffer, size_t countBytes)
{
return source->fread(entry, pBuffer, countBytes);
}
size_t Write(const void* pBuffer, size_t countBytes)
{
source->fwrite(entry, pBuffer, countBytes);
return countBytes;
}
void Seek(size_t position)
{
source->fseek(entry, position);
}
size_t Tell()
{
return source->ftell(entry);
}
size_t Length()
{
return source->fget_size(entry);
}
bool CanRead()
{
return true;
}
bool CanWrite()
{
return true;
}
};
}
#endif