Specifications
Copying files
When Switch copies or moves a file under its own control (for example, between two folders), it
ensures that all available Mac file type information and resource fork data is copied along with
the file. (On Mac OS X this means using the native file operations; on Windows this involves
supporting the emulations discussed above).
This preserves Mac file type information (which may be superfluous if a filename extension is
also present), but more importantly it also preserves any resource fork data - which allows, for
example, to process Classic Mac fonts through Switch on a Windows system.
Note however that other processes and third-party applications may not carry along Mac file
types and resource forks. On Windows this is almost never the case, and even on Mac some
modern applications no longer support these Classic features.
Changing the file type
The file type tool allows setting a file’s filename extension and/or Mac file and creator types to
a specified value. This is handy if you know the correct type of a file (for example, because it
was created by an application under your control) but you suspect that it may not have the
appropriate filename extension or Mac file type information.
Filtering on file type
Several Switch tools offer the possibility to sort files based on file type; see Specifying file filters
on page 97.
13.5 Regular Expressions
Note:
The contents of this topic is adapted from documentation provided by Trolltech.
Introduction
Regular expressions, or "regexps", provide a way to find patterns within text. This is useful in
many contexts, for example a regexp can be used to check whether a piece of text meets some
criteria. In Switch a regular expression can be used to sort files based on some naming scheme:
only files with a name that matches the regular expression are allowed to pass through a certain
connection.
While this is almost surely of no concern for the use of regexps in Switch, it is good to know that
not all regexp implementations are created equal. Most implementations provide identical results
for basic expressions, but the results for more advanced expressions and matches may differ in
subtle ways.
The Switch regexp language is modeled on Perl's regexp language, A good reference on regexps
is Mastering Regular Expressions: Powerful Techniques for Perl and Other Tools by Jeffrey E.
Friedl, ISBN 1565922573. Several web sites offer tools for working with regexps or provide libraries
with examples for matching all sorts of patterns. One simple tool to start playing with regexps
can be found at http://www.roblocher.com/technotes/regexp.aspx.
196
Enfocus Switch 10










