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 | |
Jack Jansen | e164bd8 | 1995-08-10 11:53:14 +0000 | [diff] [blame] | 31 | \begin{funcdesc}{FInfo}{} |
| 32 | Create a zero-filled FInfo object. |
| 33 | \end{funcdesc} |
| 34 | |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 35 | \begin{funcdesc}{ResolveAliasFile}{file} |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 36 | Resolve an alias file. Returns a 3-tuple \code{(\var{fsspec}, \var{isfolder}, |
| 37 | \var{aliased})} where \var{fsspec} is the resulting FSSpec object, |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 38 | \var{isfolder} is true if \var{fsspec} points to a folder and |
| 39 | \var{aliased} is true if the file was an alias in the first place |
| 40 | (otherwise the FSSpec object for the file itself is returned). |
| 41 | \end{funcdesc} |
| 42 | |
| 43 | \begin{funcdesc}{StandardGetFile}{\optional{type\, ...}} |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 44 | Present the user with a standard ``open input file'' |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 45 | dialog. Optionally, you can pass up to four 4-char file types to limit |
| 46 | the files the user can choose from. The function returns an FSSpec |
| 47 | object and a flag indicating that the user completed the dialog |
| 48 | without cancelling. |
| 49 | \end{funcdesc} |
| 50 | |
Jack Jansen | 0e13374 | 1995-08-14 13:39:16 +0000 | [diff] [blame] | 51 | \begin{funcdesc}{PromptGetFile}{prompt\optional{\, type\, ...}} |
| 52 | Similar to \var{StandardGetFile} but allows you to specify a prompt. |
| 53 | \end{funcdesc} |
| 54 | |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 55 | \begin{funcdesc}{StandardPutFile}{prompt\, \optional{default}} |
| 56 | Present the user with a standard ``open output file'' |
| 57 | dialog. \var{prompt} is the prompt string, and the optional |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 58 | \var{default} argument initializes the output file name. The function |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 59 | returns an FSSpec object and a flag indicating that the user completed |
| 60 | the dialog without cancelling. |
| 61 | \end{funcdesc} |
| 62 | |
Jack Jansen | 0e13374 | 1995-08-14 13:39:16 +0000 | [diff] [blame] | 63 | \begin{funcdesc}{GetDirectory}{\optional{prompt}} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 64 | Present the user with a non-standard ``select a directory'' |
Jack Jansen | 0e13374 | 1995-08-14 13:39:16 +0000 | [diff] [blame] | 65 | dialog. \var{prompt} is the prompt string, and the optional. |
| 66 | Return an FSSpec object and a success-indicator. |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 67 | \end{funcdesc} |
| 68 | |
Guido van Rossum | 910a671 | 1996-07-30 18:22:31 +0000 | [diff] [blame] | 69 | \begin{funcdesc}{SetFolder}{\optional{fsspec}} |
| 70 | Set the folder that is initially presented to the user when one of |
| 71 | the file selection dialogs is presented. \var{Fsspec} should point to |
| 72 | a file in the folder, not the folder itself (the file need not exist, |
| 73 | though). If no argument is passed the folder will be set to the |
| 74 | current directory, i.e. what \code{os.getcwd()} returns. |
| 75 | |
| 76 | Note that starting with system 7.5 the user can change Standard File |
| 77 | behaviour with the ``general controls'' controlpanel, thereby making |
| 78 | this call inoperative. |
| 79 | \end{funcdesc} |
| 80 | |
Jack Jansen | e164bd8 | 1995-08-10 11:53:14 +0000 | [diff] [blame] | 81 | \begin{funcdesc}{FindFolder}{where\, which\, create} |
| 82 | Locates one of the ``special'' folders that MacOS knows about, such as |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 83 | the trash or the Preferences folder. \var{Where} is the disk to |
| 84 | search, \var{which} is the 4-char string specifying which folder to |
| 85 | locate. Setting \var{create} causes the folder to be created if it |
| 86 | does not exist. Returns a \code{(vrefnum, dirid)} tuple. |
| 87 | |
| 88 | The constants for \var{where} and \var{which} can be obtained from the |
| 89 | standard module \var{MACFS}. |
Jack Jansen | e164bd8 | 1995-08-10 11:53:14 +0000 | [diff] [blame] | 90 | \end{funcdesc} |
| 91 | |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 92 | \begin{funcdesc}{FindApplication}{creator} |
| 93 | Locate the application with 4-char creator code \var{creator}. The |
| 94 | function returns an FSSpec object pointing to the application. |
| 95 | \end{funcdesc} |
| 96 | |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 97 | \subsection{FSSpec objects} |
| 98 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 99 | \renewcommand{\indexsubitem}{(FSSpec object attribute)} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 100 | \begin{datadesc}{data} |
| 101 | The raw data from the FSSpec object, suitable for passing |
| 102 | to other applications, for instance. |
| 103 | \end{datadesc} |
| 104 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 105 | \renewcommand{\indexsubitem}{(FSSpec object method)} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 106 | \begin{funcdesc}{as_pathname}{} |
| 107 | Return the full pathname of the file described by the FSSpec object. |
| 108 | \end{funcdesc} |
| 109 | |
| 110 | \begin{funcdesc}{as_tuple}{} |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 111 | 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] | 112 | by the FSSpec object. |
| 113 | \end{funcdesc} |
| 114 | |
| 115 | \begin{funcdesc}{NewAlias}{\optional{file}} |
| 116 | Create an Alias object pointing to the file described by this |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 117 | FSSpec. If the optional \var{file} parameter is present the alias |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 118 | will be relative to that file, otherwise it will be absolute. |
| 119 | \end{funcdesc} |
| 120 | |
| 121 | \begin{funcdesc}{NewAliasMinimal}{} |
| 122 | Create a minimal alias pointing to this file. |
| 123 | \end{funcdesc} |
| 124 | |
| 125 | \begin{funcdesc}{GetCreatorType}{} |
| 126 | Return the 4-char creator and type of the file. |
| 127 | \end{funcdesc} |
| 128 | |
| 129 | \begin{funcdesc}{SetCreatorType}{creator\, type} |
| 130 | Set the 4-char creator and type of the file. |
| 131 | \end{funcdesc} |
| 132 | |
Jack Jansen | e164bd8 | 1995-08-10 11:53:14 +0000 | [diff] [blame] | 133 | \begin{funcdesc}{GetFInfo}{} |
| 134 | Return a FInfo object describing the finder info for the file. |
| 135 | \end{funcdesc} |
| 136 | |
| 137 | \begin{funcdesc}{SetFInfo}{finfo} |
| 138 | Set the finder info for the file to the values specified in the |
| 139 | \var{finfo} object. |
| 140 | \end{funcdesc} |
| 141 | |
Guido van Rossum | 7e42cab | 1996-10-15 14:37:31 +0000 | [diff] [blame] | 142 | \begin{funcdesc}{GetDates}{} |
| 143 | Return a tuple with three floating point values representing the |
| 144 | creation date, modification date and backup date of the file. |
| 145 | \end{funcdesc} |
| 146 | |
| 147 | \begin{funcdesc}{SetDates}{crdate\, moddate\, backupdate} |
| 148 | Set the creation, modification and backup date of the file. The values |
| 149 | are in the standard floating point format used for times throughout |
| 150 | Python. |
| 151 | \end{funcdesc} |
| 152 | |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 153 | \subsection{alias objects} |
| 154 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 155 | \renewcommand{\indexsubitem}{(alias object attribute)} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 156 | \begin{datadesc}{data} |
| 157 | The raw data for the Alias record, suitable for storing in a resource |
| 158 | or transmitting to other programs. |
| 159 | \end{datadesc} |
| 160 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 161 | \renewcommand{\indexsubitem}{(alias object method)} |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 162 | \begin{funcdesc}{Resolve}{\optional{file}} |
| 163 | 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] | 164 | 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] | 165 | the file pointed to and a flag indicating whether the alias object |
| 166 | itself was modified during the search process. |
| 167 | \end{funcdesc} |
| 168 | |
| 169 | \begin{funcdesc}{GetInfo}{num} |
| 170 | An interface to the C routine \code{GetAliasInfo()}. |
| 171 | \end{funcdesc} |
| 172 | |
| 173 | \begin{funcdesc}{Update}{file\, \optional{file2}} |
| 174 | Update the alias to point to the \var{file} given. If \var{file2} is |
| 175 | present a relative alias will be created. |
| 176 | \end{funcdesc} |
| 177 | |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 178 | Note that it is currently not possible to directly manipulate a resource |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 179 | as an alias object. Hence, after calling \var{Update} or after |
Guido van Rossum | 6bb1adc | 1995-03-13 10:03:32 +0000 | [diff] [blame] | 180 | \var{Resolve} indicates that the alias has changed the Python program |
Jack Jansen | e4be9be | 1995-02-28 15:46:09 +0000 | [diff] [blame] | 181 | is responsible for getting the \var{data} from the alias object and |
| 182 | modifying the resource. |
| 183 | |
| 184 | |
Jack Jansen | e164bd8 | 1995-08-10 11:53:14 +0000 | [diff] [blame] | 185 | \subsection{FInfo objects} |
| 186 | |
| 187 | See Inside Mac for a complete description of what the various fields |
| 188 | mean. |
| 189 | |
| 190 | \renewcommand{\indexsubitem}{(FInfo object attribute)} |
| 191 | \begin{datadesc}{Creator} |
| 192 | The 4-char creator code of the file. |
| 193 | \end{datadesc} |
| 194 | |
| 195 | \begin{datadesc}{Type} |
| 196 | The 4-char type code of the file. |
| 197 | \end{datadesc} |
| 198 | |
| 199 | \begin{datadesc}{Flags} |
Jack Jansen | da53c52 | 1995-10-10 14:43:20 +0000 | [diff] [blame] | 200 | The finder flags for the file as 16-bit integer. The bit values in |
| 201 | \var{Flags} are defined in standard module \var{MACFS}. |
Jack Jansen | e164bd8 | 1995-08-10 11:53:14 +0000 | [diff] [blame] | 202 | \end{datadesc} |
| 203 | |
| 204 | \begin{datadesc}{Location} |
| 205 | A Point giving the position of the file's icon in its folder. |
| 206 | \end{datadesc} |
| 207 | |
| 208 | \begin{datadesc}{Fldr} |
| 209 | The folder the file is in (as an integer). |
| 210 | \end{datadesc} |