46 using FileList = std::unordered_map<std::string, FileInfo>;
58 std::vector<std::string> vec_file;
67 for (
auto& iter : vec_file)
79 uint64_t size_file = (uint64_t)buf.
size();
135#ifndef DL_DISABLE_ZLIB
162#ifndef DL_DISABLE_ZLIB
174 for (
auto& [name, info] : all_file)
176 std::byte* p = buf.
data() + info._offset;
177 std::size_t size_file = (std::size_t)*(uint64_t*)p;
178 if (info._size != size_file)
180 log_err(
"文件大小不匹配:{}", size_file);
183 p +=
sizeof(uint64_t);
185 std::string path_name = out + name;
192 { p, size_file }, path_name))
194 log_err(
"文件保存失败:{}", path_name);
199 return count == all_file.
size();
202 static bool Decompress(std::string_view src, std::string_view out)
239#ifndef DL_DISABLE_ZLIB
void Compress(Memory::CompressMode mode)
压缩当前内存
bool Save(std::string_view path_name, bool compress=false)
保存到文件
const std::byte * GetData()
返回指向的内存指针
void Write(const T *data)
写入一个对象
uint32_t HashCrc32(BufferView buf, uint32_t crc=0)
crc32哈希
void GetPathFileAll(std::string_view path, std::vector< std::string > &ret, std::string_view regex="", bool recursion=true)
获取文件夹所有文件
bool SaveBuffer(BufferView buf, std::string_view path_name)
将内存保存为文件
std::string GetFilePath(std::string_view path_name)
返回文件所在路径
bool CreateFolder(std::string_view path)
创建目录
std::string GetRelative(std::string_view path_name, std::string_view path_base)
返回相对路径
Buffer GetBuffer(std::string_view path_name)
返回文件内存
Buffer DecompressLz4(BufferView src, size_t size_origin=0)
解压缩数据,使用lz4算法
Buffer DecompressZip(BufferView src, size_t size_origin=0)
解压缩数据,使用libz