StudioZip:Editing Archives

From MutigerAffe Wiki
Jump to navigation Jump to search

Studio ZIP adds a file system with the scheme zipfs: to VS Code. Files inside an archive can be opened through it like normal files: in editor tabs, with syntax highlighting, find and replace and the other editor features of VS Code.

Opening a file in an editor tab

In the Studio ZIP tab, hover a file and click Open in editor.

  • A normal file opens in a regular VS Code editor tab.
  • A nested archive, for example a .jar inside a .war, opens in its own Studio ZIP tab. From there you can go one level deeper in the same way.

Files from archives that cannot be written open as read-only editors.

Mounting an archive

You can also add an archive to the workspace as an extra folder. It then appears in the Explorer like any other folder, and you can browse, open, create, rename and delete files there.

  • From the Explorer: right-click the archive and choose Mount Archive as Workspace Folder. This menu entry is shown for .zip, .jar, .war, .ear, .aar, .apk, .ipa, .vsix, .nupkg, .whl, .xpi, .crx and .epub.
  • From the Command Palette: run Studio ZIP: Mount Archive as Workspace Folder and choose the archive in the file dialog. This works for the other formats too, including .asar.

The folder is added at the end of the workspace and named after the archive. VS Code cannot show the content under the archive file itself, so it is a separate folder at the bottom of the Explorer. If the archive is already mounted, you get the message <name> is already mounted.

To remove it again, run Studio ZIP: Unmount Archive Workspace Folder and pick the archive from the list, or remove the folder from the workspace as usual. Unmounting does not change the archive.

Searching across files (Ctrl+Shift+F) does not cover mounted archives. Studio ZIP provides no search for its file system.

Which archives can be written

Only the ZIP family can be written: .zip, .jar, .war, .apk, .vsix, .epub and every other format that is a ZIP inside. See Supported Formats.

All other formats are read-only. Changing a single file in a .tar.xz would mean compressing the whole archive again on every save. Their files open as read-only editors, and the summary line of the Studio ZIP tab shows read-only.

A nested archive can be written if every archive in the chain is a ZIP, for example a .jar inside a .war. Saving it writes the inner archive back into the outer one. A ZIP inside a .tar.gz is read-only, because the outer archive cannot be written.

An archive that contains encrypted files cannot be written at all. Saving fails with Cannot write to an archive with encrypted entries (<name>).

What you can change

In a writable archive, the following work from an editor tab or a mounted folder:

  • Save changes to a file (Ctrl+S).
  • Create new files and folders. Missing parent folders are created with them.
  • Delete files and folders. Deleting a folder removes everything in it.
  • Rename and move files and folders inside the same archive.

Moving a file from one archive into another is not possible in one step. Studio ZIP refuses it with Studio ZIP cannot move entries between archives. Copy the file and delete the original instead.

How saving works

ZIP has no way to change one file in place, so every save writes the whole archive again.

  • The new archive is written to a temporary file next to the original (<archive>.studio-zip-<random>.tmp). Only when it is complete does it replace the original. If VS Code crashes while writing, the original stays as it was.
  • The file permissions of the archive itself are kept.
  • Files you did not change are copied over one at a time with their compression method, modification time and Unix permissions, including the executable bit. A stored (uncompressed) file stays stored. This matters for .epub, where the mimetype file must not be compressed.
  • The order of the files is kept. New files are added at the end.
  • Files you changed or added are compressed and get the current time.
  • Saves to the same archive run one after another, so two quick saves cannot overwrite each other.

Large archives are written in a stream, so saving a file in an archive of several gigabytes does not load the whole archive into memory. Saving still takes longer the larger the archive is.

Studio ZIP
Start Installation
Features Archive Tab · Preview · Editing Archives · Supported Formats
Reference Commands and Settings · FAQ · Version History
Links Project page on mutigeraffe.com · Download on the VS Code Marketplace