HLLib icon indicating copy to clipboard operation
HLLib copied to clipboard

Add a new file to a package?

Open UltraEngine opened this issue 1 year ago • 0 comments

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?

UltraEngine avatar Mar 04 '23 17:03 UltraEngine