HLLib
HLLib copied to clipboard
Add a new file to a package?
Hi, I am trying to figure out how to add a new file to a package. hlPackageOpenFile() returns 0 if the file does not already exist:
int WriteStream(Package* pak, wchar_t* path, void* data, uint64_t sz)
{
hlBindPackage(pak->hlpak);
auto s = String(path);
if (not hlPackageOpenFile(s.c_str(), HL_MODE_WRITE)) return 0;
auto root = hlPackageGetRoot();
auto item = hlFolderGetItemByPath(root, s.c_str(), HL_FIND_ALL);
HLStream* stream;
hlPackageCreateStream(item, &stream);
hlStreamWrite(stream, data, sz);
hlStreamClose(stream);
pak->modified = true;
return 1;
}
Is it possible to use HLLib to add a new file to the package?