2 ** Apple Macintosh Developer Technical Support
4 ** FSSpec compatibility functions.
6 ** by Jim Luther, Apple Developer Technical Support Emeritus
10 ** Copyright © 1992-1998 Apple Computer, Inc.
11 ** All rights reserved.
13 ** You may incorporate this sample code into your applications without
14 ** restriction, though the sample code has been provided "AS IS" and the
15 ** responsibility for its operation is 100% yours. However, what you are
16 ** not permitted to do is to redistribute the source as "DSC Sample Code"
17 ** after having made changes. If you're going to re-distribute the source,
18 ** we require that you make it clear in the source that the code was
19 ** descended from Apple Sample Code, but that you've made changes.
34 /*****************************************************************************/
36 pascal OSErr
FSMakeFSSpecCompat(short vRefNum
,
38 ConstStr255Param fileName
,
40 /* ¦ Initialize a FSSpec record.
41 The FSMakeFSSpecCompat function fills in the fields of an FSSpec record.
42 If the file system can't create the FSSpec, then the compatibility code
43 creates a FSSpec that is exactly like an FSSpec except that spec.name
44 for a file may not have the same capitalization as the file's catalog
45 entry on the disk volume. That is because fileName is parsed to get the
46 name instead of getting the name back from the file system. This works
47 fine with System 6 where FSMakeSpec isn't available.
49 vRefNum input: Volume specification.
50 dirID input: Directory ID.
51 fileName input: Pointer to object name, or nil when dirID specifies
52 a directory that's the object.
53 spec output: A file system specification to be filled in by
58 nsvErr -35 Volume doesnÕt exist
59 fnfErr -43 File or directory does not exist
60 (FSSpec is still valid)
63 /*****************************************************************************/
65 pascal OSErr
FSpOpenDFCompat(const FSSpec
*spec
,
68 /* ¦ Open a file's data fork.
69 The FSpOpenDFCompat function opens the data fork of the file specified
71 Differences from FSpOpenDF: If FSpOpenDF isn't available,
72 FSpOpenDFCompat uses PHBOpen because System 6 doesn't support PBHOpenDF.
73 This means FSpOpenDFCompat could accidentally open a driver if the
74 spec->name begins with a period.
76 spec input: An FSSpec record specifying the file whose data
78 permission input: A constant indicating the desired file access
80 refNum output: A reference number of an access path to the file's
85 nsvErr -35 No such volume
87 bdNamErr -37 Bad filename
88 tmfoErr -42 Too many files open
89 fnfErr -43 File not found
90 opWrErr -49 File already open for writing
91 permErr -54 Attempt to open locked file for writing
92 dirNFErr -120 Directory not found or incomplete pathname
93 afpAccessDenied -5000 User does not have the correct access to
98 See also: FSpOpenAware
101 /*****************************************************************************/
103 pascal OSErr
FSpOpenRFCompat(const FSSpec
*spec
,
106 /* ¦ Open a file's resource fork.
107 The FSpOpenRFCompat function opens the resource fork of the file
110 spec input: An FSSpec record specifying the file whose resource
111 fork is to be opened.
112 permission input: A constant indicating the desired file access
114 refNum output: A reference number of an access path to the file's
119 nsvErr -35 No such volume
121 bdNamErr -37 Bad filename
122 tmfoErr -42 Too many files open
123 fnfErr -43 File not found
124 opWrErr -49 File already open for writing
125 permErr -54 Attempt to open locked file for writing
126 dirNFErr -120 Directory not found or incomplete pathname
127 afpAccessDenied -5000 User does not have the correct access to
132 See also: FSpOpenRFAware
136 /*****************************************************************************/
138 pascal OSErr
FSpCreateCompat(const FSSpec
*spec
,
141 ScriptCode scriptTag
);
142 /* ¦ Create a new file.
143 The FSpCreateCompat function creates a new file with the specified
144 type, creator, and script code.
145 Differences from FSpCreate: FSpCreateCompat correctly sets the
146 fdScript in the file's FXInfo record to scriptTag if the problem
147 isn't fixed in the File Manager code.
149 spec input: An FSSpec record specifying the file to create.
150 creator input: The creator of the new file.
151 fileType input The file type of the new file.
152 scriptCode input: The code of the script system in which the file
153 name is to be displayed.
157 dirFulErr -33 File directory full
158 dskFulErr -34 Disk is full
159 nsvErr -35 No such volume
161 bdNamErr -37 Bad filename
162 fnfErr -43 Directory not found or incomplete pathname
163 wPrErr -44 Hardware volume lock
164 vLckdErr -46 Software volume lock
165 dupFNErr -48 Duplicate filename and version
166 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
167 afpAccessDenied -5000 User does not have the correct access
168 afpObjectTypeErr -5025 A directory exists with that name
171 /*****************************************************************************/
173 pascal OSErr
FSpDirCreateCompat(const FSSpec
*spec
,
174 ScriptCode scriptTag
,
176 /* ¦ Create a new directory.
177 The FSpDirCreateCompat function creates a new directory and returns the
178 directory ID of the newDirectory.
180 spec input: An FSSpec record specifying the directory to
182 scriptCode input: The code of the script system in which the
183 directory name is to be displayed.
184 createdDirID output: The directory ID of the directory that was
189 dirFulErr -33 File directory full
190 dskFulErr -34 Disk is full
191 nsvErr -35 No such volume
193 bdNamErr -37 Bad filename
194 fnfErr -43 Directory not found or incomplete pathname
195 wPrErr -44 Hardware volume lock
196 vLckdErr -46 Software volume lock
197 dupFNErr -48 Duplicate filename and version
198 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
199 wrgVolTypErr -123 Not an HFS volume
200 afpAccessDenied -5000 User does not have the correct access
203 /*****************************************************************************/
205 pascal OSErr
FSpDeleteCompat(const FSSpec
*spec
);
206 /* ¦ Delete a file or directory.
207 The FSpDeleteCompat function deletes a file or directory.
209 spec input: An FSSpec record specifying the file or
214 nsvErr -35 No such volume
216 bdNamErr -37 Bad filename
217 fnfErr -43 File not found
218 wPrErr -44 Hardware volume lock
219 fLckdErr -45 File is locked
220 vLckdErr -46 Software volume lock
221 fBsyErr -47 File busy, directory not empty, or
222 working directory control block open
223 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
224 afpAccessDenied -5000 User does not have the correct access
227 /*****************************************************************************/
229 pascal OSErr
FSpGetFInfoCompat(const FSSpec
*spec
,
231 /* ¦ Get the finder information for a file.
232 The FSpGetFInfoCompat function gets the finder information for a file.
234 spec input: An FSSpec record specifying the file.
235 fndrInfo output: If the object is a file, then its FInfo.
239 nsvErr -35 No such volume
241 bdNamErr -37 Bad filename
242 fnfErr -43 File not found
243 paramErr -50 No default volume
244 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
245 afpAccessDenied -5000 User does not have the correct access
246 afpObjectTypeErr -5025 Directory not found or incomplete pathname
250 Also see: FSpGetDInfo
253 /*****************************************************************************/
255 pascal OSErr
FSpSetFInfoCompat(const FSSpec
*spec
,
256 const FInfo
*fndrInfo
);
257 /* ¦ Set the finder information for a file.
258 The FSpSetFInfoCompat function sets the finder information for a file.
260 spec input: An FSSpec record specifying the file.
261 fndrInfo input: The FInfo.
265 nsvErr -35 No such volume
267 bdNamErr -37 Bad filename
268 fnfErr -43 File not found
269 wPrErr -44 Hardware volume lock
270 fLckdErr -45 File is locked
271 vLckdErr -46 Software volume lock
272 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
273 afpAccessDenied -5000 User does not have the correct access
274 afpObjectTypeErr -5025 Object was a directory
278 Also see: FSpSetDInfo
281 /*****************************************************************************/
283 pascal OSErr
FSpSetFLockCompat(const FSSpec
*spec
);
285 The FSpSetFLockCompat function locks a file.
287 spec input: An FSSpec record specifying the file.
291 nsvErr -35 No such volume
293 fnfErr -43 File not found
294 wPrErr -44 Hardware volume lock
295 vLckdErr -46 Software volume lock
296 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
297 afpAccessDenied -5000 User does not have the correct access to
299 afpObjectTypeErr -5025 Folder locking not supported by volume
302 /*****************************************************************************/
304 pascal OSErr
FSpRstFLockCompat(const FSSpec
*spec
);
306 The FSpRstFLockCompat function unlocks a file.
308 spec input: An FSSpec record specifying the file.
312 nsvErr -35 No such volume
314 fnfErr -43 File not found
315 wPrErr -44 Hardware volume lock
316 vLckdErr -46 Software volume lock
317 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
318 afpAccessDenied -5000 User does not have the correct access to
320 afpObjectTypeErr -5025 Folder locking not supported by volume
323 /*****************************************************************************/
325 pascal OSErr
FSpRenameCompat(const FSSpec
*spec
,
326 ConstStr255Param newName
);
327 /* ¦ Rename a file or directory.
328 The FSpRenameCompat function renames a file or directory.
330 spec input: An FSSpec record specifying the file.
331 newName input: The new name of the file or directory.
335 dirFulErr -33 File directory full
336 dskFulErr -34 Volume is full
337 nsvErr -35 No such volume
339 bdNamErr -37 Bad filename
340 fnfErr -43 File not found
341 wPrErr -44 Hardware volume lock
342 fLckdErr -45 File is locked
343 vLckdErr -46 Software volume lock
344 dupFNErr -48 Duplicate filename and version
345 paramErr -50 No default volume
346 fsRnErr -59 Problem during rename
347 dirNFErrdirNFErr -120 Directory not found or incomplete pathname
348 afpAccessDenied -5000 User does not have the correct access to
352 /*****************************************************************************/
354 pascal OSErr
FSpCatMoveCompat(const FSSpec
*source
,
356 /* ¦ Move a file or directory to a different location on on the same volume.
357 The FSpCatMoveCompat function moves a file or directory to a different
358 location on on the same volume.
360 source input: An FSSpec record specifying the file or directory.
361 dest input: An FSSpec record specifying the name and location
362 of the directory into which the source file or
363 directory is to be moved.
367 nsvErr -35 No such volume
369 bdNamErr -37 Bad filename or attempt to move into
371 fnfErr -43 File not found
372 wPrErr -44 Hardware volume lock
373 fLckdErr -45 Target directory is locked
374 vLckdErr -46 Software volume lock
375 dupFNErr -48 Duplicate filename and version
376 paramErr -50 No default volume
377 badMovErr -122 Attempt to move into offspring
378 wrgVolTypErr -123 Not an HFS volume
379 afpAccessDenied -5000 User does not have the correct access to
383 /*****************************************************************************/
385 pascal OSErr
FSpExchangeFilesCompat(const FSSpec
*source
,
387 /* ¦ Exchange the data stored in two files on the same volume.
388 The FSpExchangeFilesCompat function swaps the data in two files by
389 changing the information in the volume's catalog and, if the files
390 are open, in the file control blocks.
391 Differences from FSpExchangeFiles: Correctly exchanges files on volumes
392 that don't support PBExchangeFiles. FSpExchangeFiles attempts to support
393 volumes that don't support PBExchangeFiles, but in System 7, 7.0.1, 7.1,
394 and 7 Pro, the compatibility code just doesn't work on volumes that
395 don't support PBExchangeFiles (even though you may get a noErr result).
396 System Update 3.0 and System 7.5 and later have the problems in
397 FSpExchangeFiles corrected.
401 nsvErr -35 Volume not found
403 fnfErr -43 File not found
404 fLckdErr -45 File is locked
405 vLckdErr -46 Volume is locked or read-only
406 paramErr -50 Function not supported by volume
407 volOfflinErr -53 Volume is offline
408 wrgVolTypErr -123 Not an HFS volume
409 diffVolErr -1303 Files on different volumes
410 afpAccessDenied -5000 User does not have the correct access
411 afpObjectTypeErr -5025 Object is a directory, not a file
412 afpSameObjectErr -5038 Source and destination files are the same
415 /*****************************************************************************/
417 pascal short FSpOpenResFileCompat(const FSSpec
*spec
,
418 SignedByte permission
);
419 /* ¦ Open a file's resource file.
420 The FSpOpenResFileCompat function opens the resource file specified
423 spec input: An FSSpec record specifying the file whose
424 resource file is to be opened.
425 permission input: A constant indicating the desired file access
427 function result output: A resource file reference number, or if there's
432 nsvErr Ð35 No such volume
434 bdNamErr Ð37 Bad filename or volume name (perhaps zero
436 eofErr Ð39 End of file
437 tmfoErr Ð42 Too many files open
438 fnfErr Ð43 File not found
439 opWrErr Ð49 File already open with write permission
440 permErr Ð54 Permissions error (on file open)
441 extFSErr Ð58 Volume belongs to an external file system
442 memFullErr Ð108 Not enough room in heap zone
443 dirNFErr Ð120 Directory not found
444 mapReadErr Ð199 Map inconsistent with operation
447 /*****************************************************************************/
449 pascal void FSpCreateResFileCompat(const FSSpec
*spec
,
452 ScriptCode scriptTag
);
453 /* ¦ Create a resource file.
454 The FSpCreateResFileCompat function creates a new resource file with
455 the specified type, creator, and script code.
456 Differences from FSpCreateResFile: FSpCreateResFileCompat correctly
457 sets the fdScript in the file's FXInfo record to scriptTag if the
458 problem isn't fixed in the File Manager code.
460 spec input: An FSSpec record specifying the resource file to create.
461 creator input: The creator of the new file.
462 fileType input The file type of the new file.
463 scriptCode input: The code of the script system in which the file
464 name is to be displayed.
468 dirFulErr Ð33 Directory full
469 dskFulErr Ð34 Disk full
470 nsvErr Ð35 No such volume
472 bdNamErr Ð37 Bad filename or volume name (perhaps zero
474 tmfoErr Ð42 Too many files open
475 wPrErrw Ð44 Disk is write-protected
476 fLckdErr Ð45 File is locked
479 /*****************************************************************************/
485 #include "optimend.h"
487 #endif /* __FSPCOMPAT__ */