4
Contains: A collection of useful high-level File Manager routines
5
which use the HFS Plus APIs wherever possible.
7
Version: MoreFilesX 1.0
9
Copyright: � 1992-2002 by Apple Computer, Inc., all rights reserved.
11
You may incorporate this sample code into your applications without
12
restriction, though the sample code has been provided "AS IS" and the
13
responsibility for its operation is 100% yours. However, what you are
14
not permitted to do is to redistribute the source as "DSC Sample Code"
15
after having made changes. If you're going to re-distribute the source,
16
we require that you make it clear in the source that the code was
17
descended from Apple Sample Code, but that you've made changes.
21
DRI: Apple Macintosh Developer Technical Support
23
Other Contact: For bug reports, consult the following page on
25
http://developer.apple.com/bugreporter/
27
Technology: DTS Sample Code
33
Change History (most recent first):
35
<1> 1/25/02 JL MoreFilesX 1.0
38
What do those arrows in the documentation for each routine mean?
40
--> The parameter is an input
42
<-- The parameter is an output. The pointer to the variable
43
where the output will be returned (must not be NULL).
45
<** The parameter is an optional output. If it is not a
46
NULL pointer, it points to the variable where the output
47
will be returned. If it is a NULL pointer, the output will
48
not be returned and will possibly let the routine and the
49
File Manager do less work. If you don't need an optional output,
51
**> The parameter is an optional input. If it is not a
52
NULL pointer, it points to the variable containing the
53
input data. If it is a NULL pointer, the input is not used
54
and will possibly let the routine and the File Manager
58
#ifndef __MOREFILESX__
59
#define __MOREFILESX__
73
#ifndef __TEXTCOMMON__
74
#include <TextCommon.h>
89
#if PRAGMA_STRUCT_ALIGN
90
#pragma options align=mac68k
91
#elif PRAGMA_STRUCT_PACKPUSH
93
#elif PRAGMA_STRUCT_PACK
97
/*****************************************************************************/
99
#pragma mark ----- FinderInfo and ExtendedFinderInfo -----
102
* FSGetFinderInfo and FSSetFinderInfo use these unions for Finder information.
110
typedef union FinderInfo FinderInfo;
112
union ExtendedFinderInfo
114
ExtendedFileInfo file;
115
ExtendedFolderInfo folder;
117
typedef union ExtendedFinderInfo ExtendedFinderInfo;
119
/*****************************************************************************/
121
#pragma mark ----- GetVolParmsInfoBuffer Macros -----
124
* Macros to get information out of GetVolParmsInfoBuffer.
127
/* version 1 field getters */
128
#define GetVolParmsInfoVersion(volParms) \
129
((volParms)->vMVersion)
130
#define GetVolParmsInfoAttrib(volParms) \
131
((volParms)->vMAttrib)
132
#define GetVolParmsInfoLocalHand(volParms) \
133
((volParms)->vMLocalHand)
134
#define GetVolParmsInfoServerAdr(volParms) \
135
((volParms)->vMServerAdr)
137
/* version 2 field getters (assume zero result if version < 2) */
138
#define GetVolParmsInfoVolumeGrade(volParms) \
139
(((volParms)->vMVersion >= 2) ? (volParms)->vMVolumeGrade : 0)
140
#define GetVolParmsInfoForeignPrivID(volParms) \
141
(((volParms)->vMVersion >= 2) ? (volParms)->vMForeignPrivID : 0)
143
/* version 3 field getters (assume zero result if version < 3) */
144
#define GetVolParmsInfoExtendedAttributes(volParms) \
145
(((volParms)->vMVersion >= 3) ? (volParms)->vMExtendedAttributes : 0)
147
/* attribute bits supported by all versions of GetVolParmsInfoBuffer */
148
#define VolIsNetworkVolume(volParms) \
149
((volParms)->vMServerAdr != 0)
150
#define VolHasLimitFCBs(volParms) \
151
(((volParms)->vMAttrib & (1L << bLimitFCBs)) != 0)
152
#define VolHasLocalWList(volParms) \
153
(((volParms)->vMAttrib & (1L << bLocalWList)) != 0)
154
#define VolHasNoMiniFndr(volParms) \
155
(((volParms)->vMAttrib & (1L << bNoMiniFndr)) != 0)
156
#define VolHasNoVNEdit(volParms) \
157
(((volParms)->vMAttrib & (1L << bNoVNEdit)) != 0)
158
#define VolHasNoLclSync(volParms) \
159
(((volParms)->vMAttrib & (1L << bNoLclSync)) != 0)
160
#define VolHasTrshOffLine(volParms) \
161
(((volParms)->vMAttrib & (1L << bTrshOffLine)) != 0)
162
#define VolHasNoSwitchTo(volParms) \
163
(((volParms)->vMAttrib & (1L << bNoSwitchTo)) != 0)
164
#define VolHasNoDeskItems(volParms) \
165
(((volParms)->vMAttrib & (1L << bNoDeskItems)) != 0)
166
#define VolHasNoBootBlks(volParms) \
167
(((volParms)->vMAttrib & (1L << bNoBootBlks)) != 0)
168
#define VolHasAccessCntl(volParms) \
169
(((volParms)->vMAttrib & (1L << bAccessCntl)) != 0)
170
#define VolHasNoSysDir(volParms) \
171
(((volParms)->vMAttrib & (1L << bNoSysDir)) != 0)
172
#define VolHasExtFSVol(volParms) \
173
(((volParms)->vMAttrib & (1L << bHasExtFSVol)) != 0)
174
#define VolHasOpenDeny(volParms) \
175
(((volParms)->vMAttrib & (1L << bHasOpenDeny)) != 0)
176
#define VolHasCopyFile(volParms) \
177
(((volParms)->vMAttrib & (1L << bHasCopyFile)) != 0)
178
#define VolHasMoveRename(volParms) \
179
(((volParms)->vMAttrib & (1L << bHasMoveRename)) != 0)
180
#define VolHasDesktopMgr(volParms) \
181
(((volParms)->vMAttrib & (1L << bHasDesktopMgr)) != 0)
182
#define VolHasShortName(volParms) \
183
(((volParms)->vMAttrib & (1L << bHasShortName)) != 0)
184
#define VolHasFolderLock(volParms) \
185
(((volParms)->vMAttrib & (1L << bHasFolderLock)) != 0)
186
#define VolHasPersonalAccessPrivileges(volParms) \
187
(((volParms)->vMAttrib & (1L << bHasPersonalAccessPrivileges)) != 0)
188
#define VolHasUserGroupList(volParms) \
189
(((volParms)->vMAttrib & (1L << bHasUserGroupList)) != 0)
190
#define VolHasCatSearch(volParms) \
191
(((volParms)->vMAttrib & (1L << bHasCatSearch)) != 0)
192
#define VolHasFileIDs(volParms) \
193
(((volParms)->vMAttrib & (1L << bHasFileIDs)) != 0)
194
#define VolHasBTreeMgr(volParms) \
195
(((volParms)->vMAttrib & (1L << bHasBTreeMgr)) != 0)
196
#define VolHasBlankAccessPrivileges(volParms) \
197
(((volParms)->vMAttrib & (1L << bHasBlankAccessPrivileges)) != 0)
198
#define VolSupportsAsyncRequests(volParms) \
199
(((volParms)->vMAttrib & (1L << bSupportsAsyncRequests)) != 0)
200
#define VolSupportsTrashVolumeCache(volParms) \
201
(((volParms)->vMAttrib & (1L << bSupportsTrashVolumeCache)) != 0)
203
/* attribute bits supported by version 3 and greater versions of GetVolParmsInfoBuffer */
204
#define VolIsEjectable(volParms) \
205
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bIsEjectable)) != 0)
206
#define VolSupportsHFSPlusAPIs(volParms) \
207
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsHFSPlusAPIs)) != 0)
208
#define VolSupportsFSCatalogSearch(volParms) \
209
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsFSCatalogSearch)) != 0)
210
#define VolSupportsFSExchangeObjects(volParms) \
211
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsFSExchangeObjects)) != 0)
212
#define VolSupports2TBFiles(volParms) \
213
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupports2TBFiles)) != 0)
214
#define VolSupportsLongNames(volParms) \
215
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsLongNames)) != 0)
216
#define VolSupportsMultiScriptNames(volParms) \
217
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsMultiScriptNames)) != 0)
218
#define VolSupportsNamedForks(volParms) \
219
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsNamedForks)) != 0)
220
#define VolSupportsSubtreeIterators(volParms) \
221
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsSubtreeIterators)) != 0)
222
#define VolL2PCanMapFileBlocks(volParms) \
223
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bL2PCanMapFileBlocks)) != 0)
224
#define VolParentModDateChanges(volParms) \
225
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bParentModDateChanges)) != 0)
226
#define VolAncestorModDateChanges(volParms) \
227
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bAncestorModDateChanges)) != 0)
228
#define VolSupportsSymbolicLinks(volParms) \
229
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsSymbolicLinks)) != 0)
230
#define VolIsAutoMounted(volParms) \
231
((GetVolParmsInfoExtendedAttributes(volParms) & (1L << bIsAutoMounted)) != 0)
233
/*****************************************************************************/
235
#pragma mark ----- userPrivileges Bit Masks and Macros -----
238
* Bit masks and macros to get common information out of userPrivileges byte
239
* returned by FSGetCatalogInfo.
241
* Note: The userPrivileges byte is the same as the ioACUser byte returned
242
* by PBGetCatInfo, and is the 1's complement of the user's privileges
243
* byte returned in ioACAccess by PBHGetDirAccess. That's where the
244
* ioACUser names came from.
246
* The userPrivileges are user's effective privileges based on the
247
* user ID and the groups that user belongs to, and the owner, group,
248
* and everyone privileges for the given directory.
253
/* mask for just the access restriction bits */
254
kioACUserAccessMask = (kioACUserNoSeeFolderMask +
255
kioACUserNoSeeFilesMask +
256
kioACUserNoMakeChangesMask),
257
/* common access privilege settings */
258
kioACUserFull = 0x00, /* no access restiction bits on */
259
kioACUserNone = kioACUserAccessMask, /* all access restiction bits on */
260
kioACUserDropBox = (kioACUserNoSeeFolderMask +
261
kioACUserNoSeeFilesMask), /* make changes, but not see files or folders */
262
kioACUserBulletinBoard = kioACUserNoMakeChangesMask /* see files and folders, but not make changes */
266
/* Macros for testing ioACUser bits. */
268
#define UserIsOwner(userPrivileges) \
269
(((userPrivileges) & kioACUserNotOwnerMask) == 0)
270
#define UserHasFullAccess(userPrivileges) \
271
(((userPrivileges) & (kioACUserAccessMask)) == kioACUserFull)
272
#define UserHasDropBoxAccess(userPrivileges) \
273
(((userPrivileges) & kioACUserAccessMask) == kioACUserDropBox)
274
#define UserHasBulletinBoard(userPrivileges) \
275
(((userPrivileges) & kioACUserAccessMask) == kioACUserBulletinBoard)
276
#define UserHasNoAccess(userPrivileges) \
277
(((userPrivileges) & kioACUserAccessMask) == kioACUserNone)
279
/*****************************************************************************/
281
#pragma mark ----- File Access Routines -----
283
/*****************************************************************************/
285
#pragma mark FSCopyFork
292
ByteCount copyBufferSize);
295
The FSCopyFork function copies all data from the source fork to the
296
destination fork of open file forks and makes sure the destination EOF
297
is equal to the source EOF.
299
srcRefNum --> The source file reference number.
300
dstRefNum --> The destination file reference number.
301
copyBufferPtr --> Pointer to buffer to use during copy. The
302
buffer should be at least 4K-bytes minimum.
303
The larger the buffer, the faster the copy
305
copyBufferSize --> The size of the copy buffer.
308
/*****************************************************************************/
310
#pragma mark ----- Volume Access Routines -----
312
/*****************************************************************************/
314
#pragma mark FSGetVolParms
318
FSVolumeRefNum volRefNum,
320
GetVolParmsInfoBuffer *volParmsInfo,
321
UInt32 *actualInfoSize);
324
The FSGetVolParms function returns information about the characteristics
325
of a volume. A result of paramErr usually just means the volume doesn't
326
support GetVolParms and the feature you were going to check
329
volRefNum --> Volume specification.
330
bufferSize --> Size of buffer pointed to by volParmsInfo.
331
volParmsInfo <-- A GetVolParmsInfoBuffer record where the volume
332
attributes information is returned.
333
actualInfoSize <-- The number of bytes actually returned
338
Also see: The GetVolParmsInfoBuffer Macros for checking attribute bits
342
/*****************************************************************************/
344
#pragma mark FSGetVRefNum
349
FSVolumeRefNum *vRefNum);
352
The FSGetVRefNum function determines the volume reference
353
number of a volume from a FSRef.
356
vRefNum <-- The volume reference number.
359
/*****************************************************************************/
361
#pragma mark FSGetVInfo
365
FSVolumeRefNum volume,
366
HFSUniStr255 *volumeName, /* can be NULL */
367
UInt64 *freeBytes, /* can be NULL */
368
UInt64 *totalBytes); /* can be NULL */
371
The FSGetVInfo function returns the name, available space (in bytes),
372
and total space (in bytes) for the specified volume.
374
volume --> The volume reference number.
375
volumeName <** An optional pointer to a HFSUniStr255.
376
If not NULL, the volume name will be returned in
378
freeBytes <** An optional pointer to a UInt64.
379
If not NULL, the number of free bytes on the
380
volume will be returned in the UInt64.
381
totalBytes <** An optional pointer to a UInt64.
382
If not NULL, the total number of bytes on the
383
volume will be returned in the UInt64.
386
/*****************************************************************************/
388
#pragma mark FSGetVolFileSystemID
391
FSGetVolFileSystemID(
392
FSVolumeRefNum volume,
393
UInt16 *fileSystemID, /* can be NULL */
394
UInt16 *signature); /* can be NULL */
397
The FSGetVolFileSystemID function returns the file system ID and signature
398
of a mounted volume. The file system ID identifies the file system
399
that handles requests to a particular volume. The signature identifies the
400
volume type of the volume (for example, FSID 0 is Macintosh HFS Plus, HFS
401
or MFS, where a signature of 0x4244 identifies the volume as HFS).
402
Here's a partial list of file system ID numbers (only Apple's file systems
405
----- -----------------------------------------------------
406
$0000 Macintosh HFS Plus, HFS or MFS
407
$0100 ProDOS File System
408
$0101 PowerTalk Mail Enclosures
409
$4147 ISO 9660 File Access (through Foreign File Access)
410
$4242 High Sierra File Access (through Foreign File Access)
411
$464D QuickTake File System (through Foreign File Access)
412
$4953 Macintosh PC Exchange (MS-DOS)
413
$4A48 Audio CD Access (through Foreign File Access)
414
$4D4B Apple Photo Access (through Foreign File Access)
415
$6173 AppleShare (later versions of AppleShare only)
417
See the Technical Note "FL 35 - Determining Which File System
418
Is Active" and the "Guide to the File System Manager" for more
421
volume --> The volume reference number.
422
fileSystemID <** An optional pointer to a UInt16.
423
If not NULL, the volume's file system ID will
424
be returned in the UInt16.
425
signature <** An optional pointer to a UInt16.
426
If not NULL, the volume's signature will
427
be returned in the UInt16.
430
/*****************************************************************************/
432
#pragma mark FSGetMountedVolumes
436
FSRef ***volumeRefsHandle, /* pointer to handle of FSRefs */
437
ItemCount *numVolumes);
440
The FSGetMountedVolumes function returns the list of volumes currently
441
mounted in an array of FSRef records. The array of FSRef records is
442
returned in a Handle, volumeRefsHandle, which is allocated by
443
FSGetMountedVolumes. The caller is responsible for disposing of
444
volumeRefsHandle if the FSGetMountedVolumes returns noErr.
446
volumeRefsHandle <-- Pointer to an FSRef Handle where the array of
447
FSRefs is to be returned.
448
numVolumes <-- The number of volumes returned in the array.
451
/*****************************************************************************/
453
#pragma mark ----- FSRef/FSpec/Path/Name Conversion Routines -----
455
/*****************************************************************************/
457
#pragma mark FSRefMakeFSSpec
465
The FSRefMakeFSSpec function returns an FSSpec for the file or
466
directory specified by the ref parameter.
468
ref --> An FSRef specifying the file or directory.
472
/*****************************************************************************/
474
#pragma mark FSMakeFSRef
478
FSVolumeRefNum volRefNum,
480
ConstStr255Param name,
484
The FSMakeFSRef function creates an FSRef from the traditional
485
volume reference number, directory ID and pathname inputs. It is
486
functionally equivalent to FSMakeFSSpec followed by FSpMakeFSRef.
488
volRefNum --> Volume specification.
489
dirID --> Directory specification.
490
name --> The file or directory name, or NULL.
494
/*****************************************************************************/
496
#pragma mark FSMakePath
502
ConstStr255Param name,
507
The FSMakePath function creates a pathname from the traditional volume reference
508
number, directory ID, and pathname inputs. It is functionally equivalent to
509
FSMakeFSSpec, FSpMakeFSRef, FSRefMakePath.
511
volRefNum --> Volume specification.
512
dirID --> Directory specification.
513
name --> The file or directory name, or NULL.
514
path <-- A pointer to a buffer which FSMakePath will
515
fill with a C string representing the pathname
516
to the file or directory specified. The format of
517
the pathname returned can be determined with the
518
Gestalt selector gestaltFSAttr's
519
gestaltFSUsesPOSIXPathsForConversion bit.
520
If the gestaltFSUsesPOSIXPathsForConversion bit is
521
clear, the pathname is a Mac OS File Manager full
522
pathname in a C string, and file or directory names
523
in the pathname may be mangled as returned by
524
the File Manager. If the
525
gestaltFSUsesPOSIXPathsForConversion bit is set,
526
the pathname is a UTF8 encoded POSIX absolute
527
pathname in a C string. In either case, the
528
pathname returned can be passed back to
529
FSPathMakeRef to create an FSRef to the file or
530
directory, or FSPathMakeFSSpec to craete an FSSpec
531
to the file or directory.
532
maxPathSize --> The size of the path buffer in bytes. If the path
533
buffer is too small for the pathname string,
534
FSMakePath returns pathTooLongErr or
538
/*****************************************************************************/
540
#pragma mark FSPathMakeFSSpec
546
Boolean *isDirectory); /* can be NULL */
549
The FSPathMakeFSSpec function converts a pathname to an FSSpec.
551
path --> A pointer to a C String that is the pathname. The
552
format of the pathname you must supply can be
553
determined with the Gestalt selector gestaltFSAttr's
554
gestaltFSUsesPOSIXPathsForConversion bit.
555
If the gestaltFSUsesPOSIXPathsForConversion bit is
556
clear, the pathname must be a Mac OS File Manager
557
full pathname in a C string. If the
558
gestaltFSUsesPOSIXPathsForConversion bit is set,
559
the pathname must be a UTF8 encoded POSIX absolute
560
pathname in a C string.
562
isDirectory <** An optional pointer to a Boolean.
563
If not NULL, true will be returned in the Boolean
564
if the specified path is a directory, or false will
565
be returned in the Boolean if the specified path is
569
/*****************************************************************************/
571
#pragma mark UnicodeNameGetHFSName
574
UnicodeNameGetHFSName(
575
UniCharCount nameLength,
577
TextEncoding textEncodingHint,
578
Boolean isVolumeName,
582
The UnicodeNameGetHFSName function converts a Unicode string
583
to a Pascal Str31 (or Str27) string using an algorithm similar to that used
584
by the File Manager. Note that if the name is too long or cannot be converted
585
using the given text encoding hint, you will get an error instead of the
586
mangled name that the File Manager would return.
588
nameLength --> Number of UniChar in name parameter.
589
name --> The Unicode string to convert.
590
textEncodingHint --> The text encoding hint used for the conversion.
591
You can pass kTextEncodingUnknown to use the
592
"default" textEncodingHint.
593
isVolumeName --> If true, the output name will be limited to
594
27 characters (kHFSMaxVolumeNameChars). If false,
595
the output name will be limited to 31 characters
596
(kHFSMaxFileNameChars).
597
hfsName <-- The hfsName as a Pascal string.
601
Also see: HFSNameGetUnicodeName
604
/*****************************************************************************/
606
#pragma mark HFSNameGetUnicodeName
609
HFSNameGetUnicodeName(
610
ConstStr31Param hfsName,
611
TextEncoding textEncodingHint,
612
HFSUniStr255 *unicodeName);
615
The HFSNameGetUnicodeName function converts a Pascal Str31 string to an
616
Unicode HFSUniStr255 string using the same routines as the File Manager.
618
hfsName --> The Pascal string to convert.
619
textEncodingHint --> The text encoding hint used for the conversion.
620
You can pass kTextEncodingUnknown to use the
621
"default" textEncodingHint.
622
unicodeName <-- The Unicode string.
626
Also see: UnicodeNameGetHFSName
629
/*****************************************************************************/
631
#pragma mark ----- File/Directory Manipulation Routines -----
633
/*****************************************************************************/
635
#pragma mark FSRefValid
637
Boolean FSRefValid(const FSRef *ref);
640
The FSRefValid function determines if an FSRef is valid. If the result is
641
true, then the FSRef refers to an existing file or directory.
643
ref --> FSRef to a file or directory.
646
/*****************************************************************************/
648
#pragma mark FSGetParentRef
656
The FSGetParentRef function gets the parent directory FSRef of the
659
Note: FSRefs always point to real file system objects. So, there cannot
660
be a FSRef to the parent of volume root directories. If you call
661
FSGetParentRef with a ref to the root directory of a volume, the
662
function result will be noErr and the parentRef will be invalid (using it
663
for other file system requests will fail).
665
ref --> FSRef to a file or directory.
666
parentRef <-- The parent directory's FSRef.
669
/*****************************************************************************/
671
#pragma mark FSGetFileDirName
676
HFSUniStr255 *outName);
679
The FSGetFileDirName function gets the name of the file or directory
682
ref --> FSRef to a file or directory.
683
outName <-- The file or directory name.
686
/*****************************************************************************/
688
#pragma mark FSGetNodeID
693
long *nodeID, /* can be NULL */
694
Boolean *isDirectory); /* can be NULL */
697
The GetNodeIDFromFSRef function gets the node ID number of the
698
file or directory specified (note: the node ID is the directory ID
701
ref --> FSRef to a file or directory.
702
nodeID <** An optional pointer to a long.
703
If not NULL, the node ID will be returned in
705
isDirectory <** An optional pointer to a Boolean.
706
If not NULL, true will be returned in the Boolean
707
if the object is a directory, or false will be
708
returned in the Boolean if object is a file.
711
/*****************************************************************************/
713
#pragma mark FSGetUserPrivilegesPermissions
716
FSGetUserPrivilegesPermissions(
718
UInt8 *userPrivileges, /* can be NULL */
719
UInt32 permissions[4]); /* can be NULL */
722
The FSGetUserPrivilegesPermissions function gets the userPrivileges and/or
723
permissions of the file or directory specified.
725
ref --> FSRef to a file or directory.
726
userPrivileges <** An optional pointer to a UInt8.
727
If not NULL, the userPrivileges will be returned
729
permissions <** An optional pointer to an UInt32[4] array.
730
If not NULL, the permissions will be returned
731
in the UInt32[4] array.
734
/*****************************************************************************/
736
#pragma mark FSCheckLock
743
The FSCheckLock function determines if a file or directory is locked.
744
If FSCheckLock returns noErr, then the file or directory is not locked
745
and the volume it is on is not locked either. If FSCheckLock returns
746
fLckdErr, then the file or directory is locked. If FSCheckLock returns
747
wPrErr, then the volume is locked by hardware (i.e., locked tab on
748
removable media). If FSCheckLock returns vLckdErr, then the volume is
751
ref --> FSRef to a file or directory.
754
/*****************************************************************************/
756
#pragma mark FSGetForkSizes
761
UInt64 *dataLogicalSize, /* can be NULL */
762
UInt64 *rsrcLogicalSize); /* can be NULL */
765
The FSGetForkSizes returns the size of the data and/or resource fork for
768
ref --> FSRef to a file or directory.
769
dataLogicalSize <** An optional pointer to a UInt64.
770
If not NULL, the data fork's size will be
771
returned in the UInt64.
772
rsrcLogicalSize <** An optional pointer to a UInt64.
773
If not NULL, the resource fork's size will be
774
returned in the UInt64.
778
Also see: FSGetTotalForkSizes
781
/*****************************************************************************/
783
#pragma mark FSGetTotalForkSizes
788
UInt64 *totalLogicalSize, /* can be NULL */
789
UInt64 *totalPhysicalSize, /* can be NULL */
790
ItemCount *forkCount); /* can be NULL */
793
The FSGetTotalForkSizes returns the total logical size and/or the total
794
physical size of the specified file (i.e., it adds the sizes of all file
795
forks). It optionally returns the number of file forks.
797
ref --> FSRef to a file or directory.
798
totalLogicalSize <** An optional pointer to a UInt64.
799
If not NULL, the sum of all fork logical sizes
800
will be returned in the UInt64.
801
totalPhysicalSize <** An optional pointer to a UInt64.
802
If not NULL, the sum of all fork physical sizes
803
will be returned in the UInt64.
804
forkCount <** An optional pointer to a ItemCount.
805
If not NULL, the number of file forks
806
will be returned in the ItemCount.
810
Also see: FSGetForkSizes
813
/*****************************************************************************/
815
#pragma mark FSBumpDate
822
The FSBumpDate function changes the content modification date of a file
823
or directory to the current date/time. If the content modification date
824
is already equal to the current date/time, then add one second to the
825
content modification date.
827
ref --> FSRef to a file or directory.
830
/*****************************************************************************/
832
#pragma mark FSGetFinderInfo
837
FinderInfo *info, /* can be NULL */
838
ExtendedFinderInfo *extendedInfo, /* can be NULL */
839
Boolean *isDirectory); /* can be NULL */
842
The FSGetFinderInfo function gets the finder information for a file or
845
ref --> FSRef to a file or directory.
846
info <** An optional pointer to a FinderInfo.
847
If not NULL, the FileInfo (if ref is a file) or
848
the FolderInfo (if ref is a folder) will be
849
returned in the FinderInfo.
850
extendedInfo <** An optional pointer to a ExtendedFinderInfo.
851
If not NULL, the ExtendedFileInfo (if ref is a file)
852
or the ExtendedFolderInfo (if ref is a folder) will
853
be returned in the ExtendedFinderInfo.
854
isDirectory <** An optional pointer to a Boolean.
855
If not NULL, true will be returned in the Boolean
856
if the object is a directory, or false will be
857
returned in the Boolean if object is a file.
861
Also see: FSSetFinderInfo
864
/*****************************************************************************/
866
#pragma mark FSSetFinderInfo
871
const FinderInfo *info, /* can be NULL */
872
const ExtendedFinderInfo *extendedInfo); /* can be NULL */
875
The FSSetFinderInfo function sets the finder information for a file or
878
ref --> FSRef to a file or directory.
879
info **> A pointer to a FinderInfo record with the new
880
FileInfo (if ref is a file) or new FolderInfo
881
(if ref is a folder), or NULL if the FinderInfo
882
is not to be changed.
883
extendedInfo **> A pointer to a FinderInfo record with the new
884
ExtendedFileInfo (if ref is a file) or new
885
ExtendedFolderInfo (if ref is a folder), or NULL
886
if the ExtendedFinderInfo is not to be changed.
890
Also see: FSGetFinderInfo
893
/*****************************************************************************/
895
#pragma mark FSChangeCreatorType
904
The FSChangeCreatorType function changes the creator and/or file type of a file.
906
ref --> FSRef to a file.
907
creator --> The new creator type or 0x00000000 to leave
908
the creator type alone.
909
fileType --> The new file type or 0x00000000 to leave the
913
/*****************************************************************************/
915
#pragma mark FSChangeFinderFlags
924
The FSChangeFinderFlags function sets or clears flag bits in
925
the finderFlags field of a file's FileInfo record or a
926
directory's FolderInfo record.
928
ref --> FSRef to a file or directory.
929
setBits --> If true, then set the bits specified in flagBits.
930
If false, then clear the bits specified in flagBits.
931
flagBits --> The flagBits parameter specifies which Finder Flag
932
bits to set or clear. If a bit in flagBits is set,
933
then the same bit in fdFlags is either set or
934
cleared depending on the state of the setBits
938
/*****************************************************************************/
940
#pragma mark FSSetInvisible
946
#pragma mark FSClearInvisible
953
The FSSetInvisible and FSClearInvisible functions set or clear the
954
kIsInvisible bit in the finderFlags field of the specified file or
955
directory's finder information.
957
ref --> FSRef to a file or directory.
960
/*****************************************************************************/
962
#pragma mark FSSetNameLocked
968
#pragma mark FSClearNameLocked
975
The FSSetNameLocked and FSClearNameLocked functions set or clear the
976
kNameLocked bit bit in the finderFlags field of the specified file or
977
directory's finder information.
979
ref --> FSRef to a file or directory.
982
/*****************************************************************************/
984
#pragma mark FSSetIsStationery
990
#pragma mark FSClearIsStationery
997
The FSSetIsStationery and FSClearIsStationery functions set or clear the
998
kIsStationery bit bit in the finderFlags field of the specified file or
999
directory's finder information.
1001
ref --> FSRef to a file or directory.
1004
/*****************************************************************************/
1006
#pragma mark FSSetHasCustomIcon
1012
#pragma mark FSClearHasCustomIcon
1015
FSClearHasCustomIcon(
1019
The FSSetHasCustomIcon and FSClearHasCustomIcon functions set or clear the
1020
kHasCustomIcon bit bit in the finderFlags field of the specified file or
1021
directory's finder information.
1023
ref --> FSRef to a file or directory.
1026
/*****************************************************************************/
1028
#pragma mark FSClearHasBeenInited
1031
FSClearHasBeenInited(
1035
The FSClearHasBeenInited function clears the kHasBeenInited bit in the
1036
finderFlags field of the specified file or directory's finder information.
1038
Note: There is no FSSetHasBeenInited function because ONLY the Finder
1039
should set the kHasBeenInited bit.
1041
ref --> FSRef to a file or directory.
1044
/*****************************************************************************/
1046
#pragma mark FSCopyFileMgrAttributes
1049
FSCopyFileMgrAttributes(
1050
const FSRef *sourceRef,
1051
const FSRef *destinationRef,
1052
Boolean copyLockBit);
1055
The CopyFileMgrAttributes function copies all File Manager attributes
1056
from the source file or directory to the destination file or directory.
1057
If copyLockBit is true, then set the locked state of the destination
1058
to match the source.
1060
sourceRef --> FSRef to a file or directory.
1061
destinationRef --> FSRef to a file or directory.
1062
copyLockBit --> If true, set the locked state of the destination
1063
to match the source.
1066
/*****************************************************************************/
1068
#pragma mark FSMoveRenameObjectUnicode
1071
FSMoveRenameObjectUnicode(
1073
const FSRef *destDirectory,
1074
UniCharCount nameLength,
1075
const UniChar *name, /* can be NULL (no rename during move) */
1076
TextEncoding textEncodingHint,
1077
FSRef *newRef); /* if function fails along the way, newRef is final location of file */
1080
The FSMoveRenameObjectUnicode function moves a file or directory and
1081
optionally renames it. The source and destination locations must be on
1084
Note: If the input ref parameter is invalid, this call will fail and
1085
newRef, like ref, will be invalid.
1087
ref --> FSRef to a file or directory.
1088
destDirectory --> FSRef to the destination directory.
1089
nameLength --> Number of UniChar in name parameter.
1090
name --> An Unicode string with the new name for the
1091
moved object, or NULL if no rename is wanted.
1092
textEncodingHint --> The text encoding hint used for the rename.
1093
You can pass kTextEncodingUnknown to use the
1094
"default" textEncodingHint.
1095
newRef <-- The new FSRef of the object moved. Note that if
1096
this function fails at any step along the way,
1097
newRef is still then final location of the object.
1100
/*****************************************************************************/
1102
#pragma mark FSDeleteContainerContents
1105
FSDeleteContainerContents(
1106
const FSRef *container);
1109
The FSDeleteContainerContents function deletes the contents of a container
1110
directory. All files and subdirectories in the specified container are
1111
deleted. If a locked file or directory is encountered, it is unlocked and
1112
then deleted. If any unexpected errors are encountered,
1113
FSDeleteContainerContents quits and returns to the caller.
1115
container --> FSRef to a directory.
1119
Also see: FSDeleteContainer
1122
/*****************************************************************************/
1124
#pragma mark FSDeleteContainer
1128
const FSRef *container);
1131
The FSDeleteContainer function deletes a container directory and its contents.
1132
All files and subdirectories in the specified container are deleted.
1133
If a locked file or directory is encountered, it is unlocked and then
1134
deleted. After deleting the container's contents, the container is
1135
deleted. If any unexpected errors are encountered, FSDeleteContainer
1136
quits and returns to the caller.
1138
container --> FSRef to a directory.
1142
Also see: FSDeleteContainerContents
1145
/*****************************************************************************/
1147
#pragma mark IterateContainerFilterProcPtr
1149
typedef CALLBACK_API( Boolean , IterateContainerFilterProcPtr ) (
1150
Boolean containerChanged,
1151
ItemCount currentLevel,
1152
const FSCatalogInfo *catalogInfo,
1155
const HFSUniStr255 *name,
1159
This is the prototype for the IterateContainerFilterProc function which
1160
is called once for each file and directory found by FSIterateContainer.
1161
The IterateContainerFilterProc can use the read-only data it receives for
1164
The result of the IterateContainerFilterProc function indicates if
1165
iteration should be stopped. To stop iteration, return true; to continue
1166
iteration, return false.
1168
The yourDataPtr parameter can point to whatever data structure you might
1169
want to access from within the IterateContainerFilterProc.
1171
containerChanged --> Set to true if the container's contents changed
1173
currentLevel --> The current recursion level into the container.
1174
1 = the container, 2 = the container's immediate
1175
subdirectories, etc.
1176
catalogInfo --> The catalog information for the current object.
1177
Only the fields requested by the whichInfo
1178
parameter passed to FSIterateContainer are valid.
1179
ref --> The FSRef to the current object.
1180
spec --> The FSSpec to the current object if the wantFSSpec
1181
parameter passed to FSIterateContainer is true.
1182
name --> The name of the current object if the wantName
1183
parameter passed to FSIterateContainer is true.
1184
yourDataPtr --> An optional pointer to whatever data structure you
1185
might want to access from within the
1187
result <-- To stop iteration, return true; to continue
1188
iteration, return false.
1192
Also see: FSIterateContainer
1195
/*****************************************************************************/
1197
#pragma mark CallIterateContainerFilterProc
1199
#define CallIterateContainerFilterProc(userRoutine, containerChanged, currentLevel, catalogInfo, ref, spec, name, yourDataPtr) \
1200
(*(userRoutine))((containerChanged), (currentLevel), (catalogInfo), (ref), (spec), (name), (yourDataPtr))
1202
/*****************************************************************************/
1204
#pragma mark FSIterateContainer
1208
const FSRef *container,
1209
ItemCount maxLevels,
1210
FSCatalogInfoBitmap whichInfo,
1213
IterateContainerFilterProcPtr iterateFilter,
1217
The FSIterateContainer function performs a recursive iteration (scan) of the
1218
specified container directory and calls your IterateContainerFilterProc
1219
function once for each file and directory found.
1221
The maxLevels parameter lets you control how deep the recursion goes.
1222
If maxLevels is 1, FSIterateContainer only scans the specified directory;
1223
if maxLevels is 2, FSIterateContainer scans the specified directory and
1224
one subdirectory below the specified directory; etc. Set maxLevels to
1225
zero to scan all levels.
1227
The yourDataPtr parameter can point to whatever data structure you might
1228
want to access from within your IterateContainerFilterProc.
1230
container --> The FSRef to the container directory to iterate.
1231
maxLevels --> Maximum number of directory levels to scan or
1232
zero to scan all directory levels.
1233
whichInfo --> The fields of the FSCatalogInfo you wish to get.
1234
wantFSSpec --> Set to true if you want the FSSpec to each
1235
object passed to your IterateContainerFilterProc.
1236
wantName --> Set to true if you want the name of each
1237
object passed to your IterateContainerFilterProc.
1238
iterateFilter --> A pointer to the IterateContainerFilterProc you
1239
want called once for each file and directory found
1240
by FSIterateContainer.
1241
yourDataPtr --> An optional pointer to whatever data structure you
1242
might want to access from within the
1246
/*****************************************************************************/
1248
#pragma mark FSGetDirectoryItems
1251
FSGetDirectoryItems(
1252
const FSRef *container,
1253
FSRef ***refsHandle, /* pointer to handle of FSRefs */
1255
Boolean *containerChanged);
1258
The FSGetDirectoryItems function returns the list of items in the specified
1259
container. The array of FSRef records is returned in a Handle, refsHandle,
1260
which is allocated by FSGetDirectoryItems. The caller is responsible for
1261
disposing of refsHandle if the FSGetDirectoryItems returns noErr.
1263
container --> FSRef to a directory.
1264
refsHandle <-- Pointer to an FSRef Handle where the array of
1265
FSRefs is to be returned.
1266
numRefs <-- The number of FSRefs returned in the array.
1267
containerChanged <-- Set to true if the container changes while the
1268
list of items is being obtained.
1271
/*****************************************************************************/
1273
#pragma mark FSExchangeObjectsCompat
1276
FSExchangeObjectsCompat(
1277
const FSRef *sourceRef,
1278
const FSRef *destRef,
1279
FSRef *newSourceRef,
1283
The FSExchangeObjectsCompat function exchanges the data between two files.
1285
The FSExchangeObjectsCompat function is an enhanced version of
1286
FSExchangeObjects function. The two enhancements FSExchangeObjectsCompat
1289
1, FSExchangeObjectsCompat will work on volumes which do not support
1290
FSExchangeObjects. FSExchangeObjectsCompat does this by emulating
1291
FSExchangeObjects through a series of File Manager operations. If
1292
there is a failure at any step along the way, FSExchangeObjectsCompat
1293
attempts to undo any steps already taken to leave the files in their
1294
original state in their original locations.
1296
2. FSExchangeObjectsCompat returns new FSRefs to the source and
1297
destination files. Note that if this function fails at any step along
1298
the way, newSourceRef and newDestRef still give you access to the final
1299
locations of the files being exchanged -- even if they are renamed or
1300
not in their original locations.
1302
sourceRef --> FSRef to the source file.
1303
destRef --> FSRef to the destination file.
1304
newSourceRef <-- The new FSRef to the source file.
1305
newDestRef <-- The new FSRef to the destination file.
1308
/*****************************************************************************/
1310
#pragma mark ----- Shared Environment Routines -----
1312
/*****************************************************************************/
1314
#pragma mark FSLockRange
1323
The LockRange function locks (denies access to) a portion of a file
1324
that was opened with shared read/write permission.
1326
refNum --> The file reference number of an open file.
1327
rangeLength --> The number of bytes in the range.
1328
rangeStart --> The starting byte in the range to lock.
1332
Also see: UnlockRange
1335
/*****************************************************************************/
1337
#pragma mark FSUnlockRange
1346
The UnlockRange function unlocks (allows access to) a previously locked
1347
portion of a file that was opened with shared read/write permission.
1349
refNum --> The file reference number of an open file.
1350
rangeLength --> The number of bytes in the range.
1351
rangeStart --> The starting byte in the range to unlock.
1358
/*****************************************************************************/
1360
#pragma mark FSGetDirAccess
1365
SInt32 *ownerID, /* can be NULL */
1366
SInt32 *groupID, /* can be NULL */
1367
SInt32 *accessRights); /* can be NULL */
1370
The FSGetDirAccess function retrieves the directory access control
1371
information for a directory on a shared volume.
1373
ref --> An FSRef specifying the directory.
1374
ownerID <** An optional pointer to a SInt32.
1375
If not NULL, the directory's owner ID
1376
will be returned in the SInt32.
1377
groupID <** An optional pointer to a SInt32.
1378
If not NULL, the directory's group ID, or 0
1379
if no group affiliation, will be returned in
1381
accessRights <** An optional pointer to a SInt32.
1382
If not NULL, the directory's access rights
1383
will be returned in the SInt32.
1387
Also see: FSSetDirAccess, FSMapID, FSMapName
1390
/*****************************************************************************/
1392
#pragma mark FSSetDirAccess
1399
SInt32 accessRights);
1402
The FSpSetDirAccess function changes the directory access control
1403
information for a directory on a shared volume. You must be the owner of
1404
a directory to change its access control information.
1406
ref --> An FSRef specifying the directory.
1407
ownerID --> The directory's owner ID.
1408
groupID --> The directory's group ID or 0 if no group affiliation.
1409
accessRights --> The directory's access rights.
1413
Also see: FSGetDirAccess, FSMapID, FSMapName
1416
/*****************************************************************************/
1418
#pragma mark FSGetVolMountInfoSize
1421
FSGetVolMountInfoSize(
1422
FSVolumeRefNum volRefNum,
1426
The FSGetVolMountInfoSize function determines the how much space the
1427
program needs to allocate for a volume mounting information record.
1429
volRefNum --> Volume specification.
1430
size <-- The space needed (in bytes) of the volume
1431
mounting information record.
1435
Also see: FSGetVolMountInfo, VolumeMount
1438
/*****************************************************************************/
1440
#pragma mark FSGetVolMountInfo
1444
FSVolumeRefNum volRefNum,
1445
void *volMountInfo);
1448
The FSGetVolMountInfo function retrieves a volume mounting information
1449
record containing all the information needed to mount the volume,
1450
except for passwords.
1452
volRefNum --> Volume specification.
1453
volMountInfo <-- The volume mounting information.
1457
Also see: FSGetVolMountInfoSize, VolumeMount
1460
/*****************************************************************************/
1462
#pragma mark FSVolumeMount
1466
const void *volMountInfo,
1467
FSVolumeRefNum *volRefNum);
1470
The VolumeMount function mounts a volume using a volume mounting
1473
volMountInfo --> A volume mounting information record.
1474
volRefNum <-- The volume reference number.
1478
Also see: FSGetVolMountInfoSize, FSGetVolMountInfo
1481
/*****************************************************************************/
1483
#pragma mark FSMapID
1487
FSVolumeRefNum volRefNum,
1493
The FSMapID function determines the name of a user or group if you know
1494
the user or group ID.
1496
volRefNum --> Volume specification.
1497
objType --> The mapping function code:
1498
kOwnerID2Name to map a user ID to a user name
1499
kGroupID2Name to map a group ID to a group name
1500
name <** An optional pointer to a buffer (minimum Str31).
1501
If not NULL, the user or group name
1502
will be returned in the buffer.
1506
Also see: FSGetDirAccess, FSSetDirAccess, FSMapName
1509
/*****************************************************************************/
1511
#pragma mark FSMapName
1515
FSVolumeRefNum volRefNum,
1516
ConstStr255Param name,
1521
The FSMapName function determines the user or group ID if you know the
1524
volRefNum --> Volume specification.
1525
name --> The user or group name.
1526
objType --> The mapping function code:
1527
kOwnerName2ID to map a user name to a user ID
1528
kGroupName2ID to map a user name to a group ID
1529
ugID <-- The user or group ID.
1533
Also see: FSGetDirAccess, FSSetDirAccess, FSMapID
1536
/*****************************************************************************/
1538
#pragma mark FSCopyFile
1542
const FSRef *srcFileRef,
1543
const FSRef *dstDirectoryRef,
1544
UniCharCount nameLength,
1545
const UniChar *copyName, /* can be NULL (no rename during copy) */
1546
TextEncoding textEncodingHint,
1547
FSRef *newRef); /* can be NULL */
1550
The FSCopyFile function duplicates a file and optionally renames it.
1551
The source and destination volumes must be on the same file server.
1552
This function instructs the server to copy the file.
1554
srcFileRef --> An FSRef specifying the source file.
1555
dstDirectoryRef --> An FSRef specifying the destination directory.
1556
nameLength --> Number of UniChar in copyName parameter (ignored
1557
if copyName is NULL).
1558
copyName --> Points to the new file name if the file is to be
1559
renamed, or NULL if the file isn't to be renamed.
1560
textEncodingHint --> The text encoding hint used for the rename.
1561
You can pass kTextEncodingUnknown to use the
1562
"default" textEncodingHint.
1563
newRef <** An optional pointer to a FSRef.
1564
If not NULL, the FSRef of the duplicated file
1565
will be returned in the FSRef.
1568
/*****************************************************************************/
1570
#pragma mark FSMoveRename
1574
const FSRef *srcFileRef,
1575
const FSRef *dstDirectoryRef,
1576
UniCharCount nameLength,
1577
const UniChar *moveName, /* can be NULL (no rename during move) */
1578
TextEncoding textEncodingHint,
1579
FSRef *newRef); /* can be NULL */
1582
The FSMoveRename function moves a file or directory (object), and
1583
optionally renames it. The source and destination locations must be on
1584
the same shared volume.
1586
srcFileRef --> An FSRef specifying the source file.
1587
dstDirectoryRef --> An FSRef specifying the destination directory.
1588
nameLength --> Number of UniChar in moveName parameter (ignored
1589
if copyName is NULL)
1590
moveName --> Points to the new object name if the object is to be
1591
renamed, or NULL if the object isn't to be renamed.
1592
textEncodingHint --> The text encoding hint used for the rename.
1593
You can pass kTextEncodingUnknown to use the
1594
"default" textEncodingHint.
1595
newRef <** An optional pointer to a FSRef.
1596
If not NULL, the FSRef of the moved object
1597
will be returned in the FSRef.
1600
/*****************************************************************************/
1602
#pragma mark ----- File ID Routines -----
1604
/*****************************************************************************/
1606
#pragma mark FSResolveFileIDRef
1610
FSVolumeRefNum volRefNum,
1615
The FSResolveFileIDRef function returns an FSRef for the file with the
1616
specified file ID reference.
1618
volRefNum --> Volume specification.
1619
fileID --> The file ID reference.
1620
ref <-- The FSRef for the file ID reference.
1624
Also see: FSCreateFileIDRef, FSDeleteFileIDRef
1627
/*****************************************************************************/
1629
#pragma mark FSCreateFileIDRef
1637
The FSCreateFileIDRef function creates a file ID reference for the
1638
specified file, or if a file ID reference already exists, supplies
1639
the file ID reference and returns the result code fidExists or afpIDExists.
1641
ref --> The FSRef for the file.
1642
fileID <-- The file ID reference (if result is noErr,
1643
fidExists, or afpIDExists).
1647
Also see: GetFSRefFromFileIDRef, FSDeleteFileIDRef
1650
/*****************************************************************************/
1652
#pragma mark FSDeleteFileIDRef
1655
Why is there no FSDeleteFileIDRef routine? There are two reasons:
1657
1. Since Mac OS 8.1, PBDeleteFileIDRef hasn't deleted file ID references.
1658
On HFS volumes, deleting a file ID reference breaks aliases (which
1659
use file ID references to track files as they are moved around on a
1660
volume) and file ID references are automatically deleted when the file
1661
they refer to is deleted. On HFS Plus volumes, file ID references are
1662
always created when a file is created, deleted when the file is deleted,
1663
and cannot be deleted at any other time.
1665
2. PBDeleteFileIDRef causes a memory access fault under Mac OS X 10.0
1666
through 10.1.x. While this will be fixed in a future release, the
1667
implementation, like the Mac OS 8/9 implementation, does not delete
1672
Also see: GetFSRefFromFileIDRef, FSCreateFileIDRef
1675
/*****************************************************************************/
1677
#pragma mark ----- Utility Routines -----
1679
/*****************************************************************************/
1681
#pragma mark GetTempBuffer
1685
ByteCount buffReqSize,
1686
ByteCount *buffActSize);
1689
The GetTempBuffer function allocates a temporary buffer for file system
1690
operations which is at least 4K bytes and a multiple of 4K bytes.
1692
buffReqSize --> Size you'd like the buffer to be.
1693
buffActSize <-- The size of the buffer allocated.
1694
function result <-- Pointer to memory allocated, or NULL if no memory
1695
was available. The caller is responsible for
1696
disposing of this buffer with DisposePtr.
1699
/*****************************************************************************/
1701
#pragma mark FileRefNumGetFSRef
1709
The FileRefNumGetFSRef function gets the FSRef of an open file.
1711
refNum --> The file reference number of an open file.
1712
ref <-- The FSRef to the open file.
1715
/*****************************************************************************/
1717
#pragma mark FSSetDefault
1721
const FSRef *newDefault,
1725
The FSSetDefault function sets the current working directory to the
1726
directory specified by newDefault. The previous current working directory
1727
is returned in oldDefault and must be used to restore the current working
1728
directory to its previous state with the FSRestoreDefault function.
1729
These two functions are designed to be used as a wrapper around
1730
Standard I/O routines where the location of the file is implied to be the
1731
current working directory. This is how you should use these functions:
1733
result = FSSetDefault(&newDefault, &oldDefault);
1734
if ( noErr == result )
1736
// call the Stdio functions like remove, rename,
1737
// fopen, freopen, etc here!
1739
result = FSRestoreDefault(&oldDefault);
1742
newDefault --> An FSRef that specifies the new current working
1744
oldDefault <-- The previous current working directory's FSRef.
1748
Also see: FSRestoreDefault
1751
/*****************************************************************************/
1753
#pragma mark FSRestoreDefault
1757
const FSRef *oldDefault);
1760
The FSRestoreDefault function restores the current working directory
1761
to the directory specified by oldDefault. The oldDefault parameter was
1762
previously obtained from the FSSetDefault function.
1763
These two functions are designed to be used as a wrapper around
1764
Standard I/O routines where the location of the file is implied to be the
1765
current working directory. This is how you should use these functions:
1767
result = FSSetDefault(&newDefault, &oldDefault);
1768
if ( noErr == result )
1770
// call the Stdio functions like remove, rename,
1771
// fopen, freopen, etc here!
1773
result = FSRestoreDefault(&oldDefault);
1776
oldDefault --> The FSRef of the location to restore.
1780
Also see: FSSetDefault
1783
/*****************************************************************************/
1785
#if PRAGMA_STRUCT_ALIGN
1786
#pragma options align=reset
1787
#elif PRAGMA_STRUCT_PACKPUSH
1789
#elif PRAGMA_STRUCT_PACK
1793
#ifdef PRAGMA_IMPORT_OFF
1796
#pragma import reset
1803
#endif /* __MOREFILESX__ */