First version

This commit is contained in:
stevenhowes
2024-10-30 08:34:11 +00:00
parent 51c983a782
commit e070ec044e
13 changed files with 336 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
#include <iostream>
#include <cstring>
#include "PakFS/PakFS.hpp"
#define PAKFS_BASE "base"
#define PAKFS_PAKS_ONLY false
int main() {
try {
PakFS pakfs(PAKFS_BASE, PAKFS_PAKS_ONLY);
pakfs.listFiles();
std::vector<std::string> filenames{ "testfile", "testfile2", "folder/testfile3" , "folder2/testfile4", "folder2/subfolder1/testfile5" };
for (const auto& filename : filenames) {
int filesize = pakfs.getFileSize(filename);
if(filesize >= 0)
{
std::cout << "File found: " << filename << " Size: " << filesize << std::endl << "----" << std::endl;
uint8_t* ByteArray;
ByteArray = new uint8_t[filesize + 1];
pakfs.getFile(filename, ByteArray);
ByteArray[filesize] = 0;
std::cout << ByteArray << std::endl << "----"<< std::endl;
delete [] ByteArray;
}else{
std::cout << "File not found: " << filename << std::endl << std::endl;
}
}
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}
return 0;
}