How the Internal File Archive Works in a Wrapped Application
The internal file archive of a wrapped application contains all Tcl scripts and data files that you specify when you wrap an application. TclPro Wrapper incorporates special support into the wrapped application that allows Tcl scripts in the wrapped application to access files in the internal file archive just as if they were stored individually on disk. In other words, your Tcl scripts in a wrapped application can execute standard Tcl commands such as source and open to access files in the internal file archive.
Note: The files in the internal file archive are read-only.
Whether your Tcl script attempts to access a file from the internal file archive or from disk is determined by the following rules:
- If you attempt to access a file using an absolute pathname (for example, /user/kate/images/widget.gif), then your Tcl script always looks for the file on your disk.
- If you attempt to access a file using a relative pathname (for example, images/widget2.gif), then your Tcl script first looks for the file in the internal file archive. If it finds a file in the archive with the exact relative pathname specified, then it uses that file; otherwise, it looks for the file on your disk.
By default, files that you specify in your prowrap command with relative pathnames retain that pathname in the archive. Files that you specify with absolute pathnames are stripped of their drive and root directory characters. You can also modify this behavior by using the prowrap relativeto argument. See "Determining Path References in Wrapped Applications" for information on how pathnames for files in the internal archive of a wrapped application are determined.
Note: The internal file archive isn't a full-fledged filesystem. Instead, the files are stored in the equivalent of a flat table. This has several important implications for accessing files in the archive:
- The current working directory of your Tcl script has no relevance to the pathname you should use to access a file in the archive. For example, if there is a file in the archive that you wrapped with the relative pathname interface/main.tcl, then the two source commands in the following code fragment both access that same file in the archive:
- cd /tmp
source interface/main.tcl
# This accesses the same file as above in a wrapped
# application
cd /usr/local/bin
source interface/main.tcl- The Tcl glob command doesn't match any files in the archive. For example, if you wrap the files images/card1.gif and images/card2.gif, the glob pattern "images/*.gif" fails to match either of these files. If you have an application that depends on the glob command to produce arbitrary lists of wrapped files, you need to rewrite it to use explicit lists of wrapped files. If you use a variable to contain the file list, one technique you can use is to set the value of the variable when you wrap the application using the prowrap code option. The following example uses the Unix back-quote command evaluation and shell filename expansion techniques to set the variable imageList to contain a list of files in the wrapped images directory:
- % prowrap myApp.tcl images/*.gif \
code "set imageList [list `echo images/*.gif`]"- If you attempt to access a file on disk using a relative pathname, and there happens to be a file in the archive with the same pathname, your Tcl script accesses the file in the archive rather than the file on the disk. This is referred to as file shadowing.
- If you attempt to access a file in the archive and a file with that pathname does not exist, then your Tcl script attempts to access the file on disk. This is referred to as fall-through.
"Changing File References" provides guidelines for writing your applications so that they use wrapped files and unwrapped files properly.
http://www.ajubasolutions.com Voice: (650) 210-0100 Fax: (650) 210-0101 support@ajubasolutions.com |