FSpCompat.h

Go to the documentation of this file.
00001 
00002 /*  $Id: FSpCompat.h 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /*
00005     File:       FSpCompat.h
00006     
00007     Description:FSSpec compatibility functions.
00008 
00009     Author:     JL
00010 
00011     Copyright:  Copyright: © 1992-1999 by Apple Computer, Inc.
00012                 all rights reserved.
00013     
00014     Disclaimer: You may incorporate this sample code into your applications without
00015                 restriction, though the sample code has been provided "AS IS" and the
00016                 responsibility for its operation is 100% yours.  However, what you are
00017                 not permitted to do is to redistribute the source as "DSC Sample Code"
00018                 after having made changes. If you're going to re-distribute the source,
00019                 we require that you make it clear in the source that the code was
00020                 descended from Apple Sample Code, but that you've made changes.
00021     
00022     Change History (most recent first):
00023                 6/25/99 Updated for Metrowerks Codewarror Pro 2.1(KG)
00024 
00025 */
00026 
00027 #ifndef __FSPCOMPAT__
00028 #define __FSPCOMPAT__
00029 
00030 #include <Types.h>
00031 #include <Files.h>
00032 
00033 #include "Optimization.h"
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 /*****************************************************************************/
00040 
00041 pascal  OSErr   FSMakeFSSpecCompat(short vRefNum,
00042                                    long dirID,
00043                                    ConstStr255Param fileName,
00044                                    FSSpec *spec);
00045 /*  ¶ Initialize a FSSpec record.
00046     The FSMakeFSSpecCompat function fills in the fields of an FSSpec record.
00047     If the file system can't create the FSSpec, then the compatibility code
00048     creates a FSSpec that is exactly like an FSSpec except that spec.name
00049     for a file may not have the same capitalization as the file's catalog
00050     entry on the disk volume. That is because fileName is parsed to get the
00051     name instead of getting the name back from the file system. This works
00052     fine with System 6 where FSMakeSpec isn't available.
00053     
00054     vRefNum     input:  Volume specification.
00055     dirID       input:  Directory ID.
00056     fileName    input:  Pointer to object name, or nil when dirID specifies
00057                         a directory that's the object.
00058     spec        output: A file system specification to be filled in by
00059                         FSMakeFSSpecCompat.
00060     
00061     Result Codes
00062         noErr               0       No error    
00063         nsvErr              -35     Volume doesn’t exist    
00064         fnfErr              -43     File or directory does not exist
00065                                     (FSSpec is still valid) 
00066 */
00067 
00068 /*****************************************************************************/
00069 
00070 pascal  OSErr   FSpOpenDFCompat(const FSSpec *spec,
00071                                 char permission,
00072                                 short *refNum);
00073 /*  ¶ Open a file's data fork.
00074     The FSpOpenDFCompat function opens the data fork of the file specified
00075     by spec.
00076     Differences from FSpOpenDF: If FSpOpenDF isn't available,
00077     FSpOpenDFCompat uses PHBOpen because System 6 doesn't support PBHOpenDF.
00078     This means FSpOpenDFCompat could accidentally open a driver if the
00079     spec->name begins with a period.
00080     
00081     spec        input:  An FSSpec record specifying the file whose data
00082                         fork is to be opened.
00083     permission  input:  A constant indicating the desired file access
00084                         permissions.
00085     refNum      output: A reference number of an access path to the file's
00086                         data fork.
00087     
00088     Result Codes
00089         noErr               0       No error    
00090         nsvErr              -35     No such volume  
00091         ioErr               -36     I/O error   
00092         bdNamErr            -37     Bad filename    
00093         tmfoErr             -42     Too many files open 
00094         fnfErr              -43     File not found  
00095         opWrErr             -49     File already open for writing   
00096         permErr             -54     Attempt to open locked file for writing 
00097         dirNFErr            -120    Directory not found or incomplete pathname
00098         afpAccessDenied     -5000   User does not have the correct access to
00099                                     the file
00100     
00101     __________
00102     
00103     See also:   FSpOpenAware
00104 */
00105 
00106 /*****************************************************************************/
00107 
00108 pascal  OSErr   FSpOpenRFCompat(const FSSpec *spec,
00109                                 char permission,
00110                                 short *refNum);
00111 /*  ¶ Open a file's resource fork.
00112     The FSpOpenRFCompat function opens the resource fork of the file
00113     specified by spec.
00114     
00115     spec        input:  An FSSpec record specifying the file whose resource
00116                         fork is to be opened.
00117     permission  input:  A constant indicating the desired file access
00118                         permissions.
00119     refNum      output: A reference number of an access path to the file's
00120                         resource fork.
00121     
00122     Result Codes
00123         noErr               0       No error    
00124         nsvErr              -35     No such volume  
00125         ioErr               -36     I/O error   
00126         bdNamErr            -37     Bad filename    
00127         tmfoErr             -42     Too many files open 
00128         fnfErr              -43     File not found  
00129         opWrErr             -49     File already open for writing   
00130         permErr             -54     Attempt to open locked file for writing 
00131         dirNFErr            -120    Directory not found or incomplete pathname
00132         afpAccessDenied     -5000   User does not have the correct access to
00133                                     the file
00134     
00135     __________
00136     
00137     See also:   FSpOpenRFAware
00138 */
00139 
00140 
00141 /*****************************************************************************/
00142 
00143 pascal  OSErr   FSpCreateCompat(const FSSpec *spec,
00144                                 OSType creator,
00145                                 OSType fileType,
00146                                 ScriptCode scriptTag);
00147 /*  ¶ Create a new file.
00148     The FSpCreateCompat function creates a new file with the specified
00149     type, creator, and script code.
00150     Differences from FSpCreate: FSpCreateCompat correctly sets the
00151     fdScript in the file's FXInfo record to scriptTag if the problem
00152     isn't fixed in the File Manager code.
00153     
00154     spec        input:  An FSSpec record specifying the file to create.
00155     creator     input:  The creator of the new file.
00156     fileType    input   The file type of the new file.
00157     scriptCode  input:  The code of the script system in which the file
00158                         name is to be displayed.
00159     
00160     Result Codes
00161         noErr               0       No error    
00162         dirFulErr           -33     File directory full 
00163         dskFulErr           -34     Disk is full    
00164         nsvErr              -35     No such volume  
00165         ioErr               -36     I/O error   
00166         bdNamErr            -37     Bad filename    
00167         fnfErr              -43     Directory not found or incomplete pathname  
00168         wPrErr              -44     Hardware volume lock    
00169         vLckdErr            -46     Software volume lock    
00170         dupFNErr            -48     Duplicate filename and version  
00171         dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
00172         afpAccessDenied     -5000   User does not have the correct access   
00173         afpObjectTypeErr    -5025   A directory exists with that name   
00174 */
00175 
00176 /*****************************************************************************/
00177 
00178 pascal  OSErr   FSpDirCreateCompat(const FSSpec *spec,
00179                                    ScriptCode scriptTag,
00180                                    long *createdDirID);
00181 /*  ¶ Create a new directory.
00182     The FSpDirCreateCompat function creates a new directory and returns the
00183     directory ID of the newDirectory.
00184     
00185     spec            input:  An FSSpec record specifying the directory to
00186                             create.
00187     scriptCode      input:  The code of the script system in which the
00188                             directory name is to be displayed.
00189     createdDirID    output: The directory ID of the directory that was
00190                             created.
00191     
00192     Result Codes
00193         noErr               0       No error    
00194         dirFulErr           -33     File directory full 
00195         dskFulErr           -34     Disk is full    
00196         nsvErr              -35     No such volume  
00197         ioErr               -36     I/O error   
00198         bdNamErr            -37     Bad filename    
00199         fnfErr              -43     Directory not found or incomplete pathname  
00200         wPrErr              -44     Hardware volume lock    
00201         vLckdErr            -46     Software volume lock    
00202         dupFNErr            -48     Duplicate filename and version  
00203         dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
00204         wrgVolTypErr        -123    Not an HFS volume   
00205         afpAccessDenied     -5000   User does not have the correct access   
00206 */
00207 
00208 /*****************************************************************************/
00209 
00210 pascal  OSErr   FSpDeleteCompat(const FSSpec *spec);
00211 /*  ¶ Delete a file or directory.
00212     The FSpDeleteCompat function deletes a file or directory.
00213     
00214     spec            input:  An FSSpec record specifying the file or 
00215                             directory to delete.
00216     
00217     Result Codes
00218         noErr               0       No error    
00219         nsvErr              -35     No such volume  
00220         ioErr               -36     I/O error   
00221         bdNamErr            -37     Bad filename    
00222         fnfErr              -43     File not found  
00223         wPrErr              -44     Hardware volume lock    
00224         fLckdErr            -45     File is locked  
00225         vLckdErr            -46     Software volume lock    
00226         fBsyErr             -47     File busy, directory not empty, or
00227                                     working directory control block open    
00228         dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
00229         afpAccessDenied     -5000   User does not have the correct access   
00230 */
00231 
00232 /*****************************************************************************/
00233 
00234 pascal  OSErr   FSpGetFInfoCompat(const FSSpec *spec,
00235                                   FInfo *fndrInfo);
00236 /*  ¶ Get the finder information for a file.
00237     The FSpGetFInfoCompat function gets the finder information for a file.
00238 
00239     spec        input:  An FSSpec record specifying the file.
00240     fndrInfo    output: If the object is a file, then its FInfo.
00241     
00242     Result Codes
00243         noErr               0       No error    
00244         nsvErr              -35     No such volume  
00245         ioErr               -36     I/O error   
00246         bdNamErr            -37     Bad filename    
00247         fnfErr              -43     File not found  
00248         paramErr            -50     No default volume   
00249         dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
00250         afpAccessDenied     -5000   User does not have the correct access   
00251         afpObjectTypeErr    -5025   Directory not found or incomplete pathname  
00252     
00253     __________
00254     
00255     Also see:   FSpGetDInfo
00256 */
00257 
00258 /*****************************************************************************/
00259 
00260 pascal  OSErr   FSpSetFInfoCompat(const FSSpec *spec,
00261                                   const FInfo *fndrInfo);
00262 /*  ¶ Set the finder information for a file.
00263     The FSpSetFInfoCompat function sets the finder information for a file.
00264 
00265     spec        input:  An FSSpec record specifying the file.
00266     fndrInfo    input:  The FInfo.
00267     
00268     Result Codes
00269         noErr               0       No error    
00270         nsvErr              -35     No such volume  
00271         ioErr               -36     I/O error   
00272         bdNamErr            -37     Bad filename    
00273         fnfErr              -43     File not found  
00274         wPrErr              -44     Hardware volume lock    
00275         fLckdErr            -45     File is locked  
00276         vLckdErr            -46     Software volume lock    
00277         dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
00278         afpAccessDenied     -5000   User does not have the correct access   
00279         afpObjectTypeErr    -5025   Object was a directory  
00280     
00281     __________
00282     
00283     Also see:   FSpSetDInfo
00284 */
00285 
00286 /*****************************************************************************/
00287 
00288 pascal  OSErr   FSpSetFLockCompat(const FSSpec *spec);
00289 /*  ¶ Lock a file.
00290     The FSpSetFLockCompat function locks a file.
00291 
00292     spec        input:  An FSSpec record specifying the file.
00293     
00294     Result Codes
00295         noErr               0       No error    
00296         nsvErr              -35     No such volume  
00297         ioErr               -36     I/O error   
00298         fnfErr              -43     File not found  
00299         wPrErr              -44     Hardware volume lock    
00300         vLckdErr            -46     Software volume lock    
00301         dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
00302         afpAccessDenied     -5000   User does not have the correct access to
00303                                     the file    
00304         afpObjectTypeErr    -5025   Folder locking not supported by volume  
00305 */
00306 
00307 /*****************************************************************************/
00308 
00309 pascal  OSErr   FSpRstFLockCompat(const FSSpec *spec);
00310 /*  ¶ Unlock a file.
00311     The FSpRstFLockCompat function unlocks a file.
00312 
00313     spec        input:  An FSSpec record specifying the file.
00314     
00315     Result Codes
00316         noErr               0       No error    
00317         nsvErr              -35     No such volume  
00318         ioErr               -36     I/O error   
00319         fnfErr              -43     File not found  
00320         wPrErr              -44     Hardware volume lock    
00321         vLckdErr            -46     Software volume lock    
00322         dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
00323         afpAccessDenied     -5000   User does not have the correct access to
00324                                     the file    
00325         afpObjectTypeErr    -5025   Folder locking not supported by volume  
00326 */
00327 
00328 /*****************************************************************************/
00329 
00330 pascal  OSErr   FSpRenameCompat(const FSSpec *spec,
00331                                 ConstStr255Param newName);
00332 /*  ¶ Rename a file or directory.
00333     The FSpRenameCompat function renames a file or directory.
00334 
00335     spec        input:  An FSSpec record specifying the file.
00336     newName     input:  The new name of the file or directory.
00337     
00338     Result Codes
00339         noErr               0       No error    
00340         dirFulErr           -33     File directory full 
00341         dskFulErr           -34     Volume is full  
00342         nsvErr              -35     No such volume  
00343         ioErr               -36     I/O error   
00344         bdNamErr            -37     Bad filename    
00345         fnfErr              -43     File not found  
00346         wPrErr              -44     Hardware volume lock    
00347         fLckdErr            -45     File is locked  
00348         vLckdErr            -46     Software volume lock    
00349         dupFNErr            -48     Duplicate filename and version  
00350         paramErr            -50     No default volume   
00351         fsRnErr             -59     Problem during rename   
00352         dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
00353         afpAccessDenied     -5000   User does not have the correct access to
00354                                     the file    
00355 */
00356 
00357 /*****************************************************************************/
00358 
00359 pascal  OSErr   FSpCatMoveCompat(const FSSpec *source,
00360                                  const FSSpec *dest);
00361 /*  ¶ Move a file or directory to a different location on on the same volume.
00362     The FSpCatMoveCompat function moves a file or directory to a different
00363     location on on the same volume.
00364 
00365     source      input:  An FSSpec record specifying the file or directory.
00366     dest        input:  An FSSpec record specifying the name and location
00367                         of the directory into which the source file or
00368                         directory is to be moved.
00369     
00370     Result Codes
00371         noErr               0       No error    
00372         nsvErr              -35     No such volume  
00373         ioErr               -36     I/O error   
00374         bdNamErr            -37     Bad filename or attempt to move into
00375                                     a file  
00376         fnfErr              -43     File not found  
00377         wPrErr              -44     Hardware volume lock    
00378         fLckdErr            -45     Target directory is locked  
00379         vLckdErr            -46     Software volume lock    
00380         dupFNErr            -48     Duplicate filename and version  
00381         paramErr            -50     No default volume   
00382         badMovErr           -122    Attempt to move into offspring  
00383         wrgVolTypErr        -123    Not an HFS volume   
00384         afpAccessDenied     -5000   User does not have the correct access to
00385                                     the file    
00386 */
00387 
00388 /*****************************************************************************/
00389 
00390 pascal  OSErr   FSpExchangeFilesCompat(const FSSpec *source,
00391                                        const FSSpec *dest);
00392 /*  ¶ Exchange the data stored in two files on the same volume.
00393     The FSpExchangeFilesCompat function swaps the data in two files by
00394     changing the information in the volume's catalog and, if the files
00395     are open, in the file control blocks.
00396     Differences from FSpExchangeFiles: Correctly exchanges files on volumes
00397     that don't support PBExchangeFiles. FSpExchangeFiles attempts to support
00398     volumes that don't support PBExchangeFiles, but in System 7, 7.0.1, 7.1,
00399     and 7 Pro, the compatibility code just doesn't work on volumes that
00400     don't support PBExchangeFiles (even though you may get a noErr result).
00401     System Update 3.0 and System 7.5 and later have the problems in
00402     FSpExchangeFiles corrected.
00403     
00404     Result Codes
00405         noErr               0       No error    
00406         nsvErr              -35     Volume not found    
00407         ioErr               -36     I/O error   
00408         fnfErr              -43     File not found  
00409         fLckdErr            -45     File is locked  
00410         vLckdErr            -46     Volume is locked or read-only   
00411         paramErr            -50     Function not supported by volume    
00412         volOfflinErr        -53     Volume is offline   
00413         wrgVolTypErr        -123    Not an HFS volume   
00414         diffVolErr          -1303   Files on different volumes  
00415         afpAccessDenied     -5000   User does not have the correct access   
00416         afpObjectTypeErr    -5025   Object is a directory, not a file   
00417         afpSameObjectErr    -5038   Source and destination files are the same   
00418 */
00419 
00420 /*****************************************************************************/
00421 
00422 pascal  short   FSpOpenResFileCompat(const FSSpec *spec,
00423                                      SignedByte permission);
00424 /*  ¶ Open a file's resource file.
00425     The FSpOpenResFileCompat function opens the resource file specified
00426     by spec.
00427     
00428     spec            input:  An FSSpec record specifying the file whose
00429                             resource file is to be opened.
00430     permission      input:  A constant indicating the desired file access
00431                             permissions.
00432     function result output: A resource file reference number, or if there's
00433                             an error -1.
00434     
00435     Result Codes
00436         noErr               0       No error
00437         nsvErr              –35     No such volume
00438         ioErr               –36     I/O error
00439         bdNamErr            –37     Bad filename or volume name (perhaps zero
00440                                     length)
00441         eofErr              –39     End of file
00442         tmfoErr             –42     Too many files open
00443         fnfErr              –43     File not found
00444         opWrErr             –49     File already open with write permission
00445         permErr             –54     Permissions error (on file open)
00446         extFSErr            –58     Volume belongs to an external file system
00447         memFullErr          –108    Not enough room in heap zone
00448         dirNFErr            –120    Directory not found
00449         mapReadErr          –199    Map inconsistent with operation
00450 */
00451 
00452 /*****************************************************************************/
00453 
00454 pascal  void    FSpCreateResFileCompat(const FSSpec *spec,
00455                                        OSType creator,
00456                                        OSType fileType,
00457                                        ScriptCode scriptTag);
00458 /*  ¶ Create a resource file.
00459     The FSpCreateResFileCompat function creates a new resource file with
00460     the specified type, creator, and script code.
00461     Differences from FSpCreateResFile: FSpCreateResFileCompat correctly
00462     sets the fdScript in the file's FXInfo record to scriptTag if the
00463     problem isn't fixed in the File Manager code.
00464     
00465     spec        input:  An FSSpec record specifying the resource file to create.
00466     creator     input:  The creator of the new file.
00467     fileType    input   The file type of the new file.
00468     scriptCode  input:  The code of the script system in which the file
00469                         name is to be displayed.
00470     
00471     Result Codes
00472         noErr               0       No error
00473         dirFulErr           –33     Directory full
00474         dskFulErr           –34     Disk full
00475         nsvErr              –35     No such volume
00476         ioErr               –36     I/O error
00477         bdNamErr            –37     Bad filename or volume name (perhaps zero
00478                                     length)
00479         tmfoErr             –42     Too many files open
00480         wPrErrw             –44     Disk is write-protected
00481         fLckdErr            –45     File is locked
00482 */
00483 
00484 /*****************************************************************************/
00485 
00486 #ifdef __cplusplus
00487 }
00488 #endif
00489 
00490 #include "OptimizationEnd.h"
00491 
00492 #endif  /* __FSPCOMPAT__ */
00493 

Generated on Wed May 31 18:19:47 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6