blob: 9df3f84d21d51eb9e11cbdf2bf781eafa5520b75 [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
51\begin{funcdesc}{StandardPutFile}{prompt\, \optional{default}}
52Present the user with a standard ``open output file''
53dialog. \var{prompt} is the prompt string, and the optional
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000054\var{default} argument initializes the output file name. The function
Jack Jansene4be9be1995-02-28 15:46:09 +000055returns an FSSpec object and a flag indicating that the user completed
56the dialog without cancelling.
57\end{funcdesc}
58
59\begin{funcdesc}{GetDirectory}{}
60Present the user with a non-standard ``select a directory''
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000061dialog. Return an FSSpec object and a success-indicator.
Jack Jansene4be9be1995-02-28 15:46:09 +000062\end{funcdesc}
63
Jack Jansene164bd81995-08-10 11:53:14 +000064\begin{funcdesc}{FindFolder}{where\, which\, create}
65Locates one of the ``special'' folders that MacOS knows about, such as
66the trash or the Preferences folder. \var{Where} is the disk to search
67(\code{0x8000} for the boot disk), \var{which} is the 4-char string
68specifying which folder to locate. Setting \var{create} causes the
69folder to be created if it does not exist. Returns a \code{(vrefnum,
70dirid)} tuple. See Inside Mac VI for a complete description, including
714-char names.
72\end{funcdesc}
73
Jack Jansene4be9be1995-02-28 15:46:09 +000074\subsection{FSSpec objects}
75
Guido van Rossum470be141995-03-17 16:07:09 +000076\renewcommand{\indexsubitem}{(FSSpec object attribute)}
Jack Jansene4be9be1995-02-28 15:46:09 +000077\begin{datadesc}{data}
78The raw data from the FSSpec object, suitable for passing
79to other applications, for instance.
80\end{datadesc}
81
Guido van Rossum470be141995-03-17 16:07:09 +000082\renewcommand{\indexsubitem}{(FSSpec object method)}
Jack Jansene4be9be1995-02-28 15:46:09 +000083\begin{funcdesc}{as_pathname}{}
84Return the full pathname of the file described by the FSSpec object.
85\end{funcdesc}
86
87\begin{funcdesc}{as_tuple}{}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000088Return the \code{(\var{wdRefNum}, \var{parID}, \var{name})} tuple of the file described
Jack Jansene4be9be1995-02-28 15:46:09 +000089by the FSSpec object.
90\end{funcdesc}
91
92\begin{funcdesc}{NewAlias}{\optional{file}}
93Create an Alias object pointing to the file described by this
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000094FSSpec. If the optional \var{file} parameter is present the alias
Jack Jansene4be9be1995-02-28 15:46:09 +000095will be relative to that file, otherwise it will be absolute.
96\end{funcdesc}
97
98\begin{funcdesc}{NewAliasMinimal}{}
99Create a minimal alias pointing to this file.
100\end{funcdesc}
101
102\begin{funcdesc}{GetCreatorType}{}
103Return the 4-char creator and type of the file.
104\end{funcdesc}
105
106\begin{funcdesc}{SetCreatorType}{creator\, type}
107Set the 4-char creator and type of the file.
108\end{funcdesc}
109
Jack Jansene164bd81995-08-10 11:53:14 +0000110\begin{funcdesc}{GetFInfo}{}
111Return a FInfo object describing the finder info for the file.
112\end{funcdesc}
113
114\begin{funcdesc}{SetFInfo}{finfo}
115Set the finder info for the file to the values specified in the
116\var{finfo} object.
117\end{funcdesc}
118
Jack Jansene4be9be1995-02-28 15:46:09 +0000119\subsection{alias objects}
120
Guido van Rossum470be141995-03-17 16:07:09 +0000121\renewcommand{\indexsubitem}{(alias object attribute)}
Jack Jansene4be9be1995-02-28 15:46:09 +0000122\begin{datadesc}{data}
123The raw data for the Alias record, suitable for storing in a resource
124or transmitting to other programs.
125\end{datadesc}
126
Guido van Rossum470be141995-03-17 16:07:09 +0000127\renewcommand{\indexsubitem}{(alias object method)}
Jack Jansene4be9be1995-02-28 15:46:09 +0000128\begin{funcdesc}{Resolve}{\optional{file}}
129Resolve the alias. If the alias was created as a relative alias you
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000130should pass the file relative to which it is. Return the FSSpec for
Jack Jansene4be9be1995-02-28 15:46:09 +0000131the file pointed to and a flag indicating whether the alias object
132itself was modified during the search process.
133\end{funcdesc}
134
135\begin{funcdesc}{GetInfo}{num}
136An interface to the C routine \code{GetAliasInfo()}.
137\end{funcdesc}
138
139\begin{funcdesc}{Update}{file\, \optional{file2}}
140Update the alias to point to the \var{file} given. If \var{file2} is
141present a relative alias will be created.
142\end{funcdesc}
143
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000144Note that it is currently not possible to directly manipulate a resource
Jack Jansene4be9be1995-02-28 15:46:09 +0000145as an alias object. Hence, after calling \var{Update} or after
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000146\var{Resolve} indicates that the alias has changed the Python program
Jack Jansene4be9be1995-02-28 15:46:09 +0000147is responsible for getting the \var{data} from the alias object and
148modifying the resource.
149
150
Jack Jansene164bd81995-08-10 11:53:14 +0000151\subsection{FInfo objects}
152
153See Inside Mac for a complete description of what the various fields
154mean.
155
156\renewcommand{\indexsubitem}{(FInfo object attribute)}
157\begin{datadesc}{Creator}
158The 4-char creator code of the file.
159\end{datadesc}
160
161\begin{datadesc}{Type}
162The 4-char type code of the file.
163\end{datadesc}
164
165\begin{datadesc}{Flags}
166The finder flags for the file as 16-bit integer.
167\end{datadesc}
168
169\begin{datadesc}{Location}
170A Point giving the position of the file's icon in its folder.
171\end{datadesc}
172
173\begin{datadesc}{Fldr}
174The folder the file is in (as an integer).
175\end{datadesc}