]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/morefile/MoreDesk.h
2 ** Apple Macintosh Developer Technical Support
4 ** A collection of useful high-level Desktop Manager routines.
5 ** If the Desktop Manager isn't available, use the Desktop file
6 ** for 'read' operations.
8 ** We do more because we can...
10 ** by Jim Luther and Nitin Ganatra, Apple Developer Technical Support Emeriti
12 ** File: MoreDesktopMgr.h
14 ** Copyright © 1992-1998 Apple Computer, Inc.
15 ** All rights reserved.
17 ** You may incorporate this sample code into your applications without
18 ** restriction, though the sample code has been provided "AS IS" and the
19 ** responsibility for its operation is 100% yours. However, what you are
20 ** not permitted to do is to redistribute the source as "DSC Sample Code"
21 ** after having made changes. If you're going to re-distribute the source,
22 ** we require that you make it clear in the source that the code was
23 ** descended from Apple Sample Code, but that you've made changes.
26 #ifndef __MOREDESKTOPMGR__
27 #define __MOREDESKTOPMGR__
38 /*****************************************************************************/
40 pascal OSErr
DTOpen(ConstStr255Param volName
,
43 Boolean
*newDTDatabase
);
44 /* ¦ Open a volume's desktop database and return the desktop database refNum.
45 The DTOpen function opens a volume's desktop database. It returns
46 the reference number of the desktop database and indicates if the
47 desktop database was created as a result of this call (if it was created,
50 volName input: A pointer to the name of a mounted volume
52 vRefNum input: Volume specification.
53 dtRefNum output: The reference number of Desktop Manager's
54 desktop database on the specified volume.
55 newDTDatabase output: true if the desktop database was created as a
56 result of this call and thus empty.
57 false if the desktop database was already created,
58 or if it could not be determined if it was already
63 nsvErr -35 Volume not found
65 paramErr -50 Volume doesn't support this function
66 extFSErr -58 External file system error - no file
67 system claimed this call.
68 desktopDamagedErr -1305 The desktop database has become corrupted -
69 the Finder will fix this, but if your
70 application is not running with the
71 Finder, use PBDTReset or PBDTDelete
74 /*****************************************************************************/
76 pascal OSErr
DTXGetAPPL(ConstStr255Param volName
,
79 Boolean searchCatalog
,
83 /* ¦ Find an application on a volume that can open a file with a given creator.
84 The DTXGetAPPL function finds an application (file type 'APPL') with
85 the specified creator on the specified volume. It first tries to get
86 the application mapping from the desktop database. If that fails,
87 then it tries to find an application in the Desktop file. If that
88 fails and searchCatalog is true, then it tries to find an application
89 with the specified creator using the File Manager's CatSearch routine.
91 volName input: A pointer to the name of a mounted volume
93 vRefNum input: Volume specification.
94 creator input: The file's creator type.
95 searchCatalog input: If true, search the catalog for the application
96 if it isn't found in the desktop database.
97 applVRefNum output: The volume reference number of the volume the
99 applParID output: The parent directory ID of the application.
100 applName output: The name of the application.
104 nsvErr -35 Volume not found
106 paramErr -50 No default volume
107 rfNumErr -51 Reference number invalid
108 extFSErr -58 External file system error - no file
109 system claimed this call
110 desktopDamagedErr -1305 The desktop database has become corrupted -
111 the Finder will fix this, but if your
112 application is not running with the
113 Finder, use PBDTReset or PBDTDelete
114 afpItemNotFound -5012 Information not found
118 Also see: FSpDTGetAPPL
121 /*****************************************************************************/
123 pascal OSErr
FSpDTXGetAPPL(ConstStr255Param volName
,
126 Boolean searchCatalog
,
128 /* ¦ Find an application on a volume that can open a file with a given creator.
129 The FSpDTXGetAPPL function finds an application (file type 'APPL') with
130 the specified creator on the specified volume. It first tries to get
131 the application mapping from the desktop database. If that fails,
132 then it tries to find an application in the Desktop file. If that
133 fails and searchCatalog is true, then it tries to find an application
134 with the specified creator using the File Manager's CatSearch routine.
136 volName input: A pointer to the name of a mounted volume
138 vRefNum input: Volume specification.
139 creator input: The file's creator type.
140 searchCatalog input: If true, search the catalog for the application
141 if it isn't found in the desktop database.
142 spec output: FSSpec record containing the application name and
147 nsvErr -35 Volume not found
149 paramErr -50 No default volume
150 rfNumErr -51 Reference number invalid
151 extFSErr -58 External file system error - no file
152 system claimed this call
153 desktopDamagedErr -1305 The desktop database has become corrupted -
154 the Finder will fix this, but if your
155 application is not running with the
156 Finder, use PBDTReset or PBDTDelete
157 afpItemNotFound -5012 Information not found
161 Also see: FSpDTGetAPPL
164 /*****************************************************************************/
166 pascal OSErr
DTGetAPPL(ConstStr255Param volName
,
172 /* ¦ Find an application on a volume that can open a file with a given creator.
173 The DTGetAPPL function finds an application (file type 'APPL') with
174 the specified creator on the specified volume. It first tries to get
175 the application mapping from the desktop database. If that fails,
176 then it tries to find an application in the Desktop file. If that
177 fails, then it tries to find an application with the specified creator
178 using the File Manager's CatSearch routine.
180 volName input: A pointer to the name of a mounted volume
182 vRefNum input: Volume specification.
183 creator input: The file's creator type.
184 applVRefNum output: The volume reference number of the volume the
186 applParID output: The parent directory ID of the application.
187 applName output: The name of the application.
191 nsvErr -35 Volume not found
193 paramErr -50 No default volume
194 rfNumErr -51 Reference number invalid
195 extFSErr -58 External file system error - no file
196 system claimed this call
197 desktopDamagedErr -1305 The desktop database has become corrupted -
198 the Finder will fix this, but if your
199 application is not running with the
200 Finder, use PBDTReset or PBDTDelete
201 afpItemNotFound -5012 Information not found
205 Also see: FSpDTGetAPPL
208 /*****************************************************************************/
210 pascal OSErr
FSpDTGetAPPL(ConstStr255Param volName
,
214 /* ¦ Find an application on a volume that can open a file with a given creator.
215 The FSpDTGetAPPL function finds an application (file type 'APPL') with
216 the specified creator on the specified volume. It first tries to get
217 the application mapping from the desktop database. If that fails,
218 then it tries to find an application in the Desktop file. If that
219 fails, then it tries to find an application with the specified creator
220 using the File Manager's CatSearch routine.
222 volName input: A pointer to the name of a mounted volume
224 vRefNum input: Volume specification.
225 creator input: The file's creator type.
226 spec output: FSSpec record containing the application name and
231 nsvErr -35 Volume not found
233 paramErr -50 No default volume
234 rfNumErr -51 Reference number invalid
235 extFSErr -58 External file system error - no file
236 system claimed this call
237 desktopDamagedErr -1305 The desktop database has become corrupted -
238 the Finder will fix this, but if your
239 application is not running with the
240 Finder, use PBDTReset or PBDTDelete
241 afpItemNotFound -5012 Information not found
248 /*****************************************************************************/
250 pascal OSErr
DTGetIcon(ConstStr255Param volName
,
256 /* ¦ Get an icon from the desktop database or Desktop file.
257 The DTGetIcon function retrieves the specified icon and returns it in
258 a newly created handle. The icon is retrieves from the Desktop Manager
259 or if the Desktop Manager is not available, from the Finder's Desktop
260 file. Your program is responsible for disposing of the handle when it is
263 volName input: A pointer to the name of a mounted volume
265 vRefNum input: Volume specification.
266 iconType input: The icon type as defined in Files.h. Valid values are:
273 fileCreator input: The icon's creator type.
274 fileType input: The icon's file type.
275 iconHandle output: A Handle containing the newly created icon.
279 nsvErr -35 Volume not found
281 paramErr -50 Volume doesn't support this function
282 rfNumErr -51 Reference number invalid
283 extFSErr -58 External file system error - no file
284 system claimed this call
285 memFullErr -108 iconHandle could not be allocated
286 desktopDamagedErr -1305 The desktop database has become corrupted -
287 the Finder will fix this, but if your
288 application is not running with the
289 Finder, use PBDTReset or PBDTDelete
290 afpItemNotFound -5012 Information not found
293 /*****************************************************************************/
295 pascal OSErr
DTSetComment(short vRefNum
,
297 ConstStr255Param name
,
298 ConstStr255Param comment
);
299 /* ¦ Set a file or directory's Finder comment field.
300 The DTSetComment function sets a file or directory's Finder comment
301 field. The volume must support the Desktop Manager because you only
302 have read access to the Desktop file.
304 vRefNum input: Volume specification.
305 dirID input: Directory ID.
306 name input: Pointer to object name, or nil when dirID
307 specifies a directory that's the object.
308 comment input: The comment to add. Comments are limited to 200 characters;
309 longer comments are truncated.
313 nsvErr -35 Volume not found
315 fnfErr Ð43 File or directory doesnÕt exist
316 paramErr -50 Volume doesn't support this function
317 wPrErr Ð44 Volume is locked through hardware
318 vLckdErr Ð46 Volume is locked through software
319 rfNumErr Ð51 Reference number invalid
320 extFSErr -58 External file system error - no file
321 system claimed this call.
322 desktopDamagedErr -1305 The desktop database has become corrupted -
323 the Finder will fix this, but if your
324 application is not running with the
325 Finder, use PBDTReset or PBDTDelete
329 Also see: DTCopyComment, FSpDTCopyComment, FSpDTSetComment, DTGetComment,
333 /*****************************************************************************/
335 pascal OSErr
FSpDTSetComment(const FSSpec
*spec
,
336 ConstStr255Param comment
);
337 /* ¦ Set a file or directory's Finder comment field.
338 The FSpDTSetComment function sets a file or directory's Finder comment
339 field. The volume must support the Desktop Manager because you only
340 have read access to the Desktop file.
342 spec input: An FSSpec record specifying the file or directory.
343 comment input: The comment to add. Comments are limited to 200 characters;
344 longer comments are truncated.
348 nsvErr -35 Volume not found
350 fnfErr Ð43 File or directory doesnÕt exist
351 wPrErr Ð44 Volume is locked through hardware
352 vLckdErr Ð46 Volume is locked through software
353 rfNumErr Ð51 Reference number invalid
354 paramErr -50 Volume doesn't support this function
355 extFSErr -58 External file system error - no file
356 system claimed this call.
357 desktopDamagedErr -1305 The desktop database has become corrupted -
358 the Finder will fix this, but if your
359 application is not running with the
360 Finder, use PBDTReset or PBDTDelete
364 Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, DTGetComment,
368 /*****************************************************************************/
370 pascal OSErr
DTGetComment(short vRefNum
,
372 ConstStr255Param name
,
374 /* ¦ Get a file or directory's Finder comment field (if any).
375 The DTGetComment function gets a file or directory's Finder comment
376 field (if any) from the Desktop Manager or if the Desktop Manager is
377 not available, from the Finder's Desktop file.
379 IMPORTANT NOTE: Inside Macintosh says that comments are up to
380 200 characters. While that may be correct for the HFS file system's
381 Desktop Manager, other file systems (such as Apple Photo Access) return
382 up to 255 characters. Make sure the comment buffer is a Str255 or you'll
385 vRefNum input: Volume specification.
386 dirID input: Directory ID.
387 name input: Pointer to object name, or nil when dirID
388 specifies a directory that's the object.
389 comment output: A Str255 where the comment is to be returned.
393 nsvErr -35 Volume not found
395 fnfErr -43 File not found
396 paramErr -50 Volume doesn't support this function
397 rfNumErr Ð51 Reference number invalid
398 extFSErr -58 External file system error - no file
399 system claimed this call.
400 desktopDamagedErr -1305 The desktop database has become corrupted -
401 the Finder will fix this, but if your
402 application is not running with the
403 Finder, use PBDTReset or PBDTDelete
404 afpItemNotFound -5012 Information not found
408 Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment,
412 /*****************************************************************************/
414 pascal OSErr
FSpDTGetComment(const FSSpec
*spec
,
416 /* ¦ Get a file or directory's Finder comment field (if any).
417 The FSpDTGetComment function gets a file or directory's Finder comment
418 field (if any) from the Desktop Manager or if the Desktop Manager is
419 not available, from the Finder's Desktop file.
421 IMPORTANT NOTE: Inside Macintosh says that comments are up to
422 200 characters. While that may be correct for the HFS file system's
423 Desktop Manager, other file systems (such as Apple Photo Access) return
424 up to 255 characters. Make sure the comment buffer is a Str255 or you'll
427 spec input: An FSSpec record specifying the file or directory.
428 comment output: A Str255 where the comment is to be returned.
432 nsvErr -35 Volume not found
434 fnfErr -43 File not found
435 paramErr -50 Volume doesn't support this function
436 rfNumErr Ð51 Reference number invalid
437 extFSErr -58 External file system error - no file
438 system claimed this call.
439 desktopDamagedErr -1305 The desktop database has become corrupted -
440 the Finder will fix this, but if your
441 application is not running with the
442 Finder, use PBDTReset or PBDTDelete
443 afpItemNotFound -5012 Information not found
447 Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment,
451 /*****************************************************************************/
453 pascal OSErr
DTCopyComment(short srcVRefNum
,
455 ConstStr255Param srcName
,
458 ConstStr255Param dstName
);
459 /* ¦ Copy the file or folder comment from the source to the destination object.
460 The DTCopyComment function copies the file or folder comment from the
461 source to the destination object. The destination volume must support
462 the Desktop Manager because you only have read access to the Desktop file.
464 srcVRefNum input: Source volume specification.
465 srcDirID input: Source directory ID.
466 srcName input: Pointer to source object name, or nil when srcDirID
467 specifies a directory that's the object.
468 dstVRefNum input: Destination volume specification.
469 dstDirID input: Destination directory ID.
470 dstName input: Pointer to destination object name, or nil when
471 dstDirID specifies a directory that's the object.
475 nsvErr -35 Volume not found
477 fnfErr Ð43 File or directory doesnÕt exist
478 wPrErr Ð44 Volume is locked through hardware
479 vLckdErr Ð46 Volume is locked through software
480 paramErr -50 Volume doesn't support this function
481 rfNumErr Ð51 Reference number invalid
482 paramErr -50 Volume doesn't support this function
483 extFSErr -58 External file system error - no file
484 system claimed this call.
485 desktopDamagedErr -1305 The desktop database has become corrupted -
486 the Finder will fix this, but if your
487 application is not running with the
488 Finder, use PBDTReset or PBDTDelete
489 afpItemNotFound -5012 Information not found
493 Also see: FSpDTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment,
497 /*****************************************************************************/
499 pascal OSErr
FSpDTCopyComment(const FSSpec
*srcSpec
,
500 const FSSpec
*dstSpec
);
501 /* ¦ Copy the desktop database comment from the source to the destination object.
502 The FSpDTCopyComment function copies the desktop database comment from
503 the source to the destination object. Both the source and the
504 destination volumes must support the Desktop Manager.
506 srcSpec input: An FSSpec record specifying the source object.
507 dstSpec input: An FSSpec record specifying the destination object.
511 nsvErr -35 Volume not found
513 fnfErr Ð43 File or directory doesnÕt exist
514 wPrErr Ð44 Volume is locked through hardware
515 vLckdErr Ð46 Volume is locked through software
516 paramErr -50 Volume doesn't support this function
517 rfNumErr Ð51 Reference number invalid
518 paramErr -50 Volume doesn't support this function
519 extFSErr -58 External file system error - no file
520 system claimed this call.
521 desktopDamagedErr -1305 The desktop database has become corrupted -
522 the Finder will fix this, but if your
523 application is not running with the
524 Finder, use PBDTReset or PBDTDelete
525 afpItemNotFound -5012 Information not found
529 Also see: DTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment,
533 /*****************************************************************************/
539 #include "optimend.h"
541 #endif /* __MOREDESKTOPMGR__ */