3#ifndef __CASCLIB_SELF__
4#define __CASCLIB_SELF__
30 unsigned long result = 0;
31 if (!CascReadFile(
m_handle, dest,
static_cast<DWORD
>(bytes), &result))
46 if (CascSetFilePointer(
m_handle,
static_cast<LONG
>(offset),
nullptr, FILE_BEGIN) == CASC_INVALID_POS)
47 LOG_ERROR <<
"Seek in file" <<
filepath <<
"to position" << offset <<
"failed. Error" << GetLastError();
76 s = CascGetFileSize(
m_handle,
nullptr);
78 if (s == CASC_INVALID_SIZE)
89 unsigned long result = 0;
103 for (
const auto& ci : parsed)
106 chunk.
magic = ci.magic;
107 chunk.
start = ci.start;
108 chunk.
size = ci.size;
110 chunks.push_back(std::move(chunk));
128 bool result = CascCloseFile(savedHandle);
132 return CascCloseFile(savedHandle);
144 if (it.magic ==
"AFID")
146 LOG_INFO <<
"Chunk :" << it.magic.c_str() <<
"nb anim file id" << it.size /
sizeof(
AFID);
157 else if (it.magic ==
"SKS1")
161 read(&sks1,
sizeof(sks1));
165 else if (it.magic ==
"SKA1")
169 read(&ska1,
sizeof(ska1));
170 LOG_INFO <<
"Chunk :" << it.magic.c_str() <<
"nAttachments" << ska1.
nAttachments <<
"nAttachLookup" << ska1.
173 else if (it.magic ==
"SKB1")
177 read(&skb1,
sizeof(skb1));
178 LOG_INFO <<
"Chunk :" << it.magic.c_str() <<
"nBones" << skb1.
nBones <<
"nKeyBoneLookup" << skb1.
181 else if (it.magic ==
"SKPD")
185 read(&skpd,
sizeof(skpd));
188 else if (it.magic ==
"BFID")
190 LOG_INFO <<
"Chunk :" << it.magic.c_str() <<
"nb bone files id" << it.size /
sizeof(
uint32);
203 LOG_INFO <<
"Chunk :" << it.magic.c_str() << it.start << it.size;
virtual void doPostOpenOperation()
virtual unsigned long readFile()
virtual bool isAlreadyOpened()
virtual bool doPostCloseOperation()
size_t read(void *dest, size_t bytes)
Read bytes from the file into dest.
virtual bool getFileSize(unsigned long long &s)
CASCFile(std::string path, int id=-1)
void seek(size_t offset)
Seek to an absolute byte offset.
Abstract base class representing a file within the game data archive.
virtual void seek(size_t offset)
Seek to an absolute byte offset.
std::vector< Chunk > chunks
bool close()
Close the file and release the internal buffer.
virtual size_t read(void *dest, size_t bytes)
Read bytes from the file into dest.
const std::string & fullname() const
bool setChunk(std::string chunkName, bool resetToStart=true)
Switch the active read window to the named chunk.
bool isEof()
True if the read pointer has reached the end of the file.
bool isChunked(const unsigned char *data, size_t dataSize)
Determine whether a buffer begins with a known chunked-file header.
std::vector< ChunkInfo > parse(const unsigned char *data, size_t dataSize)
Parse all top-level chunks from a buffer.
Animation file ID entry mapping anim/sub-anim to a CASC file ID (AFID chunk).
uint32 fileId
CASC file data ID.
Skeleton attachment data header (SKA1 chunk).
uint32 nAttachments
Number of attachments.
Skeleton bone data header (SKB1 chunk).
uint32 nBones
Number of bones.
Skeleton parent data chunk (SKPD).
uint32 parentFileId
File data ID of the parent skeleton.
Skeleton sequence data header (SKS1 chunk).
uint32 nAnimationLookup
Number of animation lookup entries.
uint32 nAnimations
Number of animations.
uint32 nGlobalSequences
Number of global sequences.