80 lines
1.6 KiB
C++
80 lines
1.6 KiB
C++
#ifndef PAK_FILE_H__
|
|
#define PAK_FILE_H__
|
|
|
|
#include <stdio.h>
|
|
#include <tchar.h>
|
|
#include "../../../LString.h"
|
|
#include "PakTypes.h"
|
|
#include <windows.h>
|
|
#include "pakHeader.h"
|
|
#include "FolderEntry.h"
|
|
#include "FileEntry.h"
|
|
#include "EntryInfo.h"
|
|
#include "../../../IDataStream.h"
|
|
#include <map>
|
|
#define PAK_VERSION 0x0100
|
|
#define PAK_MAX_OPEN_ENTRY 256
|
|
|
|
namespace LifeCore
|
|
{
|
|
struct OpenEntryInfo
|
|
{
|
|
FileEntry* entry;
|
|
int position;
|
|
};
|
|
typedef int PakEntryHandle;
|
|
|
|
class PakFile
|
|
{
|
|
enum PAK_MODE
|
|
{
|
|
PM_WRITE_ENTRY = 0,
|
|
PM_READ_ENTRY = 1,
|
|
PM_EDIT_ENTRY = 2,
|
|
PM_IDLE = 3
|
|
};
|
|
|
|
public:
|
|
PakFile(void);
|
|
~PakFile(void);
|
|
int Open(IDataStream* source);
|
|
|
|
void Close();
|
|
int filesCount();
|
|
entry_info GetEntryInfo(int id);
|
|
PakEntryHandle fopen(const String& name);
|
|
int fread(PakEntryHandle entry, void* buffer, int length);
|
|
int fwrite(PakEntryHandle entry, const void* buffer, int length);
|
|
int ftell(PakEntryHandle entry);
|
|
void fseek(PakEntryHandle entry, int position);
|
|
void fclose(PakEntryHandle entry);
|
|
int fget_size(PakEntryHandle entry);
|
|
private:
|
|
int curFilePosition;
|
|
int curEntryId;
|
|
int freeFileSlots;
|
|
int freeFolderSlots;
|
|
int currentMode;
|
|
FolderEntry* hFolders;
|
|
FileEntry* hFiles;
|
|
IDataStream* pFile;
|
|
PakHeader header;
|
|
void DumpExtraData();
|
|
void DumpHeader();
|
|
FileEntry* tmpEntry;
|
|
|
|
void NewFolderEntry(const String& path);
|
|
void NewFileEntry(const String& path);
|
|
void DeleteFileEntry(const String& path);
|
|
|
|
int LocateEntry(const String& name);
|
|
int LocateEntry(int id);
|
|
|
|
OpenEntryInfo openEntries[PAK_MAX_OPEN_ENTRY];
|
|
int openEntriesCount;
|
|
|
|
BOOL IsLastEntry(const FileEntry* entry);
|
|
};
|
|
}
|
|
|
|
#endif |