trofs(n) 0.4 trofs "Tcl Read-Only Filesystem"
trofs - Manage read-only filesystems in archive file
The trofs package provides commands to create, mount, and unmount archive files containing read-only filesystems. Mounted trofs archives contain files, directories, and symbolic links that can be opened and read by Tcl commands just as if they were part of the native filesystem. The public commands documented here are all defined in and exported from the ::trofs namespace.
- archive directory archive
The archive command creates a trofs archive file archive from the contents of directory. Only the contents of directory that are readable will be archived. Unreadable contents will be silently omitted from the archive. If directory is not a readable directory at all, an empty archive will be created. If archive is not an existing file, it will be created (assuming write permission to the directory containing it). If archive is an existing file, it must be writable and seekable. The archive contents will be appended to the archive file, starting with the character \u001A, which is the end of file character for Tcl's source command. This technique allows a trofs archive to be attached to a source-able Tcl script. The archive file created by archive is suitable for use as the first argument to mount. The archive command returns an empty string.
- mount archive ?mountpoint?
The mount command mounts the trofs archive stored in archive as a read-only filesystem. The archive file archive must be a readable, seekable, trofs archive file created by the archive command. If the mountpoint argument is supplied, then [file exists mountpoint] must return 0, and [file system mountpoint] must return either native or trofs before the mount call. If no mountpoint argument is supplied, the mount command will generate a suitable mountpoint path. After a successful mount, [file system mountpoint] will return trofs, [file isdirectory mountpoint] will return 1, and the contents of archive will be visible as contents of the directory mountpoint. The mount command returns the normalized path to mountpoint.
- unmount mountpoint
The unmount command reverses the effect of a prior mount command. The mountpoint argument must be a mountpoint created by a prior call to mount. It can be in normalized form or not; it will be normalized by unmount as part of the search for a matching existing mountpoint. If no such mountpoint is currently mounted, an error is raised. Otherwise, the mount is undone, so that [file exists mountpoint] once again returns 0. The unmount command returns an empty string.
package require trofs namespace import trofs::* archive $directory $archive mount $archive $mountpoint
At this point, both $directory and $mountpoint are directories, and their readable content should be identical.