15.6 Built-in Module macfs

   

This module provides access to macintosh FSSpec handling, the Alias Manager, finder aliases and the Standard File package.

Whenever a function or method expects a file argument, this argument can be one of three things: (1) a full or partial Macintosh pathname, (2) an FSSpec object or (3) a 3-tuple (wdRefNum, parID, name) as described in Inside Mac VI. A description of aliases and the standard file package can also be found there.

FSSpec (file)
Create an FSSpec object for the specified file.

RawFSSpec (data)
Create an FSSpec object given the raw data for the C structure for the FSSpec as a string. This is mainly useful if you have obtained an FSSpec structure over a network.

RawAlias (data)
Create an Alias object given the raw data for the C structure for the alias as a string. This is mainly useful if you have obtained an FSSpec structure over a network.

FInfo ()
Create a zero-filled FInfo object.

ResolveAliasFile (file)
Resolve an alias file. Returns a 3-tuple (fsspec, isfolder, aliased) where fsspec is the resulting FSSpec object, isfolder is true if fsspec points to a folder and aliased is true if the file was an alias in the first place (otherwise the FSSpec object for the file itself is returned).

StandardGetFile ([type, ...])
Present the user with a standard ``open input file'' dialog. Optionally, you can pass up to four 4-char file types to limit the files the user can choose from. The function returns an FSSpec object and a flag indicating that the user completed the dialog without cancelling.

PromptGetFile (prompt[, type, ...])
Similar to StandardGetFile but allows you to specify a prompt.

StandardPutFile (prompt, [default])
Present the user with a standard ``open output file'' dialog. prompt is the prompt string, and the optional default argument initializes the output file name. The function returns an FSSpec object and a flag indicating that the user completed the dialog without cancelling.

GetDirectory ([prompt])
Present the user with a non-standard ``select a directory'' dialog. prompt is the prompt string, and the optional. Return an FSSpec object and a success-indicator.

SetFolder ([fsspec])
Set the folder that is initially presented to the user when one of the file selection dialogs is presented. Fsspec should point to a file in the folder, not the folder itself (the file need not exist, though). If no argument is passed the folder will be set to the current directory, i.e. what os.getcwd() returns.

Note that starting with system 7.5 the user can change Standard File behaviour with the ``general controls'' controlpanel, thereby making this call inoperative.

FindFolder (where, which, create)
Locates one of the ``special'' folders that MacOS knows about, such as the trash or the Preferences folder. Where is the disk to search, which is the 4-char string specifying which folder to locate. Setting create causes the folder to be created if it does not exist. Returns a (vrefnum, dirid) tuple.

NewAliasMinimalFromFullPath (pathname)
Return a minimal alias record object that points to the given file, which must be specified as a full pathname. This is the only way to create an alias record pointing to a non-existing file.

The constants for where and which can be obtained from the standard module MACFS.

FindApplication (creator)
Locate the application with 4-char creator code creator. The function returns an FSSpec object pointing to the application.



guido@python.org