2.3 macfs -- Various file system services

Availability: Macintosh.

Deprecated since release 2.3. The macfs module should be considered obsolete. For FSSpec, FSRef and Alias handling use the Carbon.File or Carbon.Folder module. For file dialogs use the EasyDialogs module.

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 Macintosh: Files. An FSSpec can point to a non-existing file, as long as the folder containing the file exists. Under MacPython the same is true for a pathname, but not under unix-Pyton because of the way pathnames and FSRefs works. See Apple's documentation for details.

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-character 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 which will be displayed at the top of the dialog.

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. You have to first open the directory before clicking on the ``select current directory'' button. prompt is the prompt string which will be displayed at the top of the dialog. 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'' control panel, 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-character string specifying which folder to locate. Setting create causes the folder to be created if it does not exist. Returns a (vrefnum, dirid) tuple.

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

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

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


Subsections
See About this document... for information on suggesting changes.