90 ptr->rwops_size = &FsZip::rwops_size;
100 std::string subDir = zipEntry->
subDir;
103 filename =
pathJoin(subDir, filename);
104 dirName =
pathJoin(subDir, dirName);
106 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
110 if ((*it2)->fileName == filename)
112 realDir = entry->root;
116 FOR_EACH (STD_VECTOR<std::string>::const_iterator,
122 realDir = entry->root;
130 std::string filename,
134 std::string subDir = zipEntry->
subDir;
137 filename =
pathJoin(subDir, filename);
138 dirName =
pathJoin(subDir, dirName);
140 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
144 if ((*it2)->fileName == filename)
147 FOR_EACH (STD_VECTOR<std::string>::const_iterator,
162 const std::string subDir = zipEntry->
subDir;
164 dirName =
pathJoin(subDir, dirName);
167 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
175 if (idx != std::string::npos)
192 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
202 if (idx != std::string::npos)
225 const std::string subDir = zipEntry->
subDir;
227 dirName =
pathJoin(subDir, dirName);
230 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
238 if (idx != std::string::npos)
254 FOR_EACH (STD_VECTOR<std::string>::const_iterator,
271 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
281 if (idx != std::string::npos)
300 FOR_EACH (STD_VECTOR<std::string>::const_iterator,
319 const std::string &dirName,
323 const std::string subDir = zipEntry->
subDir;
324 std::string dirNameFull;
326 dirNameFull =
pathJoin(subDir, dirName);
328 dirNameFull = dirName;
331 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
339 if (idx != std::string::npos)
355 FOR_EACH (STD_VECTOR<std::string>::const_iterator,
372 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
382 if (idx != std::string::npos)
401 FOR_EACH (STD_VECTOR<std::string>::const_iterator,
424 const std::string subDir = zipEntry->
subDir;
426 dirName =
pathJoin(subDir, dirName);
429 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
437 if (idx != std::string::npos)
453 FOR_EACH (STD_VECTOR<std::string>::const_iterator,
470 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
480 if (idx != std::string::npos)
499 FOR_EACH (STD_VECTOR<std::string>::const_iterator,
522 std::string subDir = zipEntry->
subDir;
524 dirName =
pathJoin(subDir, dirName);
525 FOR_EACH (STD_VECTOR<std::string>::const_iterator,
544 std::string filename)
547 std::string subDir = zipEntry->
subDir;
549 filename =
pathJoin(subDir, filename);
550 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
555 if (header->fileName == filename)
563 header->uncompressSize);
570 const std::string &filename
A_UNUSED)
572 reportAlways(
"VirtFs::openWrite for zip not implemented.")
577 const std::string &filename
A_UNUSED)
579 reportAlways(
"VirtFs::openAppend for zip not implemented.")
593 const uint32_t objSize,
594 const uint32_t objCount)
596 if (file ==
nullptr ||
602 if (buffer ==
nullptr)
607 const size_t pos = file->mPos;
608 const size_t sz = file->mSize;
613 const uint8_t *
restrict const memPtr = file->mBuf + pos;
615 const uint32_t memSize =
CAST_U32(sz - pos);
617 uint32_t memCount = memSize / objSize;
621 if (memCount > objCount)
624 const size_t memEnd = memCount * objSize;
625 memcpy(buffer, memPtr, memEnd);
626 file->mPos += memEnd;
660 if (pos > file->mSize)
671 return static_cast<int>(file->mPos >= file->mSize);
675 std::string filename,
679 const std::string subDir = zipEntry->
subDir;
681 filename =
pathJoin(subDir, filename);
682 FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
687 if (header->fileName == filename)
698 fileSize = header->uncompressSize;
699 return reinterpret_cast<const char*
>(buf);
#define reportAlways(...)
void log(const char *const log_text,...)
#define FOR_EACH(type, iter, array)
const char * dirSeparator
File * openWrite(FsEntry *const entry, const std::string &filename)
int rwops_read(SDL_RWops *const rw, void *const ptr, const int size, const int maxnum)
bool isDirectory(FsEntry *const entry, std::string dirName, bool &isDirFlag)
void getDirs(FsEntry *const entry, std::string dirName, StringVect &names)
void enumerate(FsEntry *const entry, std::string dirName, StringVect &names)
void getFiles(FsEntry *const entry, std::string dirName, StringVect &names)
const char * loadFile(FsEntry *const entry, std::string filename, int &fileSize)
int rwops_write(SDL_RWops *const rw, const void *const ptr, const int size, const int num)
bool getRealDir(FsEntry *const entry, std::string filename, std::string dirName, std::string &realDir)
int seek(File *const file, const uint64_t pos)
File * openAppend(FsEntry *const entry, const std::string &filename)
int64_t tell(File *const file)
void getFilesWithDir(FsEntry *const entry, const std::string &dirName, StringVect &names)
bool exists(FsEntry *const entry, std::string filename, std::string dirName)
int64_t read(File *const file, void *const buffer, const uint32_t objSize, const uint32_t objCount)
int64_t write(File *const file, const void *const buffer, const uint32_t objSize, const uint32_t objCount)
void initFuncs(FsFuncs *const ptr)
int eof(File *const file)
int rwops_close(SDL_RWops *const rw)
void freeList(List *const handle)
int32_t rwops_seek(SDL_RWops *const rw, const int32_t offset, const int whence)
int64_t fileLength(File *const file)
File * openRead(FsEntry *const entry, std::string filename)
int close(File *const file)
uint8_t * readFile(ZipLocalHeader *header)
bool findCutFirst(std::string &str1, const std::string &str2)
bool findLast(const std::string &str1, const std::string &str2)
std::string pathJoin(std::string str1, const std::string &str2)
StringVect::const_iterator StringVectCIter
std::vector< std::string > StringVect
std::vector< std::string > mDirs
std::vector< ZipLocalHeader * > mHeaders