4 Contains: FSSpec compatibility functions.
6 Version: Technology: MoreFiles
9 Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
11 Bugs?: For bug reports, consult the following page on
14 http://developer.apple.com/bugreporter/
19 You may incorporate this sample code into your applications without
20 restriction, though the sample code has been provided "AS IS" and the
21 responsibility for its operation is 100% yours. However, what you are
22 not permitted to do is to redistribute the source as "DSC Sample Code"
23 after having made changes. If you're going to re-distribute the source,
24 we require that you make it clear in the source that the code was
25 descended from Apple Sample Code, but that you've made changes.
39 #include "Optimization.h"
54 #if PRAGMA_STRUCT_ALIGN
55 #pragma options align=mac68k
56 #elif PRAGMA_STRUCT_PACKPUSH
58 #elif PRAGMA_STRUCT_PACK
62 /*****************************************************************************/
68 ConstStr255Param fileName
,
73 The FSMakeFSSpecCompat function fills in the fields of an FSSpec record.
74 If the file system can't create the FSSpec, then the compatibility code
75 creates a FSSpec that is exactly like an FSSpec except that spec.name
76 for a file may not have the same capitalization as the file's catalog
77 entry on the disk volume. That is because fileName is parsed to get the
78 name instead of getting the name back from the file system. This works
79 fine with System 6 where FSMakeSpec isn't available.
81 vRefNum input: Volume specification.
82 dirID input: Directory ID.
83 fileName input: Pointer to object name, or nil when dirID specifies
84 a directory that's the object.
85 spec output: A file system specification to be filled in by
90 nsvErr -35 Volume doesnÕt exist
91 fnfErr -43 File or directory does not exist
92 (FSSpec is still valid)
95 /*****************************************************************************/
105 The FSpOpenDFCompat function opens the data fork of the file specified
107 Differences from FSpOpenDF: If FSpOpenDF isn't available,
108 FSpOpenDFCompat uses PHBOpen because System 6 doesn't support PBHOpenDF.
109 This means FSpOpenDFCompat could accidentally open a driver if the
110 spec->name begins with a period.
112 spec input: An FSSpec record specifying the file whose data
113 fork is to be opened.
114 permission input: A constant indicating the desired file access
116 refNum output: A reference number of an access path to the file's
121 nsvErr -35 No such volume
123 bdNamErr -37 Bad filename
124 tmfoErr -42 Too many files open
125 fnfErr -43 File not found
126 opWrErr -49 File already open for writing
127 permErr -54 Attempt to open locked file for writing
128 dirNFErr -120 Directory not found or incomplete pathname
129 afpAccessDenied -5000 User does not have the correct access to
134 See also: FSpOpenAware
137 /*****************************************************************************/
147 The FSpOpenRFCompat function opens the resource fork of the file
150 spec input: An FSSpec record specifying the file whose resource
151 fork is to be opened.
152 permission input: A constant indicating the desired file access
154 refNum output: A reference number of an access path to the file's
159 nsvErr -35 No such volume
161 bdNamErr -37 Bad filename
162 tmfoErr -42 Too many files open
163 fnfErr -43 File not found
164 opWrErr -49 File already open for writing
165 permErr -54 Attempt to open locked file for writing
166 dirNFErr -120 Directory not found or incomplete pathname
167 afpAccessDenied -5000 User does not have the correct access to
172 See also: FSpOpenRFAware
175 /*****************************************************************************/
182 ScriptCode scriptTag
);
186 The FSpCreateCompat function creates a new file with the specified
187 type, creator, and script code.
188 Differences from FSpCreate: FSpCreateCompat correctly sets the
189 fdScript in the file's FXInfo record to scriptTag if the problem
190 isn't fixed in the File Manager code.
192 spec input: An FSSpec record specifying the file to create.
193 creator input: The creator of the new file.
194 fileType input The file type of the new file.
195 scriptCode input: The code of the script system in which the file
196 name is to be displayed.
200 dirFulErr -33 File directory full
201 dskFulErr -34 Disk is full
202 nsvErr -35 No such volume
204 bdNamErr -37 Bad filename
205 fnfErr -43 Directory not found or incomplete pathname
206 wPrErr -44 Hardware volume lock
207 vLckdErr -46 Software volume lock
208 dupFNErr -48 Duplicate filename and version
209 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
210 afpAccessDenied -5000 User does not have the correct access
211 afpObjectTypeErr -5025 A directory exists with that name
214 /*****************************************************************************/
219 ScriptCode scriptTag
,
220 long * createdDirID
);
224 The FSpDirCreateCompat function creates a new directory and returns the
225 directory ID of the newDirectory.
227 spec input: An FSSpec record specifying the directory to
229 scriptCode input: The code of the script system in which the
230 directory name is to be displayed.
231 createdDirID output: The directory ID of the directory that was
236 dirFulErr -33 File directory full
237 dskFulErr -34 Disk is full
238 nsvErr -35 No such volume
240 bdNamErr -37 Bad filename
241 fnfErr -43 Directory not found or incomplete pathname
242 wPrErr -44 Hardware volume lock
243 vLckdErr -46 Software volume lock
244 dupFNErr -48 Duplicate filename and version
245 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
246 wrgVolTypErr -123 Not an HFS volume
247 afpAccessDenied -5000 User does not have the correct access
250 /*****************************************************************************/
253 FSpDeleteCompat(const FSSpec
* spec
);
257 The FSpDeleteCompat function deletes a file or directory.
259 spec input: An FSSpec record specifying the file or
264 nsvErr -35 No such volume
266 bdNamErr -37 Bad filename
267 fnfErr -43 File not found
268 wPrErr -44 Hardware volume lock
269 fLckdErr -45 File is locked
270 vLckdErr -46 Software volume lock
271 fBsyErr -47 File busy, directory not empty, or
272 working directory control block open
273 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
274 afpAccessDenied -5000 User does not have the correct access
277 /*****************************************************************************/
286 The FSpGetFInfoCompat function gets the finder information for a file.
288 spec input: An FSSpec record specifying the file.
289 fndrInfo output: If the object is a file, then its FInfo.
293 nsvErr -35 No such volume
295 bdNamErr -37 Bad filename
296 fnfErr -43 File not found
297 paramErr -50 No default volume
298 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
299 afpAccessDenied -5000 User does not have the correct access
300 afpObjectTypeErr -5025 Directory not found or incomplete pathname
304 Also see: FSpGetDInfo
307 /*****************************************************************************/
312 const FInfo
* fndrInfo
);
316 The FSpSetFInfoCompat function sets the finder information for a file.
318 spec input: An FSSpec record specifying the file.
319 fndrInfo input: The FInfo.
323 nsvErr -35 No such volume
325 bdNamErr -37 Bad filename
326 fnfErr -43 File not found
327 wPrErr -44 Hardware volume lock
328 fLckdErr -45 File is locked
329 vLckdErr -46 Software volume lock
330 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
331 afpAccessDenied -5000 User does not have the correct access
332 afpObjectTypeErr -5025 Object was a directory
336 Also see: FSpSetDInfo
339 /*****************************************************************************/
342 FSpSetFLockCompat(const FSSpec
* spec
);
346 The FSpSetFLockCompat function locks a file.
348 spec input: An FSSpec record specifying the file.
352 nsvErr -35 No such volume
354 fnfErr -43 File not found
355 wPrErr -44 Hardware volume lock
356 vLckdErr -46 Software volume lock
357 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
358 afpAccessDenied -5000 User does not have the correct access to
360 afpObjectTypeErr -5025 Folder locking not supported by volume
363 /*****************************************************************************/
366 FSpRstFLockCompat(const FSSpec
* spec
);
370 The FSpRstFLockCompat function unlocks a file.
372 spec input: An FSSpec record specifying the file.
376 nsvErr -35 No such volume
378 fnfErr -43 File not found
379 wPrErr -44 Hardware volume lock
380 vLckdErr -46 Software volume lock
381 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
382 afpAccessDenied -5000 User does not have the correct access to
384 afpObjectTypeErr -5025 Folder locking not supported by volume
387 /*****************************************************************************/
392 ConstStr255Param newName
);
396 The FSpRenameCompat function renames a file or directory.
398 spec input: An FSSpec record specifying the file.
399 newName input: The new name of the file or directory.
403 dirFulErr -33 File directory full
404 dskFulErr -34 Volume is full
405 nsvErr -35 No such volume
407 bdNamErr -37 Bad filename
408 fnfErr -43 File not found
409 wPrErr -44 Hardware volume lock
410 fLckdErr -45 File is locked
411 vLckdErr -46 Software volume lock
412 dupFNErr -48 Duplicate filename and version
413 paramErr -50 No default volume
414 fsRnErr -59 Problem during rename
415 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
416 afpAccessDenied -5000 User does not have the correct access to
420 /*****************************************************************************/
424 const FSSpec
* source
,
425 const FSSpec
* dest
);
429 The FSpCatMoveCompat function moves a file or directory to a different
430 location on on the same volume.
432 source input: An FSSpec record specifying the file or directory.
433 dest input: An FSSpec record specifying the name and location
434 of the directory into which the source file or
435 directory is to be moved.
439 nsvErr -35 No such volume
441 bdNamErr -37 Bad filename or attempt to move into
443 fnfErr -43 File not found
444 wPrErr -44 Hardware volume lock
445 fLckdErr -45 Target directory is locked
446 vLckdErr -46 Software volume lock
447 dupFNErr -48 Duplicate filename and version
448 paramErr -50 No default volume
449 badMovErr -122 Attempt to move into offspring
450 wrgVolTypErr -123 Not an HFS volume
451 afpAccessDenied -5000 User does not have the correct access to
455 /*****************************************************************************/
458 FSpExchangeFilesCompat(
459 const FSSpec
* source
,
460 const FSSpec
* dest
);
464 The FSpExchangeFilesCompat function swaps the data in two files by
465 changing the information in the volume's catalog and, if the files
466 are open, in the file control blocks.
467 Differences from FSpExchangeFiles: Correctly exchanges files on volumes
468 that don't support PBExchangeFiles. FSpExchangeFiles attempts to support
469 volumes that don't support PBExchangeFiles, but in System 7, 7.0.1, 7.1,
470 and 7 Pro, the compatibility code just doesn't work on volumes that
471 don't support PBExchangeFiles (even though you may get a noErr result).
472 System Update 3.0 and System 7.5 and later have the problems in
473 FSpExchangeFiles corrected.
477 nsvErr -35 Volume not found
479 fnfErr -43 File not found
480 fLckdErr -45 File is locked
481 vLckdErr -46 Volume is locked or read-only
482 paramErr -50 Function not supported by volume
483 volOfflinErr -53 Volume is offline
484 wrgVolTypErr -123 Not an HFS volume
485 diffVolErr -1303 Files on different volumes
486 afpAccessDenied -5000 User does not have the correct access
487 afpObjectTypeErr -5025 Object is a directory, not a file
488 afpSameObjectErr -5038 Source and destination files are the same
491 /*****************************************************************************/
494 FSpOpenResFileCompat(
496 SignedByte permission
);
500 The FSpOpenResFileCompat function opens the resource file specified
503 spec input: An FSSpec record specifying the file whose
504 resource file is to be opened.
505 permission input: A constant indicating the desired file access
507 function result output: A resource file reference number, or if there's
512 nsvErr Ð35 No such volume
514 bdNamErr Ð37 Bad filename or volume name (perhaps zero
516 eofErr Ð39 End of file
517 tmfoErr Ð42 Too many files open
518 fnfErr Ð43 File not found
519 opWrErr Ð49 File already open with write permission
520 permErr Ð54 Permissions error (on file open)
521 extFSErr Ð58 Volume belongs to an external file system
522 memFullErr Ð108 Not enough room in heap zone
523 dirNFErr Ð120 Directory not found
524 mapReadErr Ð199 Map inconsistent with operation
527 /*****************************************************************************/
530 FSpCreateResFileCompat(
534 ScriptCode scriptTag
);
538 The FSpCreateResFileCompat function creates a new resource file with
539 the specified type, creator, and script code.
540 Differences from FSpCreateResFile: FSpCreateResFileCompat correctly
541 sets the fdScript in the file's FXInfo record to scriptTag if the
542 problem isn't fixed in the File Manager code.
544 spec input: An FSSpec record specifying the resource file to create.
545 creator input: The creator of the new file.
546 fileType input The file type of the new file.
547 scriptCode input: The code of the script system in which the file
548 name is to be displayed.
552 dirFulErr Ð33 Directory full
553 dskFulErr Ð34 Disk full
554 nsvErr Ð35 No such volume
556 bdNamErr Ð37 Bad filename or volume name (perhaps zero
558 tmfoErr Ð42 Too many files open
559 wPrErrw Ð44 Disk is write-protected
560 fLckdErr Ð45 File is locked
563 /*****************************************************************************/
565 #include "OptimizationEnd.h"
567 #if PRAGMA_STRUCT_ALIGN
568 #pragma options align=reset
569 #elif PRAGMA_STRUCT_PACKPUSH
571 #elif PRAGMA_STRUCT_PACK
575 #ifdef PRAGMA_IMPORT_OFF
585 #endif /* __FSPCOMPAT__ */