File: FSpCompat.h

package info (click to toggle)
ncbi-tools6 6.1.20120620-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 241,628 kB
  • ctags: 101,236
  • sloc: ansic: 1,431,713; cpp: 6,248; pascal: 3,949; xml: 3,390; sh: 3,090; perl: 1,077; csh: 488; makefile: 449; ruby: 93; lisp: 81
file content (586 lines) | stat: -rw-r--r-- 21,709 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
/*
     File:       FSpCompat.h
 
     Contains:   FSSpec compatibility functions.
 
     Version:    Technology: MoreFiles
                 Release:    1.5.2
 
     Copyright:   1992-2001 by Apple Computer, Inc., all rights reserved.
 
     Bugs?:      For bug reports, consult the following page on
                 the World Wide Web:
 
                     http://developer.apple.com/bugreporter/
 
*/

/*
    You may incorporate this sample code into your applications without
    restriction, though the sample code has been provided "AS IS" and the
    responsibility for its operation is 100% yours.  However, what you are
    not permitted to do is to redistribute the source as "DSC Sample Code"
    after having made changes. If you're going to re-distribute the source,
    we require that you make it clear in the source that the code was
    descended from Apple Sample Code, but that you've made changes.
*/

#ifndef __FSPCOMPAT__
#define __FSPCOMPAT__

#ifndef __MACTYPES__
#include <MacTypes.h>
#endif

#ifndef __FILES__
#include <Files.h>
#endif

#include "Optimization.h"


#if PRAGMA_ONCE
#pragma once
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if PRAGMA_IMPORT
#pragma import on
#endif

#if PRAGMA_STRUCT_ALIGN
    #pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
    #pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
    #pragma pack(2)
#endif

/*****************************************************************************/

EXTERN_API( OSErr )
FSMakeFSSpecCompat(
  short              vRefNum,
  long               dirID,
  ConstStr255Param   fileName,
  FSSpec *           spec);


