Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 1 | \section{Built-in Module \sectcode{macfs}} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 2 | \bimodindex{macfs} |
| 3 | |
Guido van Rossum | 8675115 | 1995-02-28 17:14:32 +0000 | [diff] [blame] | 4 | \renewcommand{\indexsubitem}{(in module macfs)} |
| 5 | |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 6 | This module provides access to macintosh FSSpec handling, the Alias |
| 7 | Manager, finder aliases and the Standard File package. |
| 8 | |
| 9 | Whenever a function or method expects a \var{file} argument, this |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 10 | argument can be one of three things:\ (1) a full or partial Macintosh |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 11 | pathname, (2) an FSSpec object or (3) a 3-tuple \code{(wdRefNum, |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 12 | parID, name)} as described in Inside Mac VI\@. A description of aliases |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 13 | and the standard file package can also be found there. |
| 14 | |
| 15 | \begin{funcdesc}{FSSpec}{file} |
| 16 | Create an FSSpec object for the specified file. |
| 17 | \end{funcdesc} |
| 18 | |
| 19 | \begin{funcdesc}{RawFSSpec}{data} |
| 20 | Create an FSSpec object given the raw data for the C structure for the |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 21 | FSSpec as a string. This is mainly useful if you have obtained an |
| 22 | FSSpec structure over a network. |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 23 | \end{funcdesc} |
| 24 | |
| 25 | \begin{funcdesc}{RawAlias}{data} |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 26 | Create an Alias object given the raw data for the C structure for the |
| 27 | alias as a string. This is mainly useful if you have obtained an |
| 28 | FSSpec structure over a network. |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 29 | \end{funcdesc} |
| 30 | |
| 31 | \begin{funcdesc}{ResolveAliasFile}{file} |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 32 | Resolve an alias file. Returns a 3-tuple \code{(\var{fsspec}, \var{isfolder}, |
| 33 | \var{aliased})} where \var{fsspec} is the resulting FSSpec object, |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 34 | \var{isfolder} is true if \var{fsspec} points to a folder and |
| 35 | \var{aliased} is true if the file was an alias in the first place |
| 36 | (otherwise the FSSpec object for the file itself is returned). |
| 37 | \end{funcdesc} |
| 38 | |
| 39 | \begin{funcdesc}{StandardGetFile}{\optional{type\, ...}} |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 40 | Present the user with a standard ``open input file'' |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 41 | dialog. Optionally, you can pass up to four 4-char file types to limit |
| 42 | the files the user can choose from. The function returns an FSSpec |
| 43 | object and a flag indicating that the user completed the dialog |
| 44 | without cancelling. |
| 45 | \end{funcdesc} |
| 46 | |
| 47 | \begin{funcdesc}{StandardPutFile}{prompt\, \optional{default}} |
| 48 | Present the user with a standard ``open output file'' |
| 49 | dialog. \var{prompt} is the prompt string, and the optional |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 50 | \var{default} argument initializes the output file name. The function |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 51 | returns an FSSpec object and a flag indicating that the user completed |
| 52 | the dialog without cancelling. |
| 53 | \end{funcdesc} |
| 54 | |
| 55 | \begin{funcdesc}{GetDirectory}{} |
| 56 | Present the user with a non-standard ``select a directory'' |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 57 | dialog. Return an FSSpec object and a success-indicator. |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 58 | \end{funcdesc} |
| 59 | |
| 60 | \subsection{FSSpec objects} |
| 61 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 62 | \renewcommand{\indexsubitem}{(FSSpec object attribute)} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 63 | \begin{datadesc}{data} |
| 64 | The raw data from the FSSpec object, suitable for passing |
| 65 | to other applications, for instance. |
| 66 | \end{datadesc} |
| 67 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 68 | \renewcommand{\indexsubitem}{(FSSpec object method)} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 69 | \begin{funcdesc}{as_pathname}{} |
| 70 | Return the full pathname of the file described by the FSSpec object. |
| 71 | \end{funcdesc} |
| 72 | |
| 73 | \begin{funcdesc}{as_tuple}{} |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 74 | Return the \code{(\var{wdRefNum}, \var{parID}, \var{name})} tuple of the file described |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 75 | by the FSSpec object. |
| 76 | \end{funcdesc} |
| 77 | |
| 78 | \begin{funcdesc}{NewAlias}{\optional{file}} |
| 79 | Create an Alias object pointing to the file described by this |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 80 | FSSpec. If the optional \var{file} parameter is present the alias |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 81 | will be relative to that file, otherwise it will be absolute. |
| 82 | \end{funcdesc} |
| 83 | |
| 84 | \begin{funcdesc}{NewAliasMinimal}{} |
| 85 | Create a minimal alias pointing to this file. |
| 86 | \end{funcdesc} |
| 87 | |
| 88 | \begin{funcdesc}{GetCreatorType}{} |
| 89 | Return the 4-char creator and type of the file. |
| 90 | \end{funcdesc} |
| 91 | |
| 92 | \begin{funcdesc}{SetCreatorType}{creator\, type} |
| 93 | Set the 4-char creator and type of the file. |
| 94 | \end{funcdesc} |
| 95 | |
| 96 | \subsection{alias objects} |
| 97 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 98 | \renewcommand{\indexsubitem}{(alias object attribute)} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 99 | \begin{datadesc}{data} |
| 100 | The raw data for the Alias record, suitable for storing in a resource |
| 101 | or transmitting to other programs. |
| 102 | \end{datadesc} |
| 103 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 104 | \renewcommand{\indexsubitem}{(alias object method)} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 105 | \begin{funcdesc}{Resolve}{\optional{file}} |
| 106 | Resolve the alias. If the alias was created as a relative alias you |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 107 | should pass the file relative to which it is. Return the FSSpec for |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 108 | the file pointed to and a flag indicating whether the alias object |
| 109 | itself was modified during the search process. |
| 110 | \end{funcdesc} |
| 111 | |
| 112 | \begin{funcdesc}{GetInfo}{num} |
| 113 | An interface to the C routine \code{GetAliasInfo()}. |
| 114 | \end{funcdesc} |
| 115 | |
| 116 | \begin{funcdesc}{Update}{file\, \optional{file2}} |
| 117 | Update the alias to point to the \var{file} given. If \var{file2} is |
| 118 | present a relative alias will be created. |
| 119 | \end{funcdesc} |
| 120 | |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 121 | Note that it is currently not possible to directly manipulate a resource |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 122 | as an alias object. Hence, after calling \var{Update} or after |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 123 | \var{Resolve} indicates that the alias has changed the Python program |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 124 | is responsible for getting the \var{data} from the alias object and |
| 125 | modifying the resource. |
| 126 | |
| 127 | |