blob: be566cbe9d08e9c1ff04e5e7e984bceba0a7adb7 [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
Guido van Rossum7e42cab1996-10-15 14:37:31 +000092\begin{funcdesc}{FindApplication}{creator}
93Locate the application with 4-char creator code \var{creator}. The
94function returns an FSSpec object pointing to the application.
95\end{funcdesc}
96
Jack Jansene4be9be1995-02-28 15:46:09 +000097\subsection{FSSpec objects}
98
Guido van Rossum470be141995-03-17 16:07:09 +000099\renewcommand{\indexsubitem}{(FSSpec object attribute)}
Jack Jansene4be9be1995-02-28 15:46:09 +0000100\begin{datadesc}{data}
101The raw data from the FSSpec object, suitable for passing
102to other applications, for instance.
103\end{datadesc}
104
Guido van Rossum470be141995-03-17 16:07:09 +0000105\renewcommand{\indexsubitem}{(FSSpec object method)}
Jack Jansene4be9be1995-02-28 15:46:09 +0000106\begin{funcdesc}{as_pathname}{}
107Return the full pathname of the file described by the FSSpec object.
108\end{funcdesc}
109
110\begin{funcdesc}{as_tuple}{}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000111Return the \code{(\var{wdRefNum}, \var{parID}, \var{name})} tuple of the file described
Jack Jansene4be9be1995-02-28 15:46:09 +0000112by the FSSpec object.
113\end{funcdesc}
114
115\begin{funcdesc}{NewAlias}{\optional{file}}
116Create an Alias object pointing to the file described by this
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000117FSSpec. If the optional \var{file} parameter is present the alias
Jack Jansene4be9be1995-02-28 15:46:09 +0000118will be relative to that file, otherwise it will be absolute.
119\end{funcdesc}
120
121\begin{funcdesc}{NewAliasMinimal}{}
122Create a minimal alias pointing to this file.
123\end{funcdesc}
124
125\begin{funcdesc}{GetCreatorType}{}
126Return the 4-char creator and type of the file.
127\end{funcdesc}
128
129\begin{funcdesc}{SetCreatorType}{creator\, type}
130Set the 4-char creator and type of the file.
131\end{funcdesc}
132
Jack Jansene164bd81995-08-10 11:53:14 +0000133\begin{funcdesc}{GetFInfo}{}
134Return a FInfo object describing the finder info for the file.
135\end{funcdesc}
136
137\begin{funcdesc}{SetFInfo}{finfo}
138Set the finder info for the file to the values specified in the
139\var{finfo} object.
140\end{funcdesc}
141
Guido van Rossum7e42cab1996-10-15 14:37:31 +0000142\begin{funcdesc}{GetDates}{}
143Return a tuple with three floating point values representing the
144creation date, modification date and backup date of the file.
145\end{funcdesc}
146
147\begin{funcdesc}{SetDates}{crdate\, moddate\, backupdate}
148Set the creation, modification and backup date of the file. The values
149are in the standard floating point format used for times throughout
150Python.
151\end{funcdesc}
152
Jack Jansene4be9be1995-02-28 15:46:09 +0000153\subsection{alias objects}
154
Guido van Rossum470be141995-03-17 16:07:09 +0000155\renewcommand{\indexsubitem}{(alias object attribute)}
Jack Jansene4be9be1995-02-28 15:46:09 +0000156\begin{datadesc}{data}
157The raw data for the Alias record, suitable for storing in a resource
158or transmitting to other programs.
159\end{datadesc}
160
Guido van Rossum470be141995-03-17 16:07:09 +0000161\renewcommand{\indexsubitem}{(alias object method)}
Jack Jansene4be9be1995-02-28 15:46:09 +0000162\begin{funcdesc}{Resolve}{\optional{file}}
163Resolve the alias. If the alias was created as a relative alias you
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000164should pass the file relative to which it is. Return the FSSpec for
Jack Jansene4be9be1995-02-28 15:46:09 +0000165the file pointed to and a flag indicating whether the alias object
166itself was modified during the search process.
167\end{funcdesc}
168
169\begin{funcdesc}{GetInfo}{num}
170An interface to the C routine \code{GetAliasInfo()}.
171\end{funcdesc}
172
173\begin{funcdesc}{Update}{file\, \optional{file2}}
174Update the alias to point to the \var{file} given. If \var{file2} is
175present a relative alias will be created.
176\end{funcdesc}
177
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000178Note that it is currently not possible to directly manipulate a resource
Jack Jansene4be9be1995-02-28 15:46:09 +0000179as an alias object. Hence, after calling \var{Update} or after
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000180\var{Resolve} indicates that the alias has changed the Python program
Jack Jansene4be9be1995-02-28 15:46:09 +0000181is responsible for getting the \var{data} from the alias object and
182modifying the resource.
183
184
Jack Jansene164bd81995-08-10 11:53:14 +0000185\subsection{FInfo objects}
186
187See Inside Mac for a complete description of what the various fields
188mean.
189
190\renewcommand{\indexsubitem}{(FInfo object attribute)}
191\begin{datadesc}{Creator}
192The 4-char creator code of the file.
193\end{datadesc}
194
195\begin{datadesc}{Type}
196The 4-char type code of the file.
197\end{datadesc}
198
199\begin{datadesc}{Flags}
Jack Jansenda53c521995-10-10 14:43:20 +0000200The finder flags for the file as 16-bit integer. The bit values in
201\var{Flags} are defined in standard module \var{MACFS}.
Jack Jansene164bd81995-08-10 11:53:14 +0000202\end{datadesc}
203
204\begin{datadesc}{Location}
205A Point giving the position of the file's icon in its folder.
206\end{datadesc}
207
208\begin{datadesc}{Fldr}
209The folder the file is in (as an integer).
210\end{datadesc}