Previous: , Up: Usage   [Contents][Index]

5.8 Archive file names

TRAMP offers also transparent access to files inside file archives. This is possible only on hosts which have installed GVFS (the GNOME Virtual File System), GVFS-based methods. Internally, file archives are mounted via the GVFS archive method.

A file archive is a regular file of kind /path/to/dir/file.EXT. The extension ‘.EXT’ identifies the type of the file archive. To examine the contents of an archive with Dired, open file name as if it were a directory (i.e., open /path/to/dir/file.EXT/). A file inside a file archive, called archive file name, has the name /path/to/dir/file.EXT/dir/file.

Most of the (elisp)magic file name operations, are implemented for archive file names, exceptions are all operations which write into a file archive, and process related operations. Therefore, functions like

(copy-file "/path/to/dir/file.tar/dir/file" "/somewhere/else")

work out of the box. This is also true for file name completion, and for libraries like dired or ediff, which accept archive file names as well.

File archives are identified by the file name extension ‘.EXT’. Since GVFS uses internally the library libarchive(3), all suffixes, which are accepted by this library, work also for archive file names. Accepted suffixes are listed in the constant tramp-archive-suffixes. They are

File archives could also be compressed, identified by an additional compression suffix. Valid compression suffixes are listed in the constant tramp-archive-compression-suffixes. They are ‘.bz2’, ‘.gz’, ‘.lrz’, ‘.lz’, ‘.lz4’, ‘.lzma’, ‘.lzo’, ‘.uu’, ‘.xz’, ‘.Z’, and ‘.zst’. A valid archive file name would be /path/to/dir/file.tar.gz/dir/file. Even several suffixes in a row are possible, like /path/to/dir/file.tar.gz.uu/dir/file.

An archive file name could be a remote file name, as in /ftp:anonymous@ftp.gnu.org:/gnu/tramp/tramp-2.4.5.tar.gz/INSTALL. Since all file operations are mapped internally to GVFS operations, remote file names supported by tramp-gvfs perform better, because no local copy of the file archive must be downloaded first. For example, ‘/sftp:user@host:...’ performs better than the similar ‘/scp:user@host:...’. See the constant tramp-archive-all-gvfs-methods for a complete list of tramp-gvfs supported method names.

If url-handler-mode is enabled, archives could be visited via URLs, like https://ftp.gnu.org/gnu/tramp/tramp-2.4.5.tar.gz/INSTALL. This allows complex file operations like

(progn
  (url-handler-mode 1)
  (ediff-directories
   "https://ftp.gnu.org/gnu/tramp/tramp-2.4.4.tar.gz/tramp-2.4.4"
   "https://ftp.gnu.org/gnu/tramp/tramp-2.4.5.tar.gz/tramp-2.4.5" ""))

It is even possible to access file archives in file archives, as

(progn
  (url-handler-mode 1)
  (find-file
   "https://ftp.debian.org/debian/pool/main/c/coreutils/coreutils_8.28-1_amd64.deb/control.tar.gz/control"))

In order to disable file archives, you could add the following form to your init file:

(customize-set-variable 'tramp-archive-enabled nil)

Previous: , Up: Usage   [Contents][Index]