/*
    The FSMakeFSSpecCompat function fills in the fields of an FSSpec record.
    If the file system can't create the FSSpec, then the compatibility code
    creates a FSSpec that is exactly like an FSSpec except that spec.name
    for a file may not have the same capitalization as the file's catalog
    entry on the disk volume. That is because fileName is parsed to get the
    name instead of getting the name back from the file system. This works
    fine with System 6 where FSMakeSpec isn't available.
    
    vRefNum     input:  Volume specification.
    dirID       input:  Directory ID.
    fileName    input:  Pointer to object name, or nil when dirID specifies
                        a directory that's the object.
    spec        output: A file system specification to be filled in by
                        FSMakeFSSpecCompat.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     Volume doesnt exist    
        fnfErr              -43     File or directory does not exist
                                    (FSSpec is still valid) 
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpOpenDFCompat(
  const FSSpec *  spec,
  char            permission,
  short *         refNum);


/*
    The FSpOpenDFCompat function opens the data fork of the file specified
    by spec.
    Differences from FSpOpenDF: If FSpOpenDF isn't available,
    FSpOpenDFCompat uses PHBOpen because System 6 doesn't support PBHOpenDF.
    This means FSpOpenDFCompat could accidentally open a driver if the
    spec->name begins with a period.
    
    spec        input:  An FSSpec record specifying the file whose data
                        fork is to be opened.
    permission  input:  A constant indicating the desired file access
                        permissions.
    refNum      output: A reference number of an access path to the file's
                        data fork.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        bdNamErr            -37     Bad filename    
        tmfoErr             -42     Too many files open 
        fnfErr              -43     File not found  
        opWrErr             -49     File already open for writing   
        permErr             -54     Attempt to open locked file for writing 
        dirNFErr            -120    Directory not found or incomplete pathname
        afpAccessDenied     -5000   User does not have the correct access to
                                    the file
    
    __________
    
    See also:   FSpOpenAware
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpOpenRFCompat(
  const FSSpec *  spec,
  char            permission,
  short *         refNum);


/*
    The FSpOpenRFCompat function opens the resource fork of the file
    specified by spec.
    
    spec        input:  An FSSpec record specifying the file whose resource
                        fork is to be opened.
    permission  input:  A constant indicating the desired file access
                        permissions.
    refNum      output: A reference number of an access path to the file's
                        resource fork.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        bdNamErr            -37     Bad filename    
        tmfoErr             -42     Too many files open 
        fnfErr              -43     File not found  
        opWrErr             -49     File already open for writing   
        permErr             -54     Attempt to open locked file for writing 
        dirNFErr            -120    Directory not found or incomplete pathname
        afpAccessDenied     -5000   User does not have the correct access to
                                    the file
    
    __________
    
    See also:   FSpOpenRFAware
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpCreateCompat(
  const FSSpec *  spec,
  OSType          creator,
  OSType          fileType,
  ScriptCode      scriptTag);


/*
    The FSpCreateCompat function creates a new file with the specified
    type, creator, and script code.
    Differences from FSpCreate: FSpCreateCompat correctly sets the
    fdScript in the file's FXInfo record to scriptTag if the problem
    isn't fixed in the File Manager code.
    
    spec        input:  An FSSpec record specifying the file to create.
    creator     input:  The creator of the new file.
    fileType    input   The file type of the new file.
    scriptCode  input:  The code of the script system in which the file
                        name is to be displayed.
    
    Result Codes
        noErr               0       No error    
        dirFulErr           -33     File directory full 
        dskFulErr           -34     Disk is full    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        bdNamErr            -37     Bad filename    
        fnfErr              -43     Directory not found or incomplete pathname  
        wPrErr              -44     Hardware volume lock    
        vLckdErr            -46     Software volume lock    
        dupFNErr            -48     Duplicate filename and version  
        dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
        afpAccessDenied     -5000   User does not have the correct access   
        afpObjectTypeErr    -5025   A directory exists with that name   
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpDirCreateCompat(
  const FSSpec *  spec,
  ScriptCode      scriptTag,
  long *          createdDirID);


/*
    The FSpDirCreateCompat function creates a new directory and returns the
    directory ID of the newDirectory.
    
    spec            input:  An FSSpec record specifying the directory to
                            create.
    scriptCode      input:  The code of the script system in which the
                            directory name is to be displayed.
    createdDirID    output: The directory ID of the directory that was
                            created.
    
    Result Codes
        noErr               0       No error    
        dirFulErr           -33     File directory full 
        dskFulErr           -34     Disk is full    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        bdNamErr            -37     Bad filename    
        fnfErr              -43     Directory not found or incomplete pathname  
        wPrErr              -44     Hardware volume lock    
        vLckdErr            -46     Software volume lock    
        dupFNErr            -48     Duplicate filename and version  
        dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
        wrgVolTypErr        -123    Not an HFS volume   
        afpAccessDenied     -5000   User does not have the correct access   
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpDeleteCompat(const FSSpec * spec);


/*
    The FSpDeleteCompat function deletes a file or directory.
    
    spec            input:  An FSSpec record specifying the file or 
                            directory to delete.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        bdNamErr            -37     Bad filename    
        fnfErr              -43     File not found  
        wPrErr              -44     Hardware volume lock    
        fLckdErr            -45     File is locked  
        vLckdErr            -46     Software volume lock    
        fBsyErr             -47     File busy, directory not empty, or
                                    working directory control block open    
        dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
        afpAccessDenied     -5000   User does not have the correct access   
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpGetFInfoCompat(
  const FSSpec *  spec,
  FInfo *         fndrInfo);


/*
    The FSpGetFInfoCompat function gets the finder information for a file.

    spec        input:  An FSSpec record specifying the file.
    fndrInfo    output: If the object is a file, then its FInfo.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        bdNamErr            -37     Bad filename    
        fnfErr              -43     File not found  
        paramErr            -50     No default volume   
        dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
        afpAccessDenied     -5000   User does not have the correct access   
        afpObjectTypeErr    -5025   Directory not found or incomplete pathname  
    
    __________
    
    Also see:   FSpGetDInfo
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpSetFInfoCompat(
  const FSSpec *  spec,
  const FInfo *   fndrInfo);


/*
    The FSpSetFInfoCompat function sets the finder information for a file.

    spec        input:  An FSSpec record specifying the file.
    fndrInfo    input:  The FInfo.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        bdNamErr            -37     Bad filename    
        fnfErr              -43     File not found  
        wPrErr              -44     Hardware volume lock    
        fLckdErr            -45     File is locked  
        vLckdErr            -46     Software volume lock    
        dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
        afpAccessDenied     -5000   User does not have the correct access   
        afpObjectTypeErr    -5025   Object was a directory  
    
    __________
    
    Also see:   FSpSetDInfo
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpSetFLockCompat(const FSSpec * spec);


/*
    The FSpSetFLockCompat function locks a file.

    spec        input:  An FSSpec record specifying the file.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        fnfErr              -43     File not found  
        wPrErr              -44     Hardware volume lock    
        vLckdErr            -46     Software volume lock    
        dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
        afpAccessDenied     -5000   User does not have the correct access to
                                    the file    
        afpObjectTypeErr    -5025   Folder locking not supported by volume  
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpRstFLockCompat(const FSSpec * spec);


/*
    The FSpRstFLockCompat function unlocks a file.

    spec        input:  An FSSpec record specifying the file.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        fnfErr              -43     File not found  
        wPrErr              -44     Hardware volume lock    
        vLckdErr            -46     Software volume lock    
        dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
        afpAccessDenied     -5000   User does not have the correct access to
                                    the file    
        afpObjectTypeErr    -5025   Folder locking not supported by volume  
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpRenameCompat(
  const FSSpec *     spec,
  ConstStr255Param   newName);


/*
    The FSpRenameCompat function renames a file or directory.

    spec        input:  An FSSpec record specifying the file.
    newName     input:  The new name of the file or directory.
    
    Result Codes
        noErr               0       No error    
        dirFulErr           -33     File directory full 
        dskFulErr           -34     Volume is full  
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        bdNamErr            -37     Bad filename    
        fnfErr              -43     File not found  
        wPrErr              -44     Hardware volume lock    
        fLckdErr            -45     File is locked  
        vLckdErr            -46     Software volume lock    
        dupFNErr            -48     Duplicate filename and version  
        paramErr            -50     No default volume   
        fsRnErr             -59     Problem during rename   
        dirNFErrdirNFErr    -120    Directory not found or incomplete pathname  
        afpAccessDenied     -5000   User does not have the correct access to
                                    the file    
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpCatMoveCompat(
  const FSSpec *  source,
  const FSSpec *  dest);


/*
    The FSpCatMoveCompat function moves a file or directory to a different
    location on on the same volume.

    source      input:  An FSSpec record specifying the file or directory.
    dest        input:  An FSSpec record specifying the name and location
                        of the directory into which the source file or
                        directory is to be moved.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     No such volume  
        ioErr               -36     I/O error   
        bdNamErr            -37     Bad filename or attempt to move into
                                    a file  
        fnfErr              -43     File not found  
        wPrErr              -44     Hardware volume lock    
        fLckdErr            -45     Target directory is locked  
        vLckdErr            -46     Software volume lock    
        dupFNErr            -48     Duplicate filename and version  
        paramErr            -50     No default volume   
        badMovErr           -122    Attempt to move into offspring  
        wrgVolTypErr        -123    Not an HFS volume   
        afpAccessDenied     -5000   User does not have the correct access to
                                    the file    
*/

