blob: f4a7034f4d5aa60da07b7a4164a653dcc9790f98 [file] [log] [blame]
Guido van Rossum470be141995-03-17 16:07:09 +00001\section{Built-in Module \sectcode{macfs}}
Jack Jansene4be9be1995-02-28 15:46:09 +00002\bimodindex{macfs}
3
Guido van Rossum86751151995-02-28 17:14:32 +00004\renewcommand{\indexsubitem}{(in module macfs)}
5
Jack Jansene4be9be1995-02-28 15:46:09 +00006This module provides access to macintosh FSSpec handling, the Alias
7Manager, finder aliases and the Standard File package.
8
9Whenever a function or method expects a \var{file} argument, this
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000010argument can be one of three things:\ (1) a full or partial Macintosh
Jack Jansene4be9be1995-02-28 15:46:09 +000011pathname, (2) an FSSpec object or (3) a 3-tuple \code{(wdRefNum,
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000012parID, name)} as described in Inside Mac VI\@. A description of aliases
Jack Jansene4be9be1995-02-28 15:46:09 +000013and the standard file package can also be found there.
14
15\begin{funcdesc}{FSSpec}{file}
16Create an FSSpec object for the specified file.
17\end{funcdesc}
18
19\begin{funcdesc}{RawFSSpec}{data}
20Create an FSSpec object given the raw data for the C structure for the
Guido van Rossum470be141995-03-17 16:07:09 +000021FSSpec as a string. This is mainly useful if you have obtained an
22FSSpec structure over a network.
Jack Jansene4be9be1995-02-28 15:46:09 +000023\end{funcdesc}
24
25\begin{funcdesc}{RawAlias}{data}
Guido van Rossum470be141995-03-17 16:07:09 +000026Create an Alias object given the raw data for the C structure for the
27alias as a string. This is mainly useful if you have obtained an
28FSSpec structure over a network.
Jack Jansene4be9be1995-02-28 15:46:09 +000029\end{funcdesc}
30
Jack Jansene164bd81995-08-10 11:53:14 +000031\begin{funcdesc}{FInfo}{}
32Create a zero-filled FInfo object.
33\end{funcdesc}
34
Jack Jansene4be9be1995-02-28 15:46:09 +000035\begin{funcdesc}{ResolveAliasFile}{file}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000036Resolve an alias file. Returns a 3-tuple \code{(\var{fsspec}, \var{isfolder},
37\var{aliased})} where \var{fsspec} is the resulting FSSpec object,
Jack Jansene4be9be1995-02-28 15:46:09 +000038\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 Rossum6bb1adc1995-03-13 10:03:32 +000044Present the user with a standard ``open input file''
Jack Jansene4be9be1995-02-28 15:46:09 +000045dialog. Optionally, you can pass up to four 4-char file types to limit
46the files the user can choose from. The function returns an FSSpec
47object and a flag indicating that the user completed the dialog
48without cancelling.
49\end{funcdesc}
50
Jack Jansen0e133741995-08-14 13:39:16 +000051\begin{funcdesc}{PromptGetFile}{prompt\optional{\, type\, ...}}
52Similar to \var{StandardGetFile} but allows you to specify a prompt.
53\end{funcdesc}
54
Jack Jansene4be9be1995-02-28 15:46:09 +000055\begin{funcdesc}{StandardPutFile}{prompt\, \optional{default}}
56Present the user with a standard ``open output file''
57dialog. \var{prompt} is the prompt string, and the optional
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000058\var{default} argument initializes the output file name. The function
Jack Jansene4be9be1995-02-28 15:46:09 +000059returns an FSSpec object and a flag indicating that the user completed
60the dialog without cancelling.
61\end{funcdesc}
62
Jack Jansen0e133741995-08-14 13:39:16 +000063\begin{funcdesc}{GetDirectory}{\optional{prompt}}
Jack Jansene4be9be1995-02-28 15:46:09 +000064Present the user with a non-standard ``select a directory''
Jack Jansen0e133741995-08-14 13:39:16 +000065dialog. \var{prompt} is the prompt string, and the optional.
66Return an FSSpec object and a success-indicator.
Jack Jansene4be9be1995-02-28 15:46:09 +000067\end{funcdesc}
68
Guido van Rossum910a6711996-07-30 18:22:31 +000069\begin{funcdesc}{SetFolder}{\optional{fsspec}}
70Set the folder that is initially presented to the user when one of
71the file selection dialogs is presented. \var{Fsspec} should point to
72a file in the folder, not the folder itself (the file need not exist,
73though). If no argument is passed the folder will be set to the
74current directory, i.e. what \code{os.getcwd()} returns.
75
76Note that starting with system 7.5 the user can change Standard File
77behaviour with the ``general controls'' controlpanel, thereby making
78this call inoperative.
79\end{funcdesc}
80
Jack Jansene164bd81995-08-10 11:53:14 +000081\begin{funcdesc}{FindFolder}{where\, which\, create}
82Locates one of the ``special'' folders that MacOS knows about, such as
Jack Jansenda53c521995-10-10 14:43:20 +000083the trash or the Preferences folder. \var{Where} is the disk to
84search, \var{which} is the 4-char string specifying which folder to
85locate. Setting \var{create} causes the folder to be created if it
86does not exist. Returns a \code{(vrefnum, dirid)} tuple.
87
88The constants for \var{where} and \var{which} can be obtained from the
89standard module \var{MACFS}.
Jack Jansene164bd81995-08-10 11:53:14 +000090\end{funcdesc}
91
Jack Jansene4be9be1995-02-28 15:46:09 +000092\subsection{FSSpec objects}
93
Guido van Rossum470be141995-03-17 16:07:09 +000094\renewcommand{\indexsubitem}{(FSSpec object attribute)}
Jack Jansene4be9be1995-02-28 15:46:09 +000095\begin{datadesc}{data}
96The raw data from the FSSpec object, suitable for passing
97to other applications, for instance.
98\end{datadesc}
99
Guido van Rossum470be141995-03-17 16:07:09 +0000100\renewcommand{\indexsubitem}{(FSSpec object method)}
Jack Jansene4be9be1995-02-28 15:46:09 +0000101\begin{funcdesc}{as_pathname}{}
102Return the full pathname of the file described by the FSSpec object.
103\end{funcdesc}
104
105\begin{funcdesc}{as_tuple}{}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000106Return the \code{(\var{wdRefNum}, \var{parID}, \var{name})} tuple of the file described
Jack Jansene4be9be1995-02-28 15:46:09 +0000107by the FSSpec object.
108\end{funcdesc}
109
110\begin{funcdesc}{NewAlias}{\optional{file}}
111Create an Alias object pointing to the file described by this
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000112FSSpec. If the optional \var{file} parameter is present the alias
Jack Jansene4be9be1995-02-28 15:46:09 +0000113will be relative to that file, otherwise it will be absolute.
114\end{funcdesc}
115
116\begin{funcdesc}{NewAliasMinimal}{}
117Create a minimal alias pointing to this file.
118\end{funcdesc}
119
120\begin{funcdesc}{GetCreatorType}{}
121Return the 4-char creator and type of the file.
122\end{funcdesc}
123
124\begin{funcdesc}{SetCreatorType}{creator\, type}
125Set the 4-char creator and type of the file.
126\end{funcdesc}
127
Jack Jansene164bd81995-08-10 11:53:14 +0000128\begin{funcdesc}{GetFInfo}{}
129Return a FInfo object describing the finder info for the file.
130\end{funcdesc}
131
132\begin{funcdesc}{SetFInfo}{finfo}
133Set the finder info for the file to the values specified in the
134\var{finfo} object.
135\end{funcdesc}
136
Jack Jansene4be9be1995-02-28 15:46:09 +0000137\subsection{alias objects}
138
Guido van Rossum470be141995-03-17 16:07:09 +0000139\renewcommand{\indexsubitem}{(alias object attribute)}
Jack Jansene4be9be1995-02-28 15:46:09 +0000140\begin{datadesc}{data}
141The raw data for the Alias record, suitable for storing in a resource
142or transmitting to other programs.
143\end{datadesc}
144
Guido van Rossum470be141995-03-17 16:07:09 +0000145\renewcommand{\indexsubitem}{(alias object method)}
Jack Jansene4be9be1995-02-28 15:46:09 +0000146\begin{funcdesc}{Resolve}{\optional{file}}
147Resolve the alias. If the alias was created as a relative alias you
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000148should pass the file relative to which it is. Return the FSSpec for
Jack Jansene4be9be1995-02-28 15:46:09 +0000149the file pointed to and a flag indicating whether the alias object
150itself was modified during the search process.
151\end{funcdesc}
152
153\begin{funcdesc}{GetInfo}{num}
154An interface to the C routine \code{GetAliasInfo()}.
155\end{funcdesc}
156
157\begin{funcdesc}{Update}{file\, \optional{file2}}
158Update the alias to point to the \var{file} given. If \var{file2} is
159present a relative alias will be created.
160\end{funcdesc}
161
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000162Note that it is currently not possible to directly manipulate a resource
Jack Jansene4be9be1995-02-28 15:46:09 +0000163as an alias object. Hence, after calling \var{Update} or after
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000164\var{Resolve} indicates that the alias has changed the Python program
Jack Jansene4be9be1995-02-28 15:46:09 +0000165is responsible for getting the \var{data} from the alias object and
166modifying the resource.
167
168
Jack Jansene164bd81995-08-10 11:53:14 +0000169\subsection{FInfo objects}
170
171See Inside Mac for a complete description of what the various fields
172mean.
173
174\renewcommand{\indexsubitem}{(FInfo object attribute)}
175\begin{datadesc}{Creator}
176The 4-char creator code of the file.
177\end{datadesc}
178
179\begin{datadesc}{Type}
180The 4-char type code of the file.
181\end{datadesc}
182
183\begin{datadesc}{Flags}
Jack Jansenda53c521995-10-10 14:43:20 +0000184The finder flags for the file as 16-bit integer. The bit values in
185\var{Flags} are defined in standard module \var{MACFS}.
Jack Jansene164bd81995-08-10 11:53:14 +0000186\end{datadesc}
187
188\begin{datadesc}{Location}
189A Point giving the position of the file's icon in its folder.
190\end{datadesc}
191
192\begin{datadesc}{Fldr}
193The folder the file is in (as an integer).
194\end{datadesc}