Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
I use ZipFile::CopyInFileInZip() to compress the file into a zip package. However, when the file name contains non ASCII characters, the file name is replaced with an underscore. Is there a way to use non ASCII file names in zip without using external libraries?
ZipFile::CopyInFileInZip()
AutoAlloc<ZipFile> zf; if (zf == nullptr) return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION); if (!zf->Open(fnZip, false, ZIP_APPEND_CREATE)) return maxon::UnknownError(MAXON_SOURCE_LOCATION); Filename fnCopy; while (fnCopy.FileSelect(FILESELECTTYPE::ANYTHING, FILESELECT::LOAD, "Select file to add to Zip File"_s)) { zf->CopyInFileInZip(fnCopy, "textures/" + fnCopy.GetFileString()); }
Thank, AiMiDi
Hi @AiMiDi you are using the old ZipFile implementation, instead, you should use the new one from the MAXON API as explained in Archives Manual.
And here an example of how to copy a file.
#include "maxon/ioarchivehandler.h" Bool res = false; Filename importFilename; res = importFilename.FileSelect(FILESELECTTYPE::ANYTHING, FILESELECT::LOAD, "Load"_s); if (!res) return maxon::UnknownError(MAXON_SOURCE_LOCATION); maxon::Url importUrl = MaxonConvert(importFilename, MAXONCONVERTMODE::READ); Filename zipFilename; res = zipFilename.FileSelect(FILESELECTTYPE::ANYTHING, FILESELECT::SAVE, "Save"_s, "zip"_s); if (!res) return maxon::UnknownError(MAXON_SOURCE_LOCATION); const maxon::WriteArchiveRef zipArchive = maxon::WriteArchiveClasses::Zip().Create() iferr_return; zipArchive.Open(MaxonConvert(zipFilename, MAXONCONVERTMODE::WRITE), false) iferr_return; zipArchive.SetCompressionLevel(2) iferr_return; zipArchive.CopyFile(importUrl, importUrl.GetName()) iferr_return; zipArchive.Close() iferr_return;
This new Maxon API support correctly non ASCII character. Cheers, Maxime.