/*****************************************************************************/

EXTERN_API( OSErr )
FSpExchangeFilesCompat(
  const FSSpec *  source,
  const FSSpec *  dest);


/*
    The FSpExchangeFilesCompat function swaps the data in two files by
    changing the information in the volume's catalog and, if the files
    are open, in the file control blocks.
    Differences from FSpExchangeFiles: Correctly exchanges files on volumes
    that don't support PBExchangeFiles. FSpExchangeFiles attempts to support
    volumes that don't support PBExchangeFiles, but in System 7, 7.0.1, 7.1,
    and 7 Pro, the compatibility code just doesn't work on volumes that
    don't support PBExchangeFiles (even though you may get a noErr result).
    System Update 3.0 and System 7.5 and later have the problems in
    FSpExchangeFiles corrected.
    
    Result Codes
        noErr               0       No error    
        nsvErr              -35     Volume not found    
        ioErr               -36     I/O error   
        fnfErr              -43     File not found  
        fLckdErr            -45     File is locked  
        vLckdErr            -46     Volume is locked or read-only   
        paramErr            -50     Function not supported by volume    
        volOfflinErr        -53     Volume is offline   
        wrgVolTypErr        -123    Not an HFS volume   
        diffVolErr          -1303   Files on different volumes  
        afpAccessDenied     -5000   User does not have the correct access   
        afpObjectTypeErr    -5025   Object is a directory, not a file   
        afpSameObjectErr    -5038   Source and destination files are the same   
*/

