craftersmine/Asar.NET

update a file inside the asar? instead of unpacking editing and repacking it again.

Closed this issue · 5 comments

update a file inside the asar? instead of unpacking editing and repacking it again.

You will still need to unpack and repack files at the end of edited file, because if file become bigger, it will overlap file at the end, and make file that located in the end of edited file corrupted

ASAR is still an archive, and no archive format can edit file on the fly without repacking the whole archive, as far as I know

how about an easy way for repacking the unpacked one? I'm having a hard time making Asar out of the unpacked one xD I have like a duplicate key or etc issue.

so far I use 7z.exe with the Asar plugin to do my stuff. and just execute it via c#. I'm rooting for this project and hope repacking will be easy xD I don't like shipping 7 zip haha its ridiculous

You need so separatelly add root entries, for example, if your archive has 3 files and one directory in root, you need to use AddFile() three times and AddDirectory() one time. This is from the project wiki

You need to keep in mind, that all Add methods are relative to archive root, so method AddFile will add file at the root of an archive, if you want to create a directory structure, use AddDirectory to add a directory of files to the archive. AddDirectory will add a provided directory as a directory in an archive root, so directory like C:\some_dir\dir will become asar_arc.asar\dir. All subdirectories and subfiles will be also added to this directory.

This code
image
Will result like this in archive
image