[AndroWish] comes with a special <a virtual file system which uses mmap(2) to read-only map a ZIP file (in this case AndroWish's APK, i.e. its own installation package) into the process address space to speed up startup time and subsequent read accesses. While this file system was designed primarily for AndroWish it can be used on other platforms, too. Namely, [undroidwish] uses it on Windows and Linux to mount an archive of Tcl and native extensions which is appended to the executable portion of its binary. It is implemented in the files <tt><a and <tt><a in AndroWish's folder and enabled in the Tcl core by the presence of the C preprocessor macro <tt>ZIPFS_IN_TCL</tt>.

<h3>Low-level C interface</h3>

<tt>Zipfs_Init(Tcl_Interp *interp)</tt>

    Performs one-time initialization of the file system and registers it process wide. Additionally, a package named <i>zipfs</i> is provided and supplemental Tcl commands are created in the given interpreter.

<tt>Zipfs_Mount(Tcl_Interp *<i>interp</i>, const char *<i>zipname</i>, const char *<i>mntpt</i>, const char

    Mounts the ZIP archive file on the mount point using the optional ZIP password Errors are reported in the interpreter If is NULL information on all currently mounted ZIP file systems is written into as a sequence of mount points and ZIP file names.

<tt>Zipfs_Unmount(Tcl_Interp *<i>interp</i>, const char

    Undoes the effect of <tt>Zipfs_Mount()</tt>, i.e. unmounts the mounted ZIP archive file Errors are reported in the interpreter

<h3>Tcl commands</h3>

<tt>zipfs::mount ?<i>zipfile</i> ?<i>mountpoint

    Mounts the ZIP archive file on mount point using the optional ZIP password If invoked without or with a single argument information as described above in <tt>Zipfs_Mount()</tt> is returned.

<tt>zipfs::unmount <i>zipfile<i></tt>

    Unmounts the mounted ZIP archive file

<tt>zipfs::mkzip <i>outfile indir</i> ?<i>strip

    Creates a ZIP archive file named from the contents of the input directory (contained regular files only) with optional ZIP password While processing the files below the optional prefix given in is stripped off the beginning of the respective file name. Caution: the choice of the parameter (less the optional prefix) determines the later root name of the archive's content.

<tt>zipfs::mkimg <i>outfile indir</i> ?<i>strip password

    Caution: highly experimental, not usable on Android, only partially tested on Linux and Windows. Create an image (potentially a new executable file) similar to <tt>zipfs::mkzip</tt>. If the parameter is specified, this file is prepended in front of the ZIP archive, otherwise the file returned by <tt>Tcl_NameOfExecutable(3)</tt> (i.e. the executable file of the running process) is used. If the parameter is not empty, an obfuscated version of that password is placed between the image and ZIP chunks of the output file and the contents of the ZIP chunk are protected with that password.

<tt>zipfs::exists

    Tests if exists in any of the currently mounted ZIP archives.

<tt>zipfs::info

    Returns information on as a list made up of the name of its enclosing and mounted ZIP archive file, file size uncompressed, file size compressed, and byte offset of the file from start of its enclosing ZIP archive file.

<tt>zipfs::list

    Lists files of any or all of the mounted ZIP archives. If is omitted all files are listed. Otherwise is interpreted as a glob or regexp pattern and used to list only files matching this pattern.

<tt>zipfs::find

    Recursively lists files including and below the directory The result list consists of relative path names starting from the given directory. This command is also used by the <tt>zipfs::mkzip</tt> and <tt>zipfs::mkimg</tt> commands.

<h3>zipfs as Tcl (and Tk) bootstrap file system</h3>

On the Android platform zipfs is used to boot Tcl/Tk from the APK by early mounting the APK file on the file system root. Since nearly all relevant files within the APK are below the <tt>assets</tt> folder, this lets Tcl see the directory with its library directories, e.g. the directory with Tcl's library modules, encoding tables etc. That relationship to is hard coded into the Tcl shared library and based on it all other packaged library directories can be found during Tcl initialization.

For standalone apps a similar approach is chosen by hard coding the file as the file to be sourced (if present) right after Tcl's initialization. This allows for packaging Tcl based apps as an APK, see the description in [AndroWish SDK] for instructions.

On other platforms (currently tested Linux and Windows) the initial mount of an embedded ZIP file system is done on the executable itself, e.g. if is the Tcl/Tk binary with an included ZIP file system, the Tcl library directory of the file system when mounted becomes Similarly, built in application code will be started from the file if present. Additionally, the contents of the optional file are appended to the command line before Tk is initialized and control is transferred to the <tt>main.tcl</tt> script. This is useful to setup certain aspects of SDL, e.g. to start in full screen mode with or without changed display resolution (see description of SDL startup options in [Beyond AndroWish]). Another hook is which (if present) should be a Windows BMP 24 bit RGB bitmap file used as the icon for the SDL root window.

On Windows platforms the drive letter of the base executable is prepended to the respective path names. For the example above this means: is the binary, becomes the Tcl library directory, is the optional application script, and so on.