/*****************************************************************************/

EXTERN_API( short )
FSpOpenResFileCompat(
  const FSSpec *  spec,
  SignedByte      permission);


/*
    The FSpOpenResFileCompat function opens the resource file specified
    by spec.
    
    spec            input:  An FSSpec record specifying the file whose
                            resource file is to be opened.
    permission      input:  A constant indicating the desired file access
                            permissions.
    function result output: A resource file reference number, or if there's
                            an error -1.
    
    Result Codes
        noErr               0       No error
        nsvErr              35     No such volume
        ioErr               36     I/O error
        bdNamErr            37     Bad filename or volume name (perhaps zero
                                    length)
        eofErr              39     End of file
        tmfoErr             42     Too many files open
        fnfErr              43     File not found
        opWrErr             49     File already open with write permission
        permErr             54     Permissions error (on file open)
        extFSErr            58     Volume belongs to an external file system
        memFullErr          108    Not enough room in heap zone
        dirNFErr            120    Directory not found
        mapReadErr          199    Map inconsistent with operation
*/

/*****************************************************************************/

EXTERN_API( void )
FSpCreateResFileCompat(
  const FSSpec *  spec,
  OSType          creator,
  OSType          fileType,
  ScriptCode      scriptTag);


/*
    The FSpCreateResFileCompat function creates a new resource file with
    the specified type, creator, and script code.
    Differences from FSpCreateResFile: FSpCreateResFileCompat correctly
    sets the fdScript in the file's FXInfo record to scriptTag if the
    problem isn't fixed in the File Manager code.
    
    spec        input:  An FSSpec record specifying the resource file to create.
    creator     input:  The creator of the new file.
    fileType    input   The file type of the new file.
    scriptCode  input:  The code of the script system in which the file
                        name is to be displayed.
    
    Result Codes
        noErr               0       No error
        dirFulErr           33     Directory full
        dskFulErr           34     Disk full
        nsvErr              35     No such volume
        ioErr               36     I/O error
        bdNamErr            37     Bad filename or volume name (perhaps zero
                                    length)
        tmfoErr             42     Too many files open
        wPrErrw             44     Disk is write-protected
        fLckdErr            45     File is locked
*/

/*****************************************************************************/

#include "OptimizationEnd.h"

#if PRAGMA_STRUCT_ALIGN
    #pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
    #pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
    #pragma pack()
#endif

#ifdef PRAGMA_IMPORT_OFF
#pragma import off
#elif PRAGMA_IMPORT
#pragma import reset
#endif

#ifdef __cplusplus
}
#endif

#endif /* __FSPCOMPAT__ */