From 92622ef4c2162596f543d304059375552db5c313 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 10 Oct 2001 22:57:33 +0000 Subject: [PATCH] new version 1.5.2 for morefiles git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11937 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/dirmac.cpp | 6 +- src/mac/carbon/filedlg.cpp | 7 +- src/mac/carbon/utils.cpp | 4 +- src/mac/dirmac.cpp | 6 +- src/mac/filedlg.cpp | 7 +- src/mac/morefile/Director.h | 493 --- .../{Director.cpp => DirectoryCopy.c} | 123 +- src/mac/morefile/DirectoryCopy.h | 559 +++ src/mac/morefile/FSpCompa.h | 488 --- .../morefile/{FSpCompa.cpp => FSpCompat.c} | 68 +- src/mac/morefile/FSpCompat.h | 586 +++ src/mac/morefile/{FileCopy.cpp => FileCopy.c} | 80 +- src/mac/morefile/FileCopy.h | 435 +- src/mac/morefile/{FullPath.cpp => FullPath.c} | 186 +- src/mac/morefile/FullPath.h | 480 ++- src/mac/morefile/IterateD.h | 171 - .../{IterateD.cpp => IterateDirectory.c} | 72 +- src/mac/morefile/IterateDirectory.h | 222 + src/mac/morefile/MoreDesk.h | 541 --- .../{MoreDesk.cpp => MoreDesktopMgr.c} | 96 +- src/mac/morefile/MoreDesktopMgr.h | 628 +++ src/mac/morefile/MoreExtr.h | 3149 --------------- src/mac/morefile/MoreFile.h | 1244 ------ .../morefile/{MoreFile.cpp => MoreFiles.c} | 61 +- src/mac/morefile/MoreFiles.h | 1420 +++++++ .../{MoreExtr.cpp => MoreFilesExtras.c} | 1426 ++++--- src/mac/morefile/MoreFilesExtras.h | 3597 +++++++++++++++++ src/mac/morefile/Optim.h | 120 - src/mac/morefile/OptimEnd.h | 40 - src/mac/morefile/Optimization.h | 109 + src/mac/morefile/OptimizationEnd.h | 56 + src/mac/morefile/{Search.cpp => Search.c} | 117 +- src/mac/morefile/Search.h | 478 ++- src/mac/morefile/mfsearch.cpp | 1313 ------ src/mac/morefile/mfsearch.h | 246 -- src/mac/utils.cpp | 4 +- 36 files changed, 9328 insertions(+), 9310 deletions(-) delete mode 100644 src/mac/morefile/Director.h rename src/mac/morefile/{Director.cpp => DirectoryCopy.c} (90%) create mode 100644 src/mac/morefile/DirectoryCopy.h delete mode 100644 src/mac/morefile/FSpCompa.h rename src/mac/morefile/{FSpCompa.cpp => FSpCompat.c} (94%) create mode 100644 src/mac/morefile/FSpCompat.h rename src/mac/morefile/{FileCopy.cpp => FileCopy.c} (91%) rename src/mac/morefile/{FullPath.cpp => FullPath.c} (58%) delete mode 100644 src/mac/morefile/IterateD.h rename src/mac/morefile/{IterateD.cpp => IterateDirectory.c} (79%) create mode 100644 src/mac/morefile/IterateDirectory.h delete mode 100644 src/mac/morefile/MoreDesk.h rename src/mac/morefile/{MoreDesk.cpp => MoreDesktopMgr.c} (95%) create mode 100644 src/mac/morefile/MoreDesktopMgr.h delete mode 100644 src/mac/morefile/MoreExtr.h delete mode 100644 src/mac/morefile/MoreFile.h rename src/mac/morefile/{MoreFile.cpp => MoreFiles.c} (92%) create mode 100644 src/mac/morefile/MoreFiles.h rename src/mac/morefile/{MoreExtr.cpp => MoreFilesExtras.c} (73%) create mode 100644 src/mac/morefile/MoreFilesExtras.h delete mode 100644 src/mac/morefile/Optim.h delete mode 100644 src/mac/morefile/OptimEnd.h create mode 100644 src/mac/morefile/Optimization.h create mode 100644 src/mac/morefile/OptimizationEnd.h rename src/mac/morefile/{Search.cpp => Search.c} (93%) delete mode 100644 src/mac/morefile/mfsearch.cpp delete mode 100644 src/mac/morefile/mfsearch.h diff --git a/src/mac/carbon/dirmac.cpp b/src/mac/carbon/dirmac.cpp index 36835cd68c..5f06ceab58 100644 --- a/src/mac/carbon/dirmac.cpp +++ b/src/mac/carbon/dirmac.cpp @@ -41,10 +41,8 @@ #endif #ifndef __DARWIN__ - #include "morefile.h" - #include "moreextr.h" - #include "fullpath.h" - #include "fspcompa.h" + #include "MoreFiles.h" + #include "MoreFilesExtras.h" #endif // ---------------------------------------------------------------------------- diff --git a/src/mac/carbon/filedlg.cpp b/src/mac/carbon/filedlg.cpp index 1d6fd58d44..504b2af6da 100644 --- a/src/mac/carbon/filedlg.cpp +++ b/src/mac/carbon/filedlg.cpp @@ -35,11 +35,8 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog) #endif #ifndef __DARWIN__ - #include "morefile.h" - #include "moreextr.h" - #include "fullpath.h" - #include "fspcompa.h" - #include "PLStringFuncs.h" + #include "MoreFiles.h" + #include "MoreFilesExtras.h" #endif extern bool gUseNavServices ; diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index f234da7456..e490ce4583 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -28,8 +28,8 @@ #include #ifndef __DARWIN__ -# include "morefile.h" -# include "moreextr.h" + #include "MoreFiles.h" + #include "MoreFilesExtras.h" #endif #ifndef __DARWIN__ diff --git a/src/mac/dirmac.cpp b/src/mac/dirmac.cpp index 36835cd68c..5f06ceab58 100644 --- a/src/mac/dirmac.cpp +++ b/src/mac/dirmac.cpp @@ -41,10 +41,8 @@ #endif #ifndef __DARWIN__ - #include "morefile.h" - #include "moreextr.h" - #include "fullpath.h" - #include "fspcompa.h" + #include "MoreFiles.h" + #include "MoreFilesExtras.h" #endif // ---------------------------------------------------------------------------- diff --git a/src/mac/filedlg.cpp b/src/mac/filedlg.cpp index 1d6fd58d44..504b2af6da 100644 --- a/src/mac/filedlg.cpp +++ b/src/mac/filedlg.cpp @@ -35,11 +35,8 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog) #endif #ifndef __DARWIN__ - #include "morefile.h" - #include "moreextr.h" - #include "fullpath.h" - #include "fspcompa.h" - #include "PLStringFuncs.h" + #include "MoreFiles.h" + #include "MoreFilesExtras.h" #endif extern bool gUseNavServices ; diff --git a/src/mac/morefile/Director.h b/src/mac/morefile/Director.h deleted file mode 100644 index a05335a63b..0000000000 --- a/src/mac/morefile/Director.h +++ /dev/null @@ -1,493 +0,0 @@ -/* -** Apple Macintosh Developer Technical Support -** -** DirectoryCopy: A robust, general purpose directory copy routine. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: DirectoryCopy.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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 __DIRECTORYCOPY__ -#define __DIRECTORYCOPY__ - -#include -#include - -#include "optim.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************************/ - -enum -{ - getNextItemOp = 1, /* couldn't access items in this directory - no access privileges */ - copyDirCommentOp = 2, /* couldn't copy directory's Finder comment */ - copyDirAccessPrivsOp = 3, /* couldn't copy directory's AFP access privileges */ - copyDirFMAttributesOp = 4, /* couldn't copy directory's File Manager attributes */ - dirCreateOp = 5, /* couldn't create destination directory */ - fileCopyOp = 6 /* couldn't copy file */ -}; - -/*****************************************************************************/ - -typedef pascal Boolean (*CopyErrProcPtr) (OSErr error, - short failedOperation, - short srcVRefNum, - long srcDirID, - ConstStr255Param srcName, - short dstVRefNum, - long dstDirID, - ConstStr255Param dstName); -/* ¦ Prototype for the CopyErrProc function DirectoryCopy calls. - This is the prototype for the CopyErrProc function DirectoryCopy - calls if an error condition is detected sometime during the copy. If - CopyErrProc returns false, then DirectoryCopy attempts to continue with - the directory copy operation. If CopyErrProc returns true, then - DirectoryCopy stops the directory copy operation. - - error input: The error result code that caused CopyErrProc to - be called. - failedOperation input: The operation that returned an error to - DirectoryCopy. - srcVRefNum input: Source volume specification. - srcDirID input: Source directory ID. - srcName input: Source file or directory name, or nil if - srcDirID specifies the directory. - dstVRefNum input: Destination volume specification. - dstDirID input: Destination directory ID. - dstName input: Destination file or directory name, or nil if - dstDirID specifies the directory. - - __________ - - Also see: FilteredDirectoryCopy, FSpFilteredDirectoryCopy, DirectoryCopy, FSpDirectoryCopy -*/ - -#define CallCopyErrProc(userRoutine, error, failedOperation, srcVRefNum, srcDirID, srcName, dstVRefNum, dstDirID, dstName) \ - (*(userRoutine))((error), (failedOperation), (srcVRefNum), (srcDirID), (srcName), (dstVRefNum), (dstDirID), (dstName)) - -/*****************************************************************************/ - -typedef pascal Boolean (*CopyFilterProcPtr) (const CInfoPBRec * const cpbPtr); - -/* ¦ Prototype for the CopyFilterProc function. - This is the prototype for the CopyFilterProc function called by - FilteredDirectoryCopy and GetLevelSize. If true is returned, - the file/folder is included in the copy, otherwise it is excluded. - - pb input: Points to the CInfoPBRec for the item under consideration. - - __________ - - Also see: FilteredDirectoryCopy, FSpFilteredDirectoryCopy -*/ - -#define CallCopyFilterProc(userRoutine, cpbPtr) (*(userRoutine))((cpbPtr)) - -/*****************************************************************************/ - -pascal OSErr FilteredDirectoryCopy(short srcVRefNum, - long srcDirID, - ConstStr255Param srcName, - short dstVRefNum, - long dstDirID, - ConstStr255Param dstName, - void *copyBufferPtr, - long copyBufferSize, - Boolean preflight, - CopyErrProcPtr copyErrHandler, - CopyFilterProcPtr copyFilterProc); -/* ¦ Make a copy of a directory structure in a new location with item filtering. - The FilteredDirectoryCopy function makes a copy of a directory - structure in a new location. If copyBufferPtr <> NIL, it points to - a buffer of copyBufferSize that is used to copy files data. The - larger the supplied buffer, the faster the copy. If - copyBufferPtr = NIL, then this routine allocates a buffer in the - application heap. If you pass a copy buffer to this routine, make - its size a multiple of 512 ($200) bytes for optimum performance. - - The optional copyFilterProc parameter lets a routine you define - decide what files or directories are copied to the destination. - - FilteredDirectoryCopy normally creates a new directory *in* the - specified destination directory and copies the source directory's - content into the new directory. However, if root parent directory - (fsRtParID) is passed as the dstDirID parameter and NULL is - passed as the dstName parameter, DirectoryCopy renames the - destination volume to the source directory's name (truncating - if the name is longer than 27 characters) and copies the source - directory's content into the destination volume's root directory. - This special case is supported by FilteredDirectoryCopy, but - not by FSpFilteredDirectoryCopy since with FSpFilteredDirectoryCopy, - the dstName parameter can not be NULL. - - srcVRefNum input: Source volume specification. - srcDirID input: Source directory ID. - srcName input: Source directory name, or nil if - srcDirID specifies the directory. - dstVRefNum input: Destination volume specification. - dstDirID input: Destination directory ID. - dstName input: Destination directory name, or nil if - dstDirID specifies the directory. - copyBufferPtr input: Points to a buffer of copyBufferSize that - is used the i/o buffer for the copy or - nil if you want DirectoryCopy to allocate its - own buffer in the application heap. - copyBufferSize input: The size of the buffer pointed to - by copyBufferPtr. - preflight input: If true, DirectoryCopy makes sure there are - enough allocation blocks on the destination - volume to hold the directory's files before - starting the copy. - copyErrHandler input: A pointer to the routine you want called if an - error condition is detected during the copy, or - nil if you don't want to handle error conditions. - If you don't handle error conditions, the first - error will cause the copy to quit and - DirectoryCopy will return the error. - Error handling is recommended... - copyFilterProc input: A pointer to the filter routine you want called - for each item in the source directory, or NULL - if you don't want to filter. - - Result Codes - noErr 0 No error - readErr Ð19 Driver does not respond to read requests - writErr Ð20 Driver does not respond to write requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - dskFulErr -34 Destination volume is full - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - tmfoErr -42 Too many files open - fnfErr -43 Source file not found, or destination - directory does not exist - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - fBsyErr -47 The source or destination file could - not be opened with the correct access - modes - dupFNErr -48 Destination file already exists - opWrErr -49 File already open for writing - paramErr -50 No default volume or function not - supported by volume - permErr -54 File is already open and cannot be opened using specified deny modes - memFullErr -108 Copy buffer could not be allocated - dirNFErr -120 Directory not found or incomplete pathname - wrgVolTypErr -123 Function not supported by volume - afpAccessDenied -5000 User does not have the correct access - afpDenyConflict -5006 The source or destination file could - not be opened with the correct access - modes - afpObjectTypeErr -5025 Source is a directory, directory not found - or incomplete pathname - - __________ - - Also see: CopyErrProcPtr, CopyFilterProcPtr, FSpFilteredDirectoryCopy, - DirectoryCopy, FSpDirectoryCopy, FileCopy, FSpFileCopy -*/ - -/*****************************************************************************/ - -pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec, - const FSSpec *dstSpec, - void *copyBufferPtr, - long copyBufferSize, - Boolean preflight, - CopyErrProcPtr copyErrHandler, - CopyFilterProcPtr copyFilterProc); -/* ¦ Make a copy of a directory structure in a new location with item filtering. - The FSpFilteredDirectoryCopy function makes a copy of a directory - structure in a new location. If copyBufferPtr <> NIL, it points to - a buffer of copyBufferSize that is used to copy files data. The - larger the supplied buffer, the faster the copy. If - copyBufferPtr = NIL, then this routine allocates a buffer in the - application heap. If you pass a copy buffer to this routine, make - its size a multiple of 512 ($200) bytes for optimum performance. - - The optional copyFilterProc parameter lets a routine you define - decide what files or directories are copied to the destination. - - srcSpec input: An FSSpec record specifying the directory to copy. - dstSpec input: An FSSpec record specifying destination directory - of the copy. - copyBufferPtr input: Points to a buffer of copyBufferSize that - is used the i/o buffer for the copy or - nil if you want DirectoryCopy to allocate its - own buffer in the application heap. - copyBufferSize input: The size of the buffer pointed to - by copyBufferPtr. - preflight input: If true, FSpDirectoryCopy makes sure there are - enough allocation blocks on the destination - volume to hold the directory's files before - starting the copy. - copyErrHandler input: A pointer to the routine you want called if an - error condition is detected during the copy, or - nil if you don't want to handle error conditions. - If you don't handle error conditions, the first - error will cause the copy to quit and - DirectoryCopy will return the error. - Error handling is recommended... - copyFilterProc input: A pointer to the filter routine you want called - for each item in the source directory, or NULL - if you don't want to filter. - - Result Codes - noErr 0 No error - readErr Ð19 Driver does not respond to read requests - writErr Ð20 Driver does not respond to write requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - dskFulErr -34 Destination volume is full - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - tmfoErr -42 Too many files open - fnfErr -43 Source file not found, or destination - directory does not exist - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - fBsyErr -47 The source or destination file could - not be opened with the correct access - modes - dupFNErr -48 Destination file already exists - opWrErr -49 File already open for writing - paramErr -50 No default volume or function not - supported by volume - permErr -54 File is already open and cannot be opened using specified deny modes - memFullErr -108 Copy buffer could not be allocated - dirNFErr -120 Directory not found or incomplete pathname - wrgVolTypErr -123 Function not supported by volume - afpAccessDenied -5000 User does not have the correct access - afpDenyConflict -5006 The source or destination file could - not be opened with the correct access - modes - afpObjectTypeErr -5025 Source is a directory, directory not found - or incomplete pathname - - __________ - - Also see: CopyErrProcPtr, CopyFilterProcPtr, FilteredDirectoryCopy, - DirectoryCopy, FSpDirectoryCopy, FileCopy, FSpFileCopy -*/ - -/*****************************************************************************/ - -pascal OSErr DirectoryCopy(short srcVRefNum, - long srcDirID, - ConstStr255Param srcName, - short dstVRefNum, - long dstDirID, - ConstStr255Param dstName, - void *copyBufferPtr, - long copyBufferSize, - Boolean preflight, - CopyErrProcPtr copyErrHandler); -/* ¦ Make a copy of a directory structure in a new location. - The DirectoryCopy function makes a copy of a directory structure in a - new location. If copyBufferPtr <> NIL, it points to a buffer of - copyBufferSize that is used to copy files data. The larger the - supplied buffer, the faster the copy. If copyBufferPtr = NIL, then this - routine allocates a buffer in the application heap. If you pass a - copy buffer to this routine, make its size a multiple of 512 - ($200) bytes for optimum performance. - - DirectoryCopy normally creates a new directory *in* the specified - destination directory and copies the source directory's content into - the new directory. However, if root parent directory (fsRtParID) - is passed as the dstDirID parameter and NULL is passed as the - dstName parameter, DirectoryCopy renames the destination volume to - the source directory's name (truncating if the name is longer than - 27 characters) and copies the source directory's content into the - destination volume's root directory. This special case is supported - by DirectoryCopy, but not by FSpDirectoryCopy since with - FSpDirectoryCopy, the dstName parameter can not be NULL. - - srcVRefNum input: Source volume specification. - srcDirID input: Source directory ID. - srcName input: Source directory name, or nil if - srcDirID specifies the directory. - dstVRefNum input: Destination volume specification. - dstDirID input: Destination directory ID. - dstName input: Destination directory name, or nil if - dstDirID specifies the directory. - copyBufferPtr input: Points to a buffer of copyBufferSize that - is used the i/o buffer for the copy or - nil if you want DirectoryCopy to allocate its - own buffer in the application heap. - copyBufferSize input: The size of the buffer pointed to - by copyBufferPtr. - preflight input: If true, DirectoryCopy makes sure there are - enough allocation blocks on the destination - volume to hold the directory's files before - starting the copy. - copyErrHandler input: A pointer to the routine you want called if an - error condition is detected during the copy, or - nil if you don't want to handle error conditions. - If you don't handle error conditions, the first - error will cause the copy to quit and - DirectoryCopy will return the error. - Error handling is recommended... - - Result Codes - noErr 0 No error - readErr Ð19 Driver does not respond to read requests - writErr Ð20 Driver does not respond to write requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - dskFulErr -34 Destination volume is full - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - tmfoErr -42 Too many files open - fnfErr -43 Source file not found, or destination - directory does not exist - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - fBsyErr -47 The source or destination file could - not be opened with the correct access - modes - dupFNErr -48 Destination file already exists - opWrErr -49 File already open for writing - paramErr -50 No default volume or function not - supported by volume - permErr -54 File is already open and cannot be opened using specified deny modes - memFullErr -108 Copy buffer could not be allocated - dirNFErr -120 Directory not found or incomplete pathname - wrgVolTypErr -123 Function not supported by volume - afpAccessDenied -5000 User does not have the correct access - afpDenyConflict -5006 The source or destination file could - not be opened with the correct access - modes - afpObjectTypeErr -5025 Source is a directory, directory not found - or incomplete pathname - - __________ - - Also see: CopyErrProcPtr, FSpDirectoryCopy, FilteredDirectoryCopy, - FSpFilteredDirectoryCopy, FileCopy, FSpFileCopy -*/ - -/*****************************************************************************/ - -pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec, - const FSSpec *dstSpec, - void *copyBufferPtr, - long copyBufferSize, - Boolean preflight, - CopyErrProcPtr copyErrHandler); -/* ¦ Make a copy of a directory structure in a new location. - The FSpDirectoryCopy function makes a copy of a directory structure in a - new location. If copyBufferPtr <> NIL, it points to a buffer of - copyBufferSize that is used to copy files data. The larger the - supplied buffer, the faster the copy. If copyBufferPtr = NIL, then this - routine allocates a buffer in the application heap. If you pass a - copy buffer to this routine, make its size a multiple of 512 - ($200) bytes for optimum performance. - - srcSpec input: An FSSpec record specifying the directory to copy. - dstSpec input: An FSSpec record specifying destination directory - of the copy. - copyBufferPtr input: Points to a buffer of copyBufferSize that - is used the i/o buffer for the copy or - nil if you want DirectoryCopy to allocate its - own buffer in the application heap. - copyBufferSize input: The size of the buffer pointed to - by copyBufferPtr. - preflight input: If true, FSpDirectoryCopy makes sure there are - enough allocation blocks on the destination - volume to hold the directory's files before - starting the copy. - copyErrHandler input: A pointer to the routine you want called if an - error condition is detected during the copy, or - nil if you don't want to handle error conditions. - If you don't handle error conditions, the first - error will cause the copy to quit and - DirectoryCopy will return the error. - Error handling is recommended... - - Result Codes - noErr 0 No error - readErr Ð19 Driver does not respond to read requests - writErr Ð20 Driver does not respond to write requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - dskFulErr -34 Destination volume is full - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - tmfoErr -42 Too many files open - fnfErr -43 Source file not found, or destination - directory does not exist - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - fBsyErr -47 The source or destination file could - not be opened with the correct access - modes - dupFNErr -48 Destination file already exists - opWrErr -49 File already open for writing - paramErr -50 No default volume or function not - supported by volume - permErr -54 File is already open and cannot be opened using specified deny modes - memFullErr -108 Copy buffer could not be allocated - dirNFErr -120 Directory not found or incomplete pathname - wrgVolTypErr -123 Function not supported by volume - afpAccessDenied -5000 User does not have the correct access - afpDenyConflict -5006 The source or destination file could - not be opened with the correct access - modes - afpObjectTypeErr -5025 Source is a directory, directory not found - or incomplete pathname - - __________ - - Also see: CopyErrProcPtr, DirectoryCopy, FilteredDirectoryCopy, - FSpFilteredDirectoryCopy, FileCopy, FSpFileCopy -*/ - -/*****************************************************************************/ - -#ifdef __cplusplus -} -#endif - -#include "optimend.h" - -#endif /* __DIRECTORYCOPY__ */ diff --git a/src/mac/morefile/Director.cpp b/src/mac/morefile/DirectoryCopy.c similarity index 90% rename from src/mac/morefile/Director.cpp rename to src/mac/morefile/DirectoryCopy.c index 635877693f..ed9c834718 100644 --- a/src/mac/morefile/Director.cpp +++ b/src/mac/morefile/DirectoryCopy.c @@ -1,37 +1,53 @@ /* -** Apple Macintosh Developer Technical Support -** -** DirectoryCopy: A robust, general purpose directory copy routine. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: DirectoryCopy.c -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: DirectoryCopy.c + + Contains: A robust, general purpose directory copy routine. + + Version: MoreFiles + + Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <2> 2/7/01 JL Added standard header. Updated names of includes. + <1> 12/06/99 JL MoreFiles 1.5. */ -#include -#include -#include +#include +#include +#include #include #include +#include #define __COMPILINGMOREFILES -#include "morefile.h" -#include "moreextr.h" -#include "moredesk.h" -#include "filecopy.h" -#include "director.h" +#include "MoreFiles.h" +#include "MoreFilesExtras.h" +#include "MoreDesktopMgr.h" +#include "FileCopy.h" +#include "DirectoryCopy.h" /*****************************************************************************/ @@ -53,13 +69,8 @@ enum ** global information that might be needed at any time. */ #if PRAGMA_STRUCT_ALIGN - #pragma options align=mac68k -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(push, 2) -#elif PRAGMA_STRUCT_PACK - #pragma pack(2) +#pragma options align=mac68k #endif - struct EnumerateGlobals { Ptr copyBuffer; /* pointer to buffer used for file copy operations */ @@ -73,11 +84,7 @@ struct EnumerateGlobals CInfoPBRec myCPB; /* the parameter block used for PBGetCatInfo calls */ }; #if PRAGMA_STRUCT_ALIGN - #pragma options align=reset -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(pop) -#elif PRAGMA_STRUCT_PACK - #pragma pack() +#pragma options align=reset #endif typedef struct EnumerateGlobals EnumerateGlobals; @@ -89,13 +96,8 @@ typedef EnumerateGlobals *EnumerateGlobalsPtr; ** global information that might be needed at any time. */ #if PRAGMA_STRUCT_ALIGN - #pragma options align=mac68k -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(push, 2) -#elif PRAGMA_STRUCT_PACK - #pragma pack(2) +#pragma options align=mac68k #endif - struct PreflightGlobals { OSErr result; /* temporary holder of results - saves 2 bytes of stack each level */ @@ -110,11 +112,7 @@ struct PreflightGlobals CopyFilterProcPtr copyFilterProc; /* pointer to filter function */ }; #if PRAGMA_STRUCT_ALIGN - #pragma options align=reset -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(pop) -#elif PRAGMA_STRUCT_PACK - #pragma pack() +#pragma options align=reset #endif typedef struct PreflightGlobals PreflightGlobals; @@ -157,7 +155,7 @@ static void GetLevelSize(long currentDirID, CallCopyFilterProc(theGlobals->copyFilterProc, &theGlobals->myCPB) ) /* filter if filter proc was supplied */ { /* Either there's no filter proc OR the filter proc says to use this item */ - if ( (theGlobals->myCPB.dirInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (theGlobals->myCPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* we have a directory */ @@ -214,9 +212,6 @@ static void GetLevelSize(long currentDirID, } while ( theGlobals->result == noErr ); } - -#if !TARGET_CARBON - /*****************************************************************************/ static OSErr PreflightDirectoryCopySpace(short srcVRefNum, @@ -234,8 +229,7 @@ static OSErr PreflightDirectoryCopySpace(short srcVRefNum, if ( error == noErr ) { /* Convert freeBytes to free disk blocks (512-byte blocks) */ - // dstFreeBlocks = (pb.ioVFreeBytes.hi << 23) + (pb.ioVFreeBytes.lo >> 9); - dstFreeBlocks = pb.ioVFreeBytes >> 9 ; + dstFreeBlocks = U32SetU(U64ShiftRight(pb.ioVFreeBytes, 9)); /* get allocation block size (always multiple of 512) and divide by 512 to get number of 512-byte blocks per allocation block */ @@ -259,7 +253,7 @@ static OSErr PreflightDirectoryCopySpace(short srcVRefNum, return ( error ); } -#endif + /*****************************************************************************/ static void CopyLevel(long sourceDirID, @@ -286,7 +280,7 @@ static void CopyLevel(long sourceDirID, /* Either there's no filter proc OR the filter proc says to use this item */ /* We have an item. Is it a file or directory? */ - if ( (theGlobals->myCPB.hFileInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (theGlobals->myCPB.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* We have a directory */ @@ -425,6 +419,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, short dstVRefNum, long dstDirID, ConstStr255Param dstName, + ConstStr255Param copyName, void *copyBufferPtr, long copyBufferSize, Boolean preflight, @@ -537,18 +532,26 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum, error = GetDirName(dstVRefNum, fsRtDirID, oldDiskName); if ( error == noErr ) { + /* use the copyName as srcDirName if supplied */ + if ( copyName != NULL ) + { + /* make a copy since copyName is a const input */ + BlockMoveData(copyName, srcDirName, sizeof(Str31)); + } /* Shorten the name if it's too long to be the volume name */ TruncPString(srcDirName, srcDirName, 27); /* Rename the disk */ error = HRename(dstVRefNum, fsRtParID, oldDiskName, srcDirName); + /* and copy to the root directory */ dstDirID = fsRtDirID; } } else { - error = DirCreate(dstVRefNum, dstDirID, srcDirName, &dstDirID); + /* use the copyName as srcDirName if supplied */ + error = DirCreate(dstVRefNum, dstDirID, ((copyName != NULL) ? copyName : srcDirName), &dstDirID); } if ( error != noErr ) { @@ -629,6 +632,7 @@ pascal OSErr DirectoryCopy(short srcVRefNum, short dstVRefNum, long dstDirID, ConstStr255Param dstName, + ConstStr255Param copyName, void *copyBufferPtr, long copyBufferSize, Boolean preflight, @@ -636,6 +640,7 @@ pascal OSErr DirectoryCopy(short srcVRefNum, { return ( FilteredDirectoryCopy(srcVRefNum, srcDirID, srcName, dstVRefNum, dstDirID, dstName, + copyName, copyBufferPtr, copyBufferSize, preflight, copyErrHandler, NULL) ); } @@ -644,6 +649,7 @@ pascal OSErr DirectoryCopy(short srcVRefNum, pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec, const FSSpec *dstSpec, + ConstStr255Param copyName, void *copyBufferPtr, long copyBufferSize, Boolean preflight, @@ -652,6 +658,7 @@ pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec, { return ( FilteredDirectoryCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name, dstSpec->vRefNum, dstSpec->parID, dstSpec->name, + copyName, copyBufferPtr, copyBufferSize, preflight, copyErrHandler, copyFilterProc) ); } @@ -660,6 +667,7 @@ pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec, pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec, const FSSpec *dstSpec, + ConstStr255Param copyName, void *copyBufferPtr, long copyBufferSize, Boolean preflight, @@ -667,6 +675,7 @@ pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec, { return ( FilteredDirectoryCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name, dstSpec->vRefNum, dstSpec->parID, dstSpec->name, + copyName, copyBufferPtr, copyBufferSize, preflight, copyErrHandler, NULL) ); } diff --git a/src/mac/morefile/DirectoryCopy.h b/src/mac/morefile/DirectoryCopy.h new file mode 100644 index 0000000000..14637e31aa --- /dev/null +++ b/src/mac/morefile/DirectoryCopy.h @@ -0,0 +1,559 @@ +/* + File: DirectoryCopy.h + + Contains: A robust, general purpose directory copy routine. + + 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 __DIRECTORYCOPY__ +#define __DIRECTORYCOPY__ + +#ifndef __MACTYPES__ +#include +#endif + +#ifndef __FILES__ +#include +#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 + +/*****************************************************************************/ + +enum { + getNextItemOp = 1, /* couldn't access items in this directory - no access privileges */ + copyDirCommentOp = 2, /* couldn't copy directory's Finder comment */ + copyDirAccessPrivsOp = 3, /* couldn't copy directory's AFP access privileges */ + copyDirFMAttributesOp = 4, /* couldn't copy directory's File Manager attributes */ + dirCreateOp = 5, /* couldn't create destination directory */ + fileCopyOp = 6 /* couldn't copy file */ +}; + + +/*****************************************************************************/ + +typedef CALLBACK_API( Boolean , CopyErrProcPtr )(OSErr error, short failedOperation, short srcVRefNum, long srcDirID, ConstStr255Param srcName, short dstVRefNum, long dstDirID, ConstStr255Param dstName); +/* + This is the prototype for the CopyErrProc function DirectoryCopy + calls if an error condition is detected sometime during the copy. If + CopyErrProc returns false, then DirectoryCopy attempts to continue with + the directory copy operation. If CopyErrProc returns true, then + DirectoryCopy stops the directory copy operation. + + error input: The error result code that caused CopyErrProc to + be called. + failedOperation input: The operation that returned an error to + DirectoryCopy. + srcVRefNum input: Source volume specification. + srcDirID input: Source directory ID. + srcName input: Source file or directory name, or nil if + srcDirID specifies the directory. + dstVRefNum input: Destination volume specification. + dstDirID input: Destination directory ID. + dstName input: Destination file or directory name, or nil if + dstDirID specifies the directory. + + __________ + + Also see: FilteredDirectoryCopy, FSpFilteredDirectoryCopy, DirectoryCopy, FSpDirectoryCopy +*/ +#define CallCopyErrProc(userRoutine, error, failedOperation, srcVRefNum, srcDirID, srcName, dstVRefNum, dstDirID, dstName) \ + (*(userRoutine))((error), (failedOperation), (srcVRefNum), (srcDirID), (srcName), (dstVRefNum), (dstDirID), (dstName)) + +/*****************************************************************************/ + +typedef CALLBACK_API( Boolean , CopyFilterProcPtr )(const CInfoPBRec * cpbPtr); +/* + This is the prototype for the CopyFilterProc function called by + FilteredDirectoryCopy and GetLevelSize. If true is returned, + the file/folder is included in the copy, otherwise it is excluded. + + pb input: Points to the CInfoPBRec for the item under consideration. + + __________ + + Also see: FilteredDirectoryCopy, FSpFilteredDirectoryCopy +*/ +#define CallCopyFilterProc(userRoutine, cpbPtr) \ + (*(userRoutine))((cpbPtr)) + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FilteredDirectoryCopy( + short srcVRefNum, + long srcDirID, + ConstStr255Param srcName, + short dstVRefNum, + long dstDirID, + ConstStr255Param dstName, + ConstStr255Param copyName, + void * copyBufferPtr, + long copyBufferSize, + Boolean preflight, + CopyErrProcPtr copyErrHandler, + CopyFilterProcPtr copyFilterProc); + + +/* + The FilteredDirectoryCopy function makes a copy of a directory + structure in a new location. If copyBufferPtr <> NIL, it points to + a buffer of copyBufferSize that is used to copy files data. The + larger the supplied buffer, the faster the copy. If + copyBufferPtr = NIL, then this routine allocates a buffer in the + application heap. If you pass a copy buffer to this routine, make + its size a multiple of 512 ($200) bytes for optimum performance. + + The optional copyFilterProc parameter lets a routine you define + decide what files or directories are copied to the destination. + + FilteredDirectoryCopy normally creates a new directory *in* the + specified destination directory and copies the source directory's + content into the new directory. However, if root parent directory + (fsRtParID) is passed as the dstDirID parameter and NULL is + passed as the dstName parameter, DirectoryCopy renames the + destination volume to the source directory's name (truncating + if the name is longer than 27 characters) and copies the source + directory's content into the destination volume's root directory. + This special case is supported by FilteredDirectoryCopy, but + not by FSpFilteredDirectoryCopy since with FSpFilteredDirectoryCopy, + the dstName parameter can not be NULL. + + srcVRefNum input: Source volume specification. + srcDirID input: Source directory ID. + srcName input: Source directory name, or nil if + srcDirID specifies the directory. + dstVRefNum input: Destination volume specification. + dstDirID input: Destination directory ID. + dstName input: Destination directory name, or nil if + dstDirID specifies the directory. + copyName input: Points to the new directory name if the directory + is to be renamed or nil if the directory isn't to + be renamed. + copyBufferPtr input: Points to a buffer of copyBufferSize that + is used the i/o buffer for the copy or + nil if you want DirectoryCopy to allocate its + own buffer in the application heap. + copyBufferSize input: The size of the buffer pointed to + by copyBufferPtr. + preflight input: If true, DirectoryCopy makes sure there are + enough allocation blocks on the destination + volume to hold the directory's files before + starting the copy. + copyErrHandler input: A pointer to the routine you want called if an + error condition is detected during the copy, or + nil if you don't want to handle error conditions. + If you don't handle error conditions, the first + error will cause the copy to quit and + DirectoryCopy will return the error. + Error handling is recommended... + copyFilterProc input: A pointer to the filter routine you want called + for each item in the source directory, or NULL + if you don't want to filter. + + Result Codes + noErr 0 No error + readErr Ð19 Driver does not respond to read requests + writErr Ð20 Driver does not respond to write requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + dskFulErr -34 Destination volume is full + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + tmfoErr -42 Too many files open + fnfErr -43 Source file not found, or destination + directory does not exist + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + fBsyErr -47 The source or destination file could + not be opened with the correct access + modes + dupFNErr -48 Destination file already exists + opWrErr -49 File already open for writing + paramErr -50 No default volume or function not + supported by volume + permErr -54 File is already open and cannot be opened using specified deny modes + memFullErr -108 Copy buffer could not be allocated + dirNFErr -120 Directory not found or incomplete pathname + wrgVolTypErr -123 Function not supported by volume + afpAccessDenied -5000 User does not have the correct access + afpDenyConflict -5006 The source or destination file could + not be opened with the correct access + modes + afpObjectTypeErr -5025 Source is a directory, directory not found + or incomplete pathname + + __________ + + Also see: CopyErrProcPtr, CopyFilterProcPtr, FSpFilteredDirectoryCopy, + DirectoryCopy, FSpDirectoryCopy, FileCopy, FSpFileCopy +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpFilteredDirectoryCopy( + const FSSpec * srcSpec, + const FSSpec * dstSpec, + ConstStr255Param copyName, + void * copyBufferPtr, + long copyBufferSize, + Boolean preflight, + CopyErrProcPtr copyErrHandler, + CopyFilterProcPtr copyFilterProc); + + +/* + The FSpFilteredDirectoryCopy function makes a copy of a directory + structure in a new location. If copyBufferPtr <> NIL, it points to + a buffer of copyBufferSize that is used to copy files data. The + larger the supplied buffer, the faster the copy. If + copyBufferPtr = NIL, then this routine allocates a buffer in the + application heap. If you pass a copy buffer to this routine, make + its size a multiple of 512 ($200) bytes for optimum performance. + + The optional copyFilterProc parameter lets a routine you define + decide what files or directories are copied to the destination. + + srcSpec input: An FSSpec record specifying the directory to copy. + dstSpec input: An FSSpec record specifying destination directory + of the copy. + copyName input: Points to the new directory name if the directory + is to be renamed or nil if the directory isn't to + be renamed. + copyBufferPtr input: Points to a buffer of copyBufferSize that + is used the i/o buffer for the copy or + nil if you want DirectoryCopy to allocate its + own buffer in the application heap. + copyBufferSize input: The size of the buffer pointed to + by copyBufferPtr. + preflight input: If true, FSpDirectoryCopy makes sure there are + enough allocation blocks on the destination + volume to hold the directory's files before + starting the copy. + copyErrHandler input: A pointer to the routine you want called if an + error condition is detected during the copy, or + nil if you don't want to handle error conditions. + If you don't handle error conditions, the first + error will cause the copy to quit and + DirectoryCopy will return the error. + Error handling is recommended... + copyFilterProc input: A pointer to the filter routine you want called + for each item in the source directory, or NULL + if you don't want to filter. + + Result Codes + noErr 0 No error + readErr Ð19 Driver does not respond to read requests + writErr Ð20 Driver does not respond to write requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + dskFulErr -34 Destination volume is full + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + tmfoErr -42 Too many files open + fnfErr -43 Source file not found, or destination + directory does not exist + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + fBsyErr -47 The source or destination file could + not be opened with the correct access + modes + dupFNErr -48 Destination file already exists + opWrErr -49 File already open for writing + paramErr -50 No default volume or function not + supported by volume + permErr -54 File is already open and cannot be opened using specified deny modes + memFullErr -108 Copy buffer could not be allocated + dirNFErr -120 Directory not found or incomplete pathname + wrgVolTypErr -123 Function not supported by volume + afpAccessDenied -5000 User does not have the correct access + afpDenyConflict -5006 The source or destination file could + not be opened with the correct access + modes + afpObjectTypeErr -5025 Source is a directory, directory not found + or incomplete pathname + + __________ + + Also see: CopyErrProcPtr, CopyFilterProcPtr, FilteredDirectoryCopy, + DirectoryCopy, FSpDirectoryCopy, FileCopy, FSpFileCopy +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DirectoryCopy( + short srcVRefNum, + long srcDirID, + ConstStr255Param srcName, + short dstVRefNum, + long dstDirID, + ConstStr255Param dstName, + ConstStr255Param copyName, + void * copyBufferPtr, + long copyBufferSize, + Boolean preflight, + CopyErrProcPtr copyErrHandler); + + +/* + The DirectoryCopy function makes a copy of a directory structure in a + new location. If copyBufferPtr <> NIL, it points to a buffer of + copyBufferSize that is used to copy files data. The larger the + supplied buffer, the faster the copy. If copyBufferPtr = NIL, then this + routine allocates a buffer in the application heap. If you pass a + copy buffer to this routine, make its size a multiple of 512 + ($200) bytes for optimum performance. + + DirectoryCopy normally creates a new directory *in* the specified + destination directory and copies the source directory's content into + the new directory. However, if root parent directory (fsRtParID) + is passed as the dstDirID parameter and NULL is passed as the + dstName parameter, DirectoryCopy renames the destination volume to + the source directory's name (truncating if the name is longer than + 27 characters) and copies the source directory's content into the + destination volume's root directory. This special case is supported + by DirectoryCopy, but not by FSpDirectoryCopy since with + FSpDirectoryCopy, the dstName parameter can not be NULL. + + srcVRefNum input: Source volume specification. + srcDirID input: Source directory ID. + srcName input: Source directory name, or nil if + srcDirID specifies the directory. + dstVRefNum input: Destination volume specification. + dstDirID input: Destination directory ID. + dstName input: Destination directory name, or nil if + dstDirID specifies the directory. + copyName input: Points to the new directory name if the directory + is to be renamed or nil if the directory isn't to + be renamed. + copyBufferPtr input: Points to a buffer of copyBufferSize that + is used the i/o buffer for the copy or + nil if you want DirectoryCopy to allocate its + own buffer in the application heap. + copyBufferSize input: The size of the buffer pointed to + by copyBufferPtr. + preflight input: If true, DirectoryCopy makes sure there are + enough allocation blocks on the destination + volume to hold the directory's files before + starting the copy. + copyErrHandler input: A pointer to the routine you want called if an + error condition is detected during the copy, or + nil if you don't want to handle error conditions. + If you don't handle error conditions, the first + error will cause the copy to quit and + DirectoryCopy will return the error. + Error handling is recommended... + + Result Codes + noErr 0 No error + readErr Ð19 Driver does not respond to read requests + writErr Ð20 Driver does not respond to write requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + dskFulErr -34 Destination volume is full + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + tmfoErr -42 Too many files open + fnfErr -43 Source file not found, or destination + directory does not exist + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + fBsyErr -47 The source or destination file could + not be opened with the correct access + modes + dupFNErr -48 Destination file already exists + opWrErr -49 File already open for writing + paramErr -50 No default volume or function not + supported by volume + permErr -54 File is already open and cannot be opened using specified deny modes + memFullErr -108 Copy buffer could not be allocated + dirNFErr -120 Directory not found or incomplete pathname + wrgVolTypErr -123 Function not supported by volume + afpAccessDenied -5000 User does not have the correct access + afpDenyConflict -5006 The source or destination file could + not be opened with the correct access + modes + afpObjectTypeErr -5025 Source is a directory, directory not found + or incomplete pathname + + __________ + + Also see: CopyErrProcPtr, FSpDirectoryCopy, FilteredDirectoryCopy, + FSpFilteredDirectoryCopy, FileCopy, FSpFileCopy +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpDirectoryCopy( + const FSSpec * srcSpec, + const FSSpec * dstSpec, + ConstStr255Param copyName, + void * copyBufferPtr, + long copyBufferSize, + Boolean preflight, + CopyErrProcPtr copyErrHandler); + + +/* + The FSpDirectoryCopy function makes a copy of a directory structure in a + new location. If copyBufferPtr <> NIL, it points to a buffer of + copyBufferSize that is used to copy files data. The larger the + supplied buffer, the faster the copy. If copyBufferPtr = NIL, then this + routine allocates a buffer in the application heap. If you pass a + copy buffer to this routine, make its size a multiple of 512 + ($200) bytes for optimum performance. + + srcSpec input: An FSSpec record specifying the directory to copy. + dstSpec input: An FSSpec record specifying destination directory + of the copy. + copyName input: Points to the new directory name if the directory + is to be renamed or nil if the directory isn't to + be renamed. + copyBufferPtr input: Points to a buffer of copyBufferSize that + is used the i/o buffer for the copy or + nil if you want DirectoryCopy to allocate its + own buffer in the application heap. + copyBufferSize input: The size of the buffer pointed to + by copyBufferPtr. + preflight input: If true, FSpDirectoryCopy makes sure there are + enough allocation blocks on the destination + volume to hold the directory's files before + starting the copy. + copyErrHandler input: A pointer to the routine you want called if an + error condition is detected during the copy, or + nil if you don't want to handle error conditions. + If you don't handle error conditions, the first + error will cause the copy to quit and + DirectoryCopy will return the error. + Error handling is recommended... + + Result Codes + noErr 0 No error + readErr Ð19 Driver does not respond to read requests + writErr Ð20 Driver does not respond to write requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + dskFulErr -34 Destination volume is full + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + tmfoErr -42 Too many files open + fnfErr -43 Source file not found, or destination + directory does not exist + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + fBsyErr -47 The source or destination file could + not be opened with the correct access + modes + dupFNErr -48 Destination file already exists + opWrErr -49 File already open for writing + paramErr -50 No default volume or function not + supported by volume + permErr -54 File is already open and cannot be opened using specified deny modes + memFullErr -108 Copy buffer could not be allocated + dirNFErr -120 Directory not found or incomplete pathname + wrgVolTypErr -123 Function not supported by volume + afpAccessDenied -5000 User does not have the correct access + afpDenyConflict -5006 The source or destination file could + not be opened with the correct access + modes + afpObjectTypeErr -5025 Source is a directory, directory not found + or incomplete pathname + + __________ + + Also see: CopyErrProcPtr, DirectoryCopy, FilteredDirectoryCopy, + FSpFilteredDirectoryCopy, FileCopy, FSpFileCopy +*/ + +/*****************************************************************************/ + +#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 /* __DIRECTORYCOPY__ */ + diff --git a/src/mac/morefile/FSpCompa.h b/src/mac/morefile/FSpCompa.h deleted file mode 100644 index d808ad8b93..0000000000 --- a/src/mac/morefile/FSpCompa.h +++ /dev/null @@ -1,488 +0,0 @@ -/* -** Apple Macintosh Developer Technical Support -** -** FSSpec compatibility functions. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: FSpCompat.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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__ - -#include -#include - -#include "optim.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************************/ - -pascal OSErr FSMakeFSSpecCompat(short vRefNum, - long dirID, - ConstStr255Param fileName, - FSSpec *spec); -/* ¦ Initialize a FSSpec record. - 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 doesnÕt exist - fnfErr -43 File or directory does not exist - (FSSpec is still valid) -*/ - -/*****************************************************************************/ - -pascal OSErr FSpOpenDFCompat(const FSSpec *spec, - char permission, - short *refNum); -/* ¦ Open a file's data fork. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpOpenRFCompat(const FSSpec *spec, - char permission, - short *refNum); -/* ¦ Open a file's resource fork. - 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 -*/ - - -/*****************************************************************************/ - -pascal OSErr FSpCreateCompat(const FSSpec *spec, - OSType creator, - OSType fileType, - ScriptCode scriptTag); -/* ¦ Create a new file. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpDirCreateCompat(const FSSpec *spec, - ScriptCode scriptTag, - long *createdDirID); -/* ¦ Create a new directory. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpDeleteCompat(const FSSpec *spec); -/* ¦ Delete a file or directory. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpGetFInfoCompat(const FSSpec *spec, - FInfo *fndrInfo); -/* ¦ Get the finder information for a file. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpSetFInfoCompat(const FSSpec *spec, - const FInfo *fndrInfo); -/* ¦ Set the finder information for a file. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpSetFLockCompat(const FSSpec *spec); -/* ¦ Lock a file. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpRstFLockCompat(const FSSpec *spec); -/* ¦ Unlock a file. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpRenameCompat(const FSSpec *spec, - ConstStr255Param newName); -/* ¦ Rename a file or directory. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpCatMoveCompat(const FSSpec *source, - const FSSpec *dest); -/* ¦ Move a file or directory to a different location on on the same volume. - 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 -*/ - -/*****************************************************************************/ - -pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, - const FSSpec *dest); -/* ¦ Exchange the data stored in two files on the same volume. - 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 -*/ - -/*****************************************************************************/ - -pascal short FSpOpenResFileCompat(const FSSpec *spec, - SignedByte permission); -/* ¦ Open a file's resource file. - 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 -*/ - -/*****************************************************************************/ - -pascal void FSpCreateResFileCompat(const FSSpec *spec, - OSType creator, - OSType fileType, - ScriptCode scriptTag); -/* ¦ Create a resource file. - 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 -*/ - -/*****************************************************************************/ - -#ifdef __cplusplus -} -#endif - -#include "optimend.h" - -#endif /* __FSPCOMPAT__ */ - diff --git a/src/mac/morefile/FSpCompa.cpp b/src/mac/morefile/FSpCompat.c similarity index 94% rename from src/mac/morefile/FSpCompa.cpp rename to src/mac/morefile/FSpCompat.c index b6a538acb5..17577684f6 100644 --- a/src/mac/morefile/FSpCompa.cpp +++ b/src/mac/morefile/FSpCompat.c @@ -1,22 +1,39 @@ /* -** Apple Macintosh Developer Technical Support -** -** FSSpec compatibility functions. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: FSpCompat.c -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: FSpCompat.c + + Contains: FSSpec compatibility functions. + + Version: MoreFiles + + Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <2> 2/7/01 JL Added standard header. Updated names of includes. Updated + various routines to use new calling convention of the + MoreFilesExtras accessor functions. + <1> 12/06/99 JL MoreFiles 1.5. */ /* @@ -28,8 +45,9 @@ #define GENERATENODATA 0 #endif -#include -#include +#include +#include +#include #include #include #include @@ -37,8 +55,8 @@ #define __COMPILINGMOREFILES -#include "moreextr.h" -#include "fspcompa.h" +#include "MoreFilesExtras.h" +#include "FSpCompat.h" /*****************************************************************************/ @@ -684,7 +702,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, result2 = PBHGetVolParmsSync(&pb); /* continue if volume has no fileID support (or no GetVolParms support) */ - if ( (result2 == noErr) && hasFileIDs(volInfo) ) + if ( (result2 == noErr) && hasFileIDs(&volInfo) ) { goto errorExit3; } @@ -701,7 +719,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, { goto errorExit3; } - if ( (catInfoSource.hFileInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (catInfoSource.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { result = notAFileErr; goto errorExit3; @@ -717,7 +735,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source, { goto errorExit3; } - if ( (catInfoDest.hFileInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (catInfoDest.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { result = notAFileErr; goto errorExit3; diff --git a/src/mac/morefile/FSpCompat.h b/src/mac/morefile/FSpCompat.h new file mode 100644 index 0000000000..1014cb8e58 --- /dev/null +++ b/src/mac/morefile/FSpCompat.h @@ -0,0 +1,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 +#endif + +#ifndef __FILES__ +#include +#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 doesnÕt 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__ */ + diff --git a/src/mac/morefile/FileCopy.cpp b/src/mac/morefile/FileCopy.c similarity index 91% rename from src/mac/morefile/FileCopy.cpp rename to src/mac/morefile/FileCopy.c index acb9c92d11..4848613b51 100644 --- a/src/mac/morefile/FileCopy.cpp +++ b/src/mac/morefile/FileCopy.c @@ -1,36 +1,53 @@ /* -** Apple Macintosh Developer Technical Support -** -** FileCopy: A robust, general purpose file copy routine. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: FileCopy.c -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: FileCopy.c + + Contains: A robust, general purpose file copy routine. + + Version: MoreFiles + + Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <2> 2/7/01 JL Added standard header. Updated names of includes. Updated + various routines to use new calling convention of the + MoreFilesExtras accessor functions. + <1> 12/06/99 JL MoreFiles 1.5. */ -#include -#include -#include +#include +#include +#include #include #include #define __COMPILINGMOREFILES -#include "morefile.h" -#include "moreextr.h" -#include "moredesk.h" -#include "filecopy.h" +#include "MoreFiles.h" +#include "MoreFilesExtras.h" +#include "MoreDesktopMgr.h" +#include "FileCopy.h" /*****************************************************************************/ @@ -129,9 +146,9 @@ static OSErr GetDestinationDirInfo(short vRefNum, pb.dirInfo.ioACUser = 0; /* ioACUser used to be filler2, clear it before calling GetCatInfo */ error = GetCatInfoNoName(vRefNum, dirID, name, &pb); *theDirID = pb.dirInfo.ioDrDirID; - *isDirectory = (pb.dirInfo.ioFlAttrib & ioDirMask) != 0; + *isDirectory = (pb.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0; /* see if access priviledges are make changes, not see folder, and not see files (drop box) */ - *isDropBox = ((pb.dirInfo.ioACUser & 0x07) == 0x03); + *isDropBox = userHasDropBoxAccess(pb.dirInfo.ioACUser); return ( error ); } @@ -161,8 +178,6 @@ static OSErr CheckForForks(short vRefNum, /*****************************************************************************/ -#if !TARGET_CARBON - static OSErr PreflightFileCopySpace(short srcVRefNum, long srcDirID, ConstStr255Param srcName, @@ -185,8 +200,7 @@ static OSErr PreflightFileCopySpace(short srcVRefNum, dstBlksPerAllocBlk = ((unsigned long)pb.xPB.ioVAlBlkSiz >> 9); /* Convert freeBytes to free disk blocks (512-byte blocks) */ - // dstFreeBlocks = (pb.xPB.ioVFreeBytes.hi << 23) + (pb.xPB.ioVFreeBytes.lo >> 9); - dstFreeBlocks = pb.xPB.ioVFreeBytes >> 9 ; + dstFreeBlocks = U32SetU(U64ShiftRight(pb.xPB.ioVFreeBytes, 9)); /* Now, get the size of the file's data resource forks */ pb.hPB.fileParam.ioNamePtr = (StringPtr)srcName; @@ -247,7 +261,7 @@ static OSErr PreflightFileCopySpace(short srcVRefNum, return ( error ); } -#endif + /*****************************************************************************/ pascal OSErr FileCopy(short srcVRefNum, @@ -331,7 +345,7 @@ pascal OSErr FileCopy(short srcVRefNum, return ( err ); } - if ( (err != paramErr) && hasCopyFile(infoBuffer) ) + if ( (err != paramErr) && hasCopyFile(&infoBuffer) ) { /* The source volume supports PBHCopyFile. */ srcServerAdr = infoBuffer.vMServerAdr; diff --git a/src/mac/morefile/FileCopy.h b/src/mac/morefile/FileCopy.h index 257a73315c..a855f1f96f 100644 --- a/src/mac/morefile/FileCopy.h +++ b/src/mac/morefile/FileCopy.h @@ -1,220 +1,271 @@ /* -** Apple Macintosh Developer Technical Support -** -** FileCopy: A robust, general purpose file copy routine. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: FileCopy.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: FileCopy.h + + Contains: A robust, general purpose file copy routine. + + 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 __FILECOPY__ #define __FILECOPY__ -#include +#ifndef __MACTYPES__ +#include +#endif + +#ifndef __FILES__ #include +#endif -#include "optim.h" +#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 + /*****************************************************************************/ -pascal OSErr FileCopy(short srcVRefNum, - long srcDirID, - ConstStr255Param srcName, - short dstVRefNum, - long dstDirID, - ConstStr255Param dstPathname, - ConstStr255Param copyName, - void *copyBufferPtr, - long copyBufferSize, - Boolean preflight); -/* ¦ Duplicate a file and optionally rename it. - The FileCopy function duplicates a file and optionally renames it. - Since the PBHCopyFile routine is only available on some - AFP server volumes under specific conditions, this routine - either uses PBHCopyFile, or does all of the work PBHCopyFile - does. The srcVRefNum, srcDirID and srcName are used to - determine the location of the file to copy. The dstVRefNum - dstDirID and dstPathname are used to determine the location of - the destination directory. If copyName <> NIL, then it points - to the name of the new file. If copyBufferPtr <> NIL, it - points to a buffer of copyBufferSize that is used to copy - the file's data. The larger the supplied buffer, the - faster the copy. If copyBufferPtr = NIL, then this routine - allocates a buffer in the application heap. If you pass a - copy buffer to this routine, make its size a multiple of 512 - ($200) bytes for optimum performance. - - srcVRefNum input: Source volume specification. - srcDirID input: Source directory ID. - srcName input: Source file name. - dstVRefNum input: Destination volume specification. - dstDirID input: Destination directory ID. - dstPathname input: Pointer to destination directory name, or - nil when dstDirID specifies a directory. - copyName input: Points to the new file name if the file is - to be renamed or nil if the file isn't to - be renamed. - copyBufferPtr input: Points to a buffer of copyBufferSize that - is used the i/o buffer for the copy or - nil if you want FileCopy to allocate its - own buffer in the application heap. - copyBufferSize input: The size of the buffer pointed to - by copyBufferPtr. - preflight input: If true, FileCopy makes sure there are enough - allocation blocks on the destination volume to - hold both the data and resource forks before - starting the copy. - - Result Codes - noErr 0 No error - readErr Ð19 Driver does not respond to read requests - writErr Ð20 Driver does not respond to write requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - dskFulErr -34 Destination volume is full - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - tmfoErr -42 Too many files open - fnfErr -43 Source file not found, or destination - directory does not exist - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - fBsyErr -47 The source or destination file could - not be opened with the correct access - modes - dupFNErr -48 Destination file already exists - opWrErr -49 File already open for writing - paramErr -50 No default volume or function not - supported by volume - permErr -54 File is already open and cannot be opened using specified deny modes - memFullErr -108 Copy buffer could not be allocated - dirNFErr -120 Directory not found or incomplete pathname - wrgVolTypErr -123 Function not supported by volume - afpAccessDenied -5000 User does not have the correct access - afpDenyConflict -5006 The source or destination file could - not be opened with the correct access - modes - afpObjectTypeErr -5025 Source is a directory, directory not found - or incomplete pathname - - __________ - - Also see: FSpFileCopy, DirectoryCopy, FSpDirectoryCopy +EXTERN_API( OSErr ) +FileCopy( + short srcVRefNum, + long srcDirID, + ConstStr255Param srcName, + short dstVRefNum, + long dstDirID, + ConstStr255Param dstPathname, + ConstStr255Param copyName, + void * copyBufferPtr, + long copyBufferSize, + Boolean preflight); + + +/* + The FileCopy function duplicates a file and optionally renames it. + Since the PBHCopyFile routine is only available on some + AFP server volumes under specific conditions, this routine + either uses PBHCopyFile, or does all of the work PBHCopyFile + does. The srcVRefNum, srcDirID and srcName are used to + determine the location of the file to copy. The dstVRefNum + dstDirID and dstPathname are used to determine the location of + the destination directory. If copyName <> NIL, then it points + to the name of the new file. If copyBufferPtr <> NIL, it + points to a buffer of copyBufferSize that is used to copy + the file's data. The larger the supplied buffer, the + faster the copy. If copyBufferPtr = NIL, then this routine + allocates a buffer in the application heap. If you pass a + copy buffer to this routine, make its size a multiple of 512 + ($200) bytes for optimum performance. + + srcVRefNum input: Source volume specification. + srcDirID input: Source directory ID. + srcName input: Source file name. + dstVRefNum input: Destination volume specification. + dstDirID input: Destination directory ID. + dstPathname input: Pointer to destination directory name, or + nil when dstDirID specifies a directory. + copyName input: Points to the new file name if the file is + to be renamed or nil if the file isn't to + be renamed. + copyBufferPtr input: Points to a buffer of copyBufferSize that + is used the i/o buffer for the copy or + nil if you want FileCopy to allocate its + own buffer in the application heap. + copyBufferSize input: The size of the buffer pointed to + by copyBufferPtr. + preflight input: If true, FileCopy makes sure there are enough + allocation blocks on the destination volume to + hold both the data and resource forks before + starting the copy. + + Result Codes + noErr 0 No error + readErr Ð19 Driver does not respond to read requests + writErr Ð20 Driver does not respond to write requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + dskFulErr -34 Destination volume is full + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + tmfoErr -42 Too many files open + fnfErr -43 Source file not found, or destination + directory does not exist + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + fBsyErr -47 The source or destination file could + not be opened with the correct access + modes + dupFNErr -48 Destination file already exists + opWrErr -49 File already open for writing + paramErr -50 No default volume or function not + supported by volume + permErr -54 File is already open and cannot be opened using specified deny modes + memFullErr -108 Copy buffer could not be allocated + dirNFErr -120 Directory not found or incomplete pathname + wrgVolTypErr -123 Function not supported by volume + afpAccessDenied -5000 User does not have the correct access + afpDenyConflict -5006 The source or destination file could + not be opened with the correct access + modes + afpObjectTypeErr -5025 Source is a directory, directory not found + or incomplete pathname + + __________ + + Also see: FSpFileCopy, DirectoryCopy, FSpDirectoryCopy */ /*****************************************************************************/ -pascal OSErr FSpFileCopy(const FSSpec *srcSpec, - const FSSpec *dstSpec, - ConstStr255Param copyName, - void *copyBufferPtr, - long copyBufferSize, - Boolean preflight); -/* ¦ Duplicate a file and optionally rename it. - The FSpFileCopy function duplicates a file and optionally renames it. - Since the PBHCopyFile routine is only available on some - AFP server volumes under specific conditions, this routine - either uses PBHCopyFile, or does all of the work PBHCopyFile - does. The srcSpec is used to - determine the location of the file to copy. The dstSpec is - used to determine the location of the - destination directory. If copyName <> NIL, then it points - to the name of the new file. If copyBufferPtr <> NIL, it - points to a buffer of copyBufferSize that is used to copy - the file's data. The larger the supplied buffer, the - faster the copy. If copyBufferPtr = NIL, then this routine - allocates a buffer in the application heap. If you pass a - copy buffer to this routine, make its size a multiple of 512 - ($200) bytes for optimum performance. - - srcSpec input: An FSSpec record specifying the source file. - dstSpec input: An FSSpec record specifying the destination - directory. - copyName input: Points to the new file name if the file is - to be renamed or nil if the file isn't to - be renamed. - copyBufferPtr input: Points to a buffer of copyBufferSize that - is used the i/o buffer for the copy or - nil if you want FileCopy to allocate its - own buffer in the application heap. - copyBufferSize input: The size of the buffer pointed to - by copyBufferPtr. - preflight input: If true, FSpFileCopy makes sure there are - enough allocation blocks on the destination - volume to hold both the data and resource forks - before starting the copy. - - Result Codes - noErr 0 No error - readErr Ð19 Driver does not respond to read requests - writErr Ð20 Driver does not respond to write requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - dskFulErr -34 Destination volume is full - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - tmfoErr -42 Too many files open - fnfErr -43 Source file not found, or destination - directory does not exist - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - fBsyErr -47 The source or destination file could - not be opened with the correct access - modes - dupFNErr -48 Destination file already exists - opWrErr -49 File already open for writing - paramErr -50 No default volume or function not - supported by volume - permErr -54 File is already open and cannot be opened using specified deny modes - memFullErr -108 Copy buffer could not be allocated - dirNFErr -120 Directory not found or incomplete pathname - wrgVolTypErr -123 Function not supported by volume - afpAccessDenied -5000 User does not have the correct access - afpDenyConflict -5006 The source or destination file could - not be opened with the correct access - modes - afpObjectTypeErr -5025 Source is a directory, directory not found - or incomplete pathname - - __________ - - Also see: FileCopy, DirectoryCopy, FSpDirectoryCopy +EXTERN_API( OSErr ) +FSpFileCopy( + const FSSpec * srcSpec, + const FSSpec * dstSpec, + ConstStr255Param copyName, + void * copyBufferPtr, + long copyBufferSize, + Boolean preflight); + + +/* + The FSpFileCopy function duplicates a file and optionally renames it. + Since the PBHCopyFile routine is only available on some + AFP server volumes under specific conditions, this routine + either uses PBHCopyFile, or does all of the work PBHCopyFile + does. The srcSpec is used to + determine the location of the file to copy. The dstSpec is + used to determine the location of the + destination directory. If copyName <> NIL, then it points + to the name of the new file. If copyBufferPtr <> NIL, it + points to a buffer of copyBufferSize that is used to copy + the file's data. The larger the supplied buffer, the + faster the copy. If copyBufferPtr = NIL, then this routine + allocates a buffer in the application heap. If you pass a + copy buffer to this routine, make its size a multiple of 512 + ($200) bytes for optimum performance. + + srcSpec input: An FSSpec record specifying the source file. + dstSpec input: An FSSpec record specifying the destination + directory. + copyName input: Points to the new file name if the file is + to be renamed or nil if the file isn't to + be renamed. + copyBufferPtr input: Points to a buffer of copyBufferSize that + is used the i/o buffer for the copy or + nil if you want FileCopy to allocate its + own buffer in the application heap. + copyBufferSize input: The size of the buffer pointed to + by copyBufferPtr. + preflight input: If true, FSpFileCopy makes sure there are + enough allocation blocks on the destination + volume to hold both the data and resource forks + before starting the copy. + + Result Codes + noErr 0 No error + readErr Ð19 Driver does not respond to read requests + writErr Ð20 Driver does not respond to write requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + dskFulErr -34 Destination volume is full + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + tmfoErr -42 Too many files open + fnfErr -43 Source file not found, or destination + directory does not exist + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + fBsyErr -47 The source or destination file could + not be opened with the correct access + modes + dupFNErr -48 Destination file already exists + opWrErr -49 File already open for writing + paramErr -50 No default volume or function not + supported by volume + permErr -54 File is already open and cannot be opened using specified deny modes + memFullErr -108 Copy buffer could not be allocated + dirNFErr -120 Directory not found or incomplete pathname + wrgVolTypErr -123 Function not supported by volume + afpAccessDenied -5000 User does not have the correct access + afpDenyConflict -5006 The source or destination file could + not be opened with the correct access + modes + afpObjectTypeErr -5025 Source is a directory, directory not found + or incomplete pathname + + __________ + + Also see: FileCopy, DirectoryCopy, FSpDirectoryCopy */ /*****************************************************************************/ +#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 -#include "optimend.h" +#endif /* __FILECOPY__ */ -#endif /* __FILECOPY__ */ diff --git a/src/mac/morefile/FullPath.cpp b/src/mac/morefile/FullPath.c similarity index 58% rename from src/mac/morefile/FullPath.cpp rename to src/mac/morefile/FullPath.c index 7e54d6c5fa..32ccb9977b 100644 --- a/src/mac/morefile/FullPath.cpp +++ b/src/mac/morefile/FullPath.c @@ -1,35 +1,50 @@ /* -** Apple Macintosh Developer Technical Support -** -** Routines for dealing with full pathnames... if you really must. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: FullPath.c -** -** Copyright © 1995-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: FullPath.c + + Contains: Routines for dealing with full pathnames... if you really must. + + Version: MoreFiles + + Copyright: © 1995-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <2> 2/7/01 JL Added standard header. Updated names of includes. + <1> 12/06/99 JL MoreFiles 1.5. */ -#include -#include -#include +#include +#include +#include #include #include #include #define __COMPILINGMOREFILES -#include "fspcompa.h" -#include "fullpath.h" +#include "FSpCompat.h" +#include "FullPath.h" /* IMPORTANT NOTE: @@ -112,79 +127,88 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec, *fullPathLength = 0; *fullPath = NULL; - // Default to noErr - realResult = noErr; - /* Make a copy of the input FSSpec that can be modified */ - BlockMoveData(spec, &tempSpec, sizeof(FSSpec)); + /* Default to noErr */ + realResult = result = noErr; - if ( tempSpec.parID == fsRtParID ) + /* work around Nav Services "bug" (it returns invalid FSSpecs with empty names) */ + if ( spec->name[0] == 0 ) { - /* The object is a volume */ - - /* Add a colon to make it a full pathname */ - ++tempSpec.name[0]; - tempSpec.name[tempSpec.name[0]] = ':'; - - /* We're done */ - result = PtrToHand(&tempSpec.name[1], fullPath, tempSpec.name[0]); + result = FSMakeFSSpecCompat(spec->vRefNum, spec->parID, spec->name, &tempSpec); } else { - /* The object isn't a volume */ - - /* Is the object a file or a directory? */ - pb.dirInfo.ioNamePtr = tempSpec.name; - pb.dirInfo.ioVRefNum = tempSpec.vRefNum; - pb.dirInfo.ioDrDirID = tempSpec.parID; - pb.dirInfo.ioFDirIndex = 0; - result = PBGetCatInfoSync(&pb); - // Allow file/directory name at end of path to not exist. - realResult = result; - if ( (result == noErr) || (result == fnfErr) ) + /* Make a copy of the input FSSpec that can be modified */ + BlockMoveData(spec, &tempSpec, sizeof(FSSpec)); + } + + if ( result == noErr ) + { + if ( tempSpec.parID == fsRtParID ) { - /* if the object is a directory, append a colon so full pathname ends with colon */ - if ( (result == noErr) && (pb.hFileInfo.ioFlAttrib & ioDirMask) != 0 ) - { - ++tempSpec.name[0]; - tempSpec.name[tempSpec.name[0]] = ':'; - } + /* The object is a volume */ + + /* Add a colon to make it a full pathname */ + ++tempSpec.name[0]; + tempSpec.name[tempSpec.name[0]] = ':'; - /* Put the object name in first */ + /* We're done */ result = PtrToHand(&tempSpec.name[1], fullPath, tempSpec.name[0]); - if ( result == noErr ) + } + else + { + /* The object isn't a volume */ + + /* Is the object a file or a directory? */ + pb.dirInfo.ioNamePtr = tempSpec.name; + pb.dirInfo.ioVRefNum = tempSpec.vRefNum; + pb.dirInfo.ioDrDirID = tempSpec.parID; + pb.dirInfo.ioFDirIndex = 0; + result = PBGetCatInfoSync(&pb); + // Allow file/directory name at end of path to not exist. + realResult = result; + if ( (result == noErr) || (result == fnfErr) ) { - /* Get the ancestor directory names */ - pb.dirInfo.ioNamePtr = tempSpec.name; - pb.dirInfo.ioVRefNum = tempSpec.vRefNum; - pb.dirInfo.ioDrParID = tempSpec.parID; - do /* loop until we have an error or find the root directory */ + /* if the object is a directory, append a colon so full pathname ends with colon */ + if ( (result == noErr) && (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) + { + ++tempSpec.name[0]; + tempSpec.name[tempSpec.name[0]] = ':'; + } + + /* Put the object name in first */ + result = PtrToHand(&tempSpec.name[1], fullPath, tempSpec.name[0]); + if ( result == noErr ) { - pb.dirInfo.ioFDirIndex = -1; - pb.dirInfo.ioDrDirID = pb.dirInfo.ioDrParID; - result = PBGetCatInfoSync(&pb); - if ( result == noErr ) + /* Get the ancestor directory names */ + pb.dirInfo.ioNamePtr = tempSpec.name; + pb.dirInfo.ioVRefNum = tempSpec.vRefNum; + pb.dirInfo.ioDrParID = tempSpec.parID; + do /* loop until we have an error or find the root directory */ { - /* Append colon to directory name */ - ++tempSpec.name[0]; - tempSpec.name[tempSpec.name[0]] = ':'; - - /* Add directory name to beginning of fullPath */ - (void) Munger(*fullPath, 0, NULL, 0, &tempSpec.name[1], tempSpec.name[0]); - result = MemError(); - } - } while ( (result == noErr) && (pb.dirInfo.ioDrDirID != fsRtDirID) ); + pb.dirInfo.ioFDirIndex = -1; + pb.dirInfo.ioDrDirID = pb.dirInfo.ioDrParID; + result = PBGetCatInfoSync(&pb); + if ( result == noErr ) + { + /* Append colon to directory name */ + ++tempSpec.name[0]; + tempSpec.name[tempSpec.name[0]] = ':'; + + /* Add directory name to beginning of fullPath */ + (void) Munger(*fullPath, 0, NULL, 0, &tempSpec.name[1], tempSpec.name[0]); + result = MemError(); + } + } while ( (result == noErr) && (pb.dirInfo.ioDrDirID != fsRtDirID) ); + } } } } + if ( result == noErr ) { /* Return the length */ -#if TARGET_CARBON *fullPathLength = GetHandleSize(*fullPath); -#else - *fullPathLength = InlineGetHandleSize(*fullPath); -#endif result = realResult; // return realResult in case it was fnfErr } else @@ -220,6 +244,14 @@ pascal OSErr FSpLocationFromFullPath(short fullPathLength, /* Let the Alias Manager resolve the alias. */ result = ResolveAlias(NULL, alias, spec, &wasChanged); + /* work around Alias Mgr sloppy volume matching bug */ + if ( spec->vRefNum == 0 ) + { + /* invalidate wrong FSSpec */ + spec->parID = 0; + spec->name[0] = 0; + result = nsvErr; + } DisposeHandle((Handle)alias); /* Free up memory used */ } return ( result ); diff --git a/src/mac/morefile/FullPath.h b/src/mac/morefile/FullPath.h index cf18a9741c..e1710c12bc 100644 --- a/src/mac/morefile/FullPath.h +++ b/src/mac/morefile/FullPath.h @@ -1,243 +1,311 @@ /* -** Apple Macintosh Developer Technical Support -** -** Routines for dealing with full pathnames... if you really must. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: FullPath.h -** -** Copyright © 1995-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: FullPath.h + + Contains: Routines for dealing with full pathnames... if you really must. + + Version: Technology: MoreFiles + Release: 1.5.2 + + Copyright: © 1995-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. +*/ + +/* + IMPORTANT NOTE: + + The use of full pathnames is strongly discouraged. Full pathnames are + particularly unreliable as a means of identifying files, directories + or volumes within your application, for two primary reasons: + + ¥ The user can change the name of any element in the path at + virtually any time. + ¥ Volume names on the Macintosh are *not* unique. Multiple + mounted volumes can have the same name. For this reason, the use of + a full pathname to identify a specific volume may not produce the + results you expect. If more than one volume has the same name and + a full pathname is used, the File Manager currently uses the first + mounted volume it finds with a matching name in the volume queue. + + In general, you should use a fileÕs name, parent directory ID, and + volume reference number to identify a file you want to open, delete, + or otherwise manipulate. + + If you need to remember the location of a particular file across + subsequent system boots, use the Alias Manager to create an alias + record describing the file. If the Alias Manager is not available, you + can save the fileÕs name, its parent directory ID, and the name of the + volume on which itÕs located. Although none of these methods is + foolproof, they are much more reliable than using full pathnames to + identify files. + + Nonetheless, it is sometimes useful to display a fileÕs full pathname + to the user. For example, a backup utility might display a list of full + pathnames of files as it copies them onto the backup medium. Or, a + utility might want to display a dialog box showing the full pathname of + a file when it needs the userÕs confirmation to delete the file. No + matter how unreliable full pathnames may be from a file-specification + viewpoint, users understand them more readily than volume reference + numbers or directory IDs. (Hint: Use the TruncString function from + TextUtils.h with truncMiddle as the truncWhere argument to shorten + full pathnames to a displayable length.) + + The following technique for constructing the full pathname of a file is + intended for display purposes only. Applications that depend on any + particular structure of a full pathname are likely to fail on alternate + foreign file systems or under future system software versions. */ #ifndef __FULLPATH__ #define __FULLPATH__ -#include +#ifndef __MACTYPES__ +#include +#endif + +#ifndef __FILES__ #include +#endif -#include "optim.h" +#include "Optimization.h" + + +#if PRAGMA_ONCE +#pragma once +#endif #ifdef __cplusplus extern "C" { #endif -/* - IMPORTANT NOTE: - - The use of full pathnames is strongly discouraged. Full pathnames are - particularly unreliable as a means of identifying files, directories - or volumes within your application, for two primary reasons: - - ¥ The user can change the name of any element in the path at - virtually any time. - ¥ Volume names on the Macintosh are *not* unique. Multiple - mounted volumes can have the same name. For this reason, the use of - a full pathname to identify a specific volume may not produce the - results you expect. If more than one volume has the same name and - a full pathname is used, the File Manager currently uses the first - mounted volume it finds with a matching name in the volume queue. - - In general, you should use a fileÕs name, parent directory ID, and - volume reference number to identify a file you want to open, delete, - or otherwise manipulate. - - If you need to remember the location of a particular file across - subsequent system boots, use the Alias Manager to create an alias - record describing the file. If the Alias Manager is not available, you - can save the fileÕs name, its parent directory ID, and the name of the - volume on which itÕs located. Although none of these methods is - foolproof, they are much more reliable than using full pathnames to - identify files. - - Nonetheless, it is sometimes useful to display a fileÕs full pathname - to the user. For example, a backup utility might display a list of full - pathnames of files as it copies them onto the backup medium. Or, a - utility might want to display a dialog box showing the full pathname of - a file when it needs the userÕs confirmation to delete the file. No - matter how unreliable full pathnames may be from a file-specification - viewpoint, users understand them more readily than volume reference - numbers or directory IDs. (Hint: Use the TruncString function from - TextUtils.h with truncMiddle as the truncWhere argument to shorten - full pathnames to a displayable length.) - - The following technique for constructing the full pathname of a file is - intended for display purposes only. Applications that depend on any - particular structure of a full pathname are likely to fail on alternate - foreign file systems or under future system software versions. -*/ +#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 /*****************************************************************************/ -pascal OSErr GetFullPath(short vRefNum, - long dirID, - ConstStr255Param name, - short *fullPathLength, - Handle *fullPath); -/* ¦ Get a full pathname to a volume, directory or file. - The GetFullPath function builds a full pathname to the specified - object. The full pathname is returned in the newly created handle - fullPath and the length of the full pathname is returned in - fullPathLength. Your program is responsible for disposing of the - fullPath handle. - - Note that a full pathname can be made to a file/directory that does not - yet exist if all directories up to that file/directory exist. In this case, - GetFullPath will return a fnfErr. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - fullPathLength output: The number of characters in the full pathname. - If the function fails to create a full - pathname, it sets fullPathLength to 0. - fullPath output: A handle to the newly created full pathname - buffer. If the function fails to create a - full pathname, it sets fullPath to NULL. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - fnfErr -43 File or directory does not exist (fullPath - and fullPathLength are still valid) - paramErr -50 No default volume - memFullErr -108 Not enough memory - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpGetFullPath +EXTERN_API( OSErr ) +GetFullPath( + short vRefNum, + long dirID, + ConstStr255Param name, + short * fullPathLength, + Handle * fullPath); + + +/* + The GetFullPath function builds a full pathname to the specified + object. The full pathname is returned in the newly created handle + fullPath and the length of the full pathname is returned in + fullPathLength. Your program is responsible for disposing of the + fullPath handle. + + Note that a full pathname can be made to a file/directory that does not + yet exist if all directories up to that file/directory exist. In this case, + GetFullPath will return a fnfErr. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + fullPathLength output: The number of characters in the full pathname. + If the function fails to create a full + pathname, it sets fullPathLength to 0. + fullPath output: A handle to the newly created full pathname + buffer. If the function fails to create a + full pathname, it sets fullPath to NULL. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + fnfErr -43 File or directory does not exist (fullPath + and fullPathLength are still valid) + paramErr -50 No default volume + memFullErr -108 Not enough memory + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpGetFullPath */ /*****************************************************************************/ -pascal OSErr FSpGetFullPath(const FSSpec *spec, - short *fullPathLength, - Handle *fullPath); -/* ¦ Get a full pathname to a volume, directory or file. - The GetFullPath function builds a full pathname to the specified - object. The full pathname is returned in the newly created handle - fullPath and the length of the full pathname is returned in - fullPathLength. Your program is responsible for disposing of the - fullPath handle. - - Note that a full pathname can be made to a file/directory that does not - yet exist if all directories up to that file/directory exist. In this case, - FSpGetFullPath will return a fnfErr. - - spec input: An FSSpec record specifying the object. - fullPathLength output: The number of characters in the full pathname. - If the function fails to create a full pathname, - it sets fullPathLength to 0. - fullPath output: A handle to the newly created full pathname - buffer. If the function fails to create a - full pathname, it sets fullPath to NULL. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - fnfErr -43 File or directory does not exist (fullPath - and fullPathLength are still valid) - paramErr -50 No default volume - memFullErr -108 Not enough memory - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: GetFullPath +EXTERN_API( OSErr ) +FSpGetFullPath( + const FSSpec * spec, + short * fullPathLength, + Handle * fullPath); + + +/* + The GetFullPath function builds a full pathname to the specified + object. The full pathname is returned in the newly created handle + fullPath and the length of the full pathname is returned in + fullPathLength. Your program is responsible for disposing of the + fullPath handle. + + Note that a full pathname can be made to a file/directory that does not + yet exist if all directories up to that file/directory exist. In this case, + FSpGetFullPath will return a fnfErr. + + IMPORTANT: The definition of a FSSpec is a volume reference number (not a + drive number, working directory number, or 0), a parent directory ID (not 0), + and the name of a file or folder (not an empty name, a full pathname, or + a partial pathname containing one or more colon (:) characters). + FSpGetFullPath assumes it is getting a FSSpec that matches the rules. + If you have an FSSpec record that wasn't created by FSMakeFSSpec (or + FSMakeFSSpecCompat from FSpCompat in MoreFiles which correctly builds + FSSpecs), you should call GetFullPath instead of FSpGetFullPath. + + spec input: An FSSpec record specifying the object. + fullPathLength output: The number of characters in the full pathname. + If the function fails to create a full pathname, + it sets fullPathLength to 0. + fullPath output: A handle to the newly created full pathname + buffer. If the function fails to create a + full pathname, it sets fullPath to NULL. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + fnfErr -43 File or directory does not exist (fullPath + and fullPathLength are still valid) + paramErr -50 No default volume + memFullErr -108 Not enough memory + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: GetFullPath */ /*****************************************************************************/ -pascal OSErr FSpLocationFromFullPath(short fullPathLength, - const void *fullPath, - FSSpec *spec); -/* ¦ Get a FSSpec from a full pathname. - The FSpLocationFromFullPath function returns a FSSpec to the object - specified by full pathname. This function requires the Alias Manager. - - fullPathLength input: The number of characters in the full pathname - of the target. - fullPath input: A pointer to a buffer that contains the full - pathname of the target. The full pathname - starts with the name of the volume, includes - all of the directory names in the path to the - target, and ends with the target name. - spec output: An FSSpec record specifying the object. - - Result Codes - noErr 0 No error - nsvErr -35 The volume is not mounted - fnfErr -43 Target not found, but volume and parent - directory found - paramErr -50 Parameter error - usrCanceledErr -128 The user canceled the operation - - __________ - - See also: LocationFromFullPath +EXTERN_API( OSErr ) +FSpLocationFromFullPath( + short fullPathLength, + const void * fullPath, + FSSpec * spec); + + +/* + The FSpLocationFromFullPath function returns a FSSpec to the object + specified by full pathname. This function requires the Alias Manager. + + fullPathLength input: The number of characters in the full pathname + of the target. + fullPath input: A pointer to a buffer that contains the full + pathname of the target. The full pathname + starts with the name of the volume, includes + all of the directory names in the path to the + target, and ends with the target name. + spec output: An FSSpec record specifying the object. + + Result Codes + noErr 0 No error + nsvErr -35 The volume is not mounted + fnfErr -43 Target not found, but volume and parent + directory found + paramErr -50 Parameter error + usrCanceledErr -128 The user canceled the operation + + __________ + + See also: LocationFromFullPath */ /*****************************************************************************/ -pascal OSErr LocationFromFullPath(short fullPathLength, - const void *fullPath, - short *vRefNum, - long *parID, - Str31 name); -/* ¦ Get an object's location from a full pathname. - The LocationFromFullPath function returns the volume reference number, - parent directory ID and name of the object specified by full pathname. - This function requires the Alias Manager. - - fullPathLength input: The number of characters in the full pathname - of the target. - fullPath input: A pointer to a buffer that contains the full - pathname of the target. The full pathname starts - with the name of the volume, includes all of - the directory names in the path to the target, - and ends with the target name. - vRefNum output: The volume reference number. - parID output: The parent directory ID of the specified object. - name output: The name of the specified object. - - Result Codes - noErr 0 No error - nsvErr -35 The volume is not mounted - fnfErr -43 Target not found, but volume and parent - directory found - paramErr -50 Parameter error - usrCanceledErr -128 The user canceled the operation - - __________ - - See also: FSpLocationFromFullPath +EXTERN_API( OSErr ) +LocationFromFullPath( + short fullPathLength, + const void * fullPath, + short * vRefNum, + long * parID, + Str31 name); + + +/* + The LocationFromFullPath function returns the volume reference number, + parent directory ID and name of the object specified by full pathname. + This function requires the Alias Manager. + + fullPathLength input: The number of characters in the full pathname + of the target. + fullPath input: A pointer to a buffer that contains the full + pathname of the target. The full pathname starts + with the name of the volume, includes all of + the directory names in the path to the target, + and ends with the target name. + vRefNum output: The volume reference number. + parID output: The parent directory ID of the specified object. + name output: The name of the specified object. + + Result Codes + noErr 0 No error + nsvErr -35 The volume is not mounted + fnfErr -43 Target not found, but volume and parent + directory found + paramErr -50 Parameter error + usrCanceledErr -128 The user canceled the operation + + __________ + + See also: FSpLocationFromFullPath */ /*****************************************************************************/ +#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 -#include "optimend.h" +#endif /* __FULLPATH__ */ -#endif /* __FULLPATH__ */ \ No newline at end of file diff --git a/src/mac/morefile/IterateD.h b/src/mac/morefile/IterateD.h deleted file mode 100644 index 46fafb9fe1..0000000000 --- a/src/mac/morefile/IterateD.h +++ /dev/null @@ -1,171 +0,0 @@ -/* -** IterateDirectory: File Manager directory iterator routines. -** -** by Jim Luther -** -** File: IterateDirectory.h -** -** Copyright © 1995-1998 Jim Luther and Apple Computer, Inc. -** All rights reserved. -** -** 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. -** -** IterateDirectory is designed to drop into the MoreFiles sample code -** library I wrote while in Apple Developer Technical Support -*/ - -#ifndef __ITERATEDIRECTORY__ -#define __ITERATEDIRECTORY__ - -#include -#include - -#include "optim.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************************/ - -typedef pascal void (*IterateFilterProcPtr) (const CInfoPBRec * const cpbPtr, - Boolean *quitFlag, - void *yourDataPtr); -/* ¦ Prototype for the IterateFilterProc function IterateDirectory calls. - This is the prototype for the IterateFilterProc function which is - called once for each file and directory found by IterateDirectory. The - IterateFilterProc gets a pointer to the CInfoPBRec that IterateDirectory - used to call PBGetCatInfo. The IterateFilterProc can use the read-only - data in the CInfoPBRec for whatever it wants. - - If the IterateFilterProc wants to stop IterateDirectory, it can set - quitFlag to true (quitFlag will be passed to the IterateFilterProc - false). - - The yourDataPtr parameter can point to whatever data structure you might - want to access from within the IterateFilterProc. - - cpbPtr input: A pointer to the CInfoPBRec that IterateDirectory - used to call PBGetCatInfo. The CInfoPBRec and the - data it points to must not be changed by your - IterateFilterProc. - quitFlag output: Your IterateFilterProc can set quitFlag to true - if it wants to stop IterateDirectory. - yourDataPtr input: A pointer to whatever data structure you might - want to access from within the IterateFilterProc. - - __________ - - Also see: IterateDirectory, FSpIterateDirectory -*/ - -#define CallIterateFilterProc(userRoutine, cpbPtr, quitFlag, yourDataPtr) \ - (*(userRoutine))((cpbPtr), (quitFlag), (yourDataPtr)) - -/*****************************************************************************/ - -pascal OSErr IterateDirectory(short vRefNum, - long dirID, - ConstStr255Param name, - unsigned short maxLevels, - IterateFilterProcPtr iterateFilter, - void *yourDataPtr); -/* ¦ Iterate (scan) through a directory's content. - The IterateDirectory function performs a recursive iteration (scan) of - the specified directory and calls your IterateFilterProc function once - for each file and directory found. - - The maxLevels parameter lets you control how deep the recursion goes. - If maxLevels is 1, IterateDirectory only scans the specified directory; - if maxLevels is 2, IterateDirectory scans the specified directory and - one subdirectory below the specified directory; etc. Set maxLevels to - zero to scan all levels. - - The yourDataPtr parameter can point to whatever data structure you might - want to access from within the IterateFilterProc. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - maxLevels input: Maximum number of directory levels to scan or - zero to scan all directory levels. - iterateFilter input: A pointer to the routine you want called once - for each file and directory found by - IterateDirectory. - yourDataPtr input: A pointer to whatever data structure you might - want to access from within the IterateFilterProc. - - 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 or iterateFilter was NULL - dirNFErr -120 Directory not found or incomplete pathname - or a file was passed instead of a directory - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: IterateFilterProcPtr, FSpIterateDirectory -*/ - -/*****************************************************************************/ - -pascal OSErr FSpIterateDirectory(const FSSpec *spec, - unsigned short maxLevels, - IterateFilterProcPtr iterateFilter, - void *yourDataPtr); -/* ¦ Iterate (scan) through a directory's content. - The FSpIterateDirectory function performs a recursive iteration (scan) - of the specified directory and calls your IterateFilterProc function once - for each file and directory found. - - The maxLevels parameter lets you control how deep the recursion goes. - If maxLevels is 1, FSpIterateDirectory only scans the specified directory; - if maxLevels is 2, FSpIterateDirectory scans the specified directory and - one subdirectory below the specified directory; etc. Set maxLevels to - zero to scan all levels. - - The yourDataPtr parameter can point to whatever data structure you might - want to access from within the IterateFilterProc. - - spec input: An FSSpec record specifying the directory to scan. - maxLevels input: Maximum number of directory levels to scan or - zero to scan all directory levels. - iterateFilter input: A pointer to the routine you want called once - for each file and directory found by - FSpIterateDirectory. - yourDataPtr input: A pointer to whatever data structure you might - want to access from within the IterateFilterProc. - - 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 or iterateFilter was NULL - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: IterateFilterProcPtr, IterateDirectory -*/ - -/*****************************************************************************/ - -#ifdef __cplusplus -} -#endif - -#include "optimend.h" - -#endif /* __ITERATEDIRECTORY__ */ diff --git a/src/mac/morefile/IterateD.cpp b/src/mac/morefile/IterateDirectory.c similarity index 79% rename from src/mac/morefile/IterateD.cpp rename to src/mac/morefile/IterateDirectory.c index 4786b80c01..e748829ff5 100644 --- a/src/mac/morefile/IterateD.cpp +++ b/src/mac/morefile/IterateDirectory.c @@ -1,29 +1,47 @@ /* -** IterateDirectory: File Manager directory iterator routines. -** -** by Jim Luther -** -** File: IterateDirectory.c -** -** Copyright © 1995-1998 Jim Luther and Apple Computer, Inc. -** All rights reserved. -** -** 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. -** -** IterateDirectory is designed to drop into the MoreFiles sample code -** library I wrote while in Apple Developer Technical Support + File: IterateDirectory.c + + Contains: File Manager directory iterator routines. + + Version: MoreFiles + + Copyright: © 1995-2001 by Jim Luther and Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <2> 2/7/01 JL Added standard header. Updated names of includes. + <1> 12/06/99 JL MoreFiles 1.5. */ -#include -#include +#include +#include #include #define __COMPILINGMOREFILES -#include "moreextr.h" -#include "iterated.h" +#include "MoreFilesExtras.h" +#include "IterateDirectory.h" /* ** Type definitions @@ -34,13 +52,8 @@ ** and to hold global information that might be needed at any time. */ #if PRAGMA_STRUCT_ALIGN - #pragma options align=mac68k -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(push, 2) -#elif PRAGMA_STRUCT_PACK - #pragma pack(2) +#pragma options align=mac68k #endif - struct IterateGlobals { IterateFilterProcPtr iterateFilter; /* pointer to IterateFilterProc */ @@ -52,13 +65,8 @@ struct IterateGlobals unsigned short currentLevel; /* The current level IterateLevel is on */ void *yourDataPtr; /* A pointer to caller data the filter may need to access */ }; - #if PRAGMA_STRUCT_ALIGN - #pragma options align=reset -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(pop) -#elif PRAGMA_STRUCT_PACK - #pragma pack() +#pragma options align=reset #endif typedef struct IterateGlobals IterateGlobals; @@ -102,7 +110,7 @@ static void IterateDirectoryLevel(long dirID, CallIterateFilterProc(theGlobals->iterateFilter, &theGlobals->cPB, &theGlobals->quitFlag, theGlobals->yourDataPtr); /* Is it a directory? */ - if ( (theGlobals->cPB.hFileInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (theGlobals->cPB.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* We have a directory */ if ( !theGlobals->quitFlag ) diff --git a/src/mac/morefile/IterateDirectory.h b/src/mac/morefile/IterateDirectory.h new file mode 100644 index 0000000000..ef6b113eea --- /dev/null +++ b/src/mac/morefile/IterateDirectory.h @@ -0,0 +1,222 @@ +/* + File: IterateDirectory.h + + Contains: File Manager directory iterator routines. + + Version: Technology: MoreFiles + Release: 1.5.2 + + Copyright: © 1995-2001 by Jim Luther and 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 __ITERATEDIRECTORY__ +#define __ITERATEDIRECTORY__ + +#ifndef __MACTYPES__ +#include +#endif + +#ifndef __FILES__ +#include +#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 + +/*****************************************************************************/ + +typedef CALLBACK_API( void , IterateFilterProcPtr )(const CInfoPBRec *cpbPtr, Boolean *quitFlag, void *yourDataPtr); +/* + This is the prototype for the IterateFilterProc function which is + called once for each file and directory found by IterateDirectory. The + IterateFilterProc gets a pointer to the CInfoPBRec that IterateDirectory + used to call PBGetCatInfo. The IterateFilterProc can use the read-only + data in the CInfoPBRec for whatever it wants. + + If the IterateFilterProc wants to stop IterateDirectory, it can set + quitFlag to true (quitFlag will be passed to the IterateFilterProc + false). + + The yourDataPtr parameter can point to whatever data structure you might + want to access from within the IterateFilterProc. + + cpbPtr input: A pointer to the CInfoPBRec that IterateDirectory + used to call PBGetCatInfo. The CInfoPBRec and the + data it points to must not be changed by your + IterateFilterProc. + quitFlag output: Your IterateFilterProc can set quitFlag to true + if it wants to stop IterateDirectory. + yourDataPtr input: A pointer to whatever data structure you might + want to access from within the IterateFilterProc. + + __________ + + Also see: IterateDirectory, FSpIterateDirectory +*/ +#define CallIterateFilterProc(userRoutine, cpbPtr, quitFlag, yourDataPtr) \ + (*(userRoutine))((cpbPtr), (quitFlag), (yourDataPtr)) + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +IterateDirectory( + short vRefNum, + long dirID, + ConstStr255Param name, + unsigned short maxLevels, + IterateFilterProcPtr iterateFilter, + void * yourDataPtr); + + +/* + The IterateDirectory function performs a recursive iteration (scan) of + the specified directory and calls your IterateFilterProc function once + for each file and directory found. + + The maxLevels parameter lets you control how deep the recursion goes. + If maxLevels is 1, IterateDirectory only scans the specified directory; + if maxLevels is 2, IterateDirectory scans the specified directory and + one subdirectory below the specified directory; etc. Set maxLevels to + zero to scan all levels. + + The yourDataPtr parameter can point to whatever data structure you might + want to access from within the IterateFilterProc. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + maxLevels input: Maximum number of directory levels to scan or + zero to scan all directory levels. + iterateFilter input: A pointer to the routine you want called once + for each file and directory found by + IterateDirectory. + yourDataPtr input: A pointer to whatever data structure you might + want to access from within the IterateFilterProc. + + 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 or iterateFilter was NULL + dirNFErr -120 Directory not found or incomplete pathname + or a file was passed instead of a directory + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: IterateFilterProcPtr, FSpIterateDirectory +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpIterateDirectory( + const FSSpec * spec, + unsigned short maxLevels, + IterateFilterProcPtr iterateFilter, + void * yourDataPtr); + + +/* + The FSpIterateDirectory function performs a recursive iteration (scan) + of the specified directory and calls your IterateFilterProc function once + for each file and directory found. + + The maxLevels parameter lets you control how deep the recursion goes. + If maxLevels is 1, FSpIterateDirectory only scans the specified directory; + if maxLevels is 2, FSpIterateDirectory scans the specified directory and + one subdirectory below the specified directory; etc. Set maxLevels to + zero to scan all levels. + + The yourDataPtr parameter can point to whatever data structure you might + want to access from within the IterateFilterProc. + + spec input: An FSSpec record specifying the directory to scan. + maxLevels input: Maximum number of directory levels to scan or + zero to scan all directory levels. + iterateFilter input: A pointer to the routine you want called once + for each file and directory found by + FSpIterateDirectory. + yourDataPtr input: A pointer to whatever data structure you might + want to access from within the IterateFilterProc. + + 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 or iterateFilter was NULL + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: IterateFilterProcPtr, IterateDirectory +*/ + +/*****************************************************************************/ + +#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 /* __ITERATEDIRECTORY__ */ + diff --git a/src/mac/morefile/MoreDesk.h b/src/mac/morefile/MoreDesk.h deleted file mode 100644 index ee8dbb4f80..0000000000 --- a/src/mac/morefile/MoreDesk.h +++ /dev/null @@ -1,541 +0,0 @@ -/* -** Apple Macintosh Developer Technical Support -** -** A collection of useful high-level Desktop Manager routines. -** If the Desktop Manager isn't available, use the Desktop file -** for 'read' operations. -** -** We do more because we can... -** -** by Jim Luther and Nitin Ganatra, Apple Developer Technical Support Emeriti -** -** File: MoreDesktopMgr.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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 __MOREDESKTOPMGR__ -#define __MOREDESKTOPMGR__ - -#include -#include - -#include "optim.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************************/ - -pascal OSErr DTOpen(ConstStr255Param volName, - short vRefNum, - short *dtRefNum, - Boolean *newDTDatabase); -/* ¦ Open a volume's desktop database and return the desktop database refNum. - The DTOpen function opens a volume's desktop database. It returns - the reference number of the desktop database and indicates if the - desktop database was created as a result of this call (if it was created, - then it is empty). - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - dtRefNum output: The reference number of Desktop Manager's - desktop database on the specified volume. - newDTDatabase output: true if the desktop database was created as a - result of this call and thus empty. - false if the desktop database was already created, - or if it could not be determined if it was already - created. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - paramErr -50 Volume doesn't support this function - extFSErr -58 External file system error - no file - system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete -*/ - -/*****************************************************************************/ - -pascal OSErr DTXGetAPPL(ConstStr255Param volName, - short vRefNum, - OSType creator, - Boolean searchCatalog, - short *applVRefNum, - long *applParID, - Str255 applName); -/* ¦ Find an application on a volume that can open a file with a given creator. - The DTXGetAPPL function finds an application (file type 'APPL') with - the specified creator on the specified volume. It first tries to get - the application mapping from the desktop database. If that fails, - then it tries to find an application in the Desktop file. If that - fails and searchCatalog is true, then it tries to find an application - with the specified creator using the File Manager's CatSearch routine. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - creator input: The file's creator type. - searchCatalog input: If true, search the catalog for the application - if it isn't found in the desktop database. - applVRefNum output: The volume reference number of the volume the - application is on. - applParID output: The parent directory ID of the application. - applName output: The name of the application. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - paramErr -50 No default volume - rfNumErr -51 Reference number invalid - extFSErr -58 External file system error - no file - system claimed this call - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - afpItemNotFound -5012 Information not found - - __________ - - Also see: FSpDTGetAPPL -*/ - -/*****************************************************************************/ - -pascal OSErr FSpDTXGetAPPL(ConstStr255Param volName, - short vRefNum, - OSType creator, - Boolean searchCatalog, - FSSpec *spec); -/* ¦ Find an application on a volume that can open a file with a given creator. - The FSpDTXGetAPPL function finds an application (file type 'APPL') with - the specified creator on the specified volume. It first tries to get - the application mapping from the desktop database. If that fails, - then it tries to find an application in the Desktop file. If that - fails and searchCatalog is true, then it tries to find an application - with the specified creator using the File Manager's CatSearch routine. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - creator input: The file's creator type. - searchCatalog input: If true, search the catalog for the application - if it isn't found in the desktop database. - spec output: FSSpec record containing the application name and - location. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - paramErr -50 No default volume - rfNumErr -51 Reference number invalid - extFSErr -58 External file system error - no file - system claimed this call - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - afpItemNotFound -5012 Information not found - - __________ - - Also see: FSpDTGetAPPL -*/ - -/*****************************************************************************/ - -pascal OSErr DTGetAPPL(ConstStr255Param volName, - short vRefNum, - OSType creator, - short *applVRefNum, - long *applParID, - Str255 applName); -/* ¦ Find an application on a volume that can open a file with a given creator. - The DTGetAPPL function finds an application (file type 'APPL') with - the specified creator on the specified volume. It first tries to get - the application mapping from the desktop database. If that fails, - then it tries to find an application in the Desktop file. If that - fails, then it tries to find an application with the specified creator - using the File Manager's CatSearch routine. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - creator input: The file's creator type. - applVRefNum output: The volume reference number of the volume the - application is on. - applParID output: The parent directory ID of the application. - applName output: The name of the application. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - paramErr -50 No default volume - rfNumErr -51 Reference number invalid - extFSErr -58 External file system error - no file - system claimed this call - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - afpItemNotFound -5012 Information not found - - __________ - - Also see: FSpDTGetAPPL -*/ - -/*****************************************************************************/ - -pascal OSErr FSpDTGetAPPL(ConstStr255Param volName, - short vRefNum, - OSType creator, - FSSpec *spec); -/* ¦ Find an application on a volume that can open a file with a given creator. - The FSpDTGetAPPL function finds an application (file type 'APPL') with - the specified creator on the specified volume. It first tries to get - the application mapping from the desktop database. If that fails, - then it tries to find an application in the Desktop file. If that - fails, then it tries to find an application with the specified creator - using the File Manager's CatSearch routine. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - creator input: The file's creator type. - spec output: FSSpec record containing the application name and - location. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - paramErr -50 No default volume - rfNumErr -51 Reference number invalid - extFSErr -58 External file system error - no file - system claimed this call - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - afpItemNotFound -5012 Information not found - - __________ - - Also see: DTGetAPPL -*/ - -/*****************************************************************************/ - -pascal OSErr DTGetIcon(ConstStr255Param volName, - short vRefNum, - short iconType, - OSType fileCreator, - OSType fileType, - Handle *iconHandle); -/* ¦ Get an icon from the desktop database or Desktop file. - The DTGetIcon function retrieves the specified icon and returns it in - a newly created handle. The icon is retrieves from the Desktop Manager - or if the Desktop Manager is not available, from the Finder's Desktop - file. Your program is responsible for disposing of the handle when it is - done using the icon. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - iconType input: The icon type as defined in Files.h. Valid values are: - kLargeIcon - kLarge4BitIcon - kLarge8BitIcon - kSmallIcon - kSmall4BitIcon - kSmall8BitIcon - fileCreator input: The icon's creator type. - fileType input: The icon's file type. - iconHandle output: A Handle containing the newly created icon. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - paramErr -50 Volume doesn't support this function - rfNumErr -51 Reference number invalid - extFSErr -58 External file system error - no file - system claimed this call - memFullErr -108 iconHandle could not be allocated - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - afpItemNotFound -5012 Information not found -*/ - -/*****************************************************************************/ - -pascal OSErr DTSetComment(short vRefNum, - long dirID, - ConstStr255Param name, - ConstStr255Param comment); -/* ¦ Set a file or directory's Finder comment field. - The DTSetComment function sets a file or directory's Finder comment - field. The volume must support the Desktop Manager because you only - have read access to the Desktop file. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - comment input: The comment to add. Comments are limited to 200 characters; - longer comments are truncated. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr Ð43 File or directory doesnÕt exist - paramErr -50 Volume doesn't support this function - wPrErr Ð44 Volume is locked through hardware - vLckdErr Ð46 Volume is locked through software - rfNumErr Ð51 Reference number invalid - extFSErr -58 External file system error - no file - system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - - __________ - - Also see: DTCopyComment, FSpDTCopyComment, FSpDTSetComment, DTGetComment, - FSpDTGetComment -*/ - -/*****************************************************************************/ - -pascal OSErr FSpDTSetComment(const FSSpec *spec, - ConstStr255Param comment); -/* ¦ Set a file or directory's Finder comment field. - The FSpDTSetComment function sets a file or directory's Finder comment - field. The volume must support the Desktop Manager because you only - have read access to the Desktop file. - - spec input: An FSSpec record specifying the file or directory. - comment input: The comment to add. Comments are limited to 200 characters; - longer comments are truncated. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr Ð43 File or directory doesnÕt exist - wPrErr Ð44 Volume is locked through hardware - vLckdErr Ð46 Volume is locked through software - rfNumErr Ð51 Reference number invalid - paramErr -50 Volume doesn't support this function - extFSErr -58 External file system error - no file - system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - - __________ - - Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, DTGetComment, - FSpDTGetComment -*/ - -/*****************************************************************************/ - -pascal OSErr DTGetComment(short vRefNum, - long dirID, - ConstStr255Param name, - Str255 comment); -/* ¦ Get a file or directory's Finder comment field (if any). - The DTGetComment function gets a file or directory's Finder comment - field (if any) from the Desktop Manager or if the Desktop Manager is - not available, from the Finder's Desktop file. - - IMPORTANT NOTE: Inside Macintosh says that comments are up to - 200 characters. While that may be correct for the HFS file system's - Desktop Manager, other file systems (such as Apple Photo Access) return - up to 255 characters. Make sure the comment buffer is a Str255 or you'll - regret it. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - comment output: A Str255 where the comment is to be returned. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr -43 File not found - paramErr -50 Volume doesn't support this function - rfNumErr Ð51 Reference number invalid - extFSErr -58 External file system error - no file - system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - afpItemNotFound -5012 Information not found - - __________ - - Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment, - FSpDTGetComment -*/ - -/*****************************************************************************/ - -pascal OSErr FSpDTGetComment(const FSSpec *spec, - Str255 comment); -/* ¦ Get a file or directory's Finder comment field (if any). - The FSpDTGetComment function gets a file or directory's Finder comment - field (if any) from the Desktop Manager or if the Desktop Manager is - not available, from the Finder's Desktop file. - - IMPORTANT NOTE: Inside Macintosh says that comments are up to - 200 characters. While that may be correct for the HFS file system's - Desktop Manager, other file systems (such as Apple Photo Access) return - up to 255 characters. Make sure the comment buffer is a Str255 or you'll - regret it. - - spec input: An FSSpec record specifying the file or directory. - comment output: A Str255 where the comment is to be returned. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr -43 File not found - paramErr -50 Volume doesn't support this function - rfNumErr Ð51 Reference number invalid - extFSErr -58 External file system error - no file - system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - afpItemNotFound -5012 Information not found - - __________ - - Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment, - DTGetComment -*/ - -/*****************************************************************************/ - -pascal OSErr DTCopyComment(short srcVRefNum, - long srcDirID, - ConstStr255Param srcName, - short dstVRefNum, - long dstDirID, - ConstStr255Param dstName); -/* ¦ Copy the file or folder comment from the source to the destination object. - The DTCopyComment function copies the file or folder comment from the - source to the destination object. The destination volume must support - the Desktop Manager because you only have read access to the Desktop file. - - srcVRefNum input: Source volume specification. - srcDirID input: Source directory ID. - srcName input: Pointer to source object name, or nil when srcDirID - specifies a directory that's the object. - dstVRefNum input: Destination volume specification. - dstDirID input: Destination directory ID. - dstName input: Pointer to destination object name, or nil when - dstDirID specifies a directory that's the object. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr Ð43 File or directory doesnÕt exist - wPrErr Ð44 Volume is locked through hardware - vLckdErr Ð46 Volume is locked through software - paramErr -50 Volume doesn't support this function - rfNumErr Ð51 Reference number invalid - paramErr -50 Volume doesn't support this function - extFSErr -58 External file system error - no file - system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - afpItemNotFound -5012 Information not found - - __________ - - Also see: FSpDTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment, - FSpDTGetComment -*/ - -/*****************************************************************************/ - -pascal OSErr FSpDTCopyComment(const FSSpec *srcSpec, - const FSSpec *dstSpec); -/* ¦ Copy the desktop database comment from the source to the destination object. - The FSpDTCopyComment function copies the desktop database comment from - the source to the destination object. Both the source and the - destination volumes must support the Desktop Manager. - - srcSpec input: An FSSpec record specifying the source object. - dstSpec input: An FSSpec record specifying the destination object. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr Ð43 File or directory doesnÕt exist - wPrErr Ð44 Volume is locked through hardware - vLckdErr Ð46 Volume is locked through software - paramErr -50 Volume doesn't support this function - rfNumErr Ð51 Reference number invalid - paramErr -50 Volume doesn't support this function - extFSErr -58 External file system error - no file - system claimed this call. - desktopDamagedErr -1305 The desktop database has become corrupted - - the Finder will fix this, but if your - application is not running with the - Finder, use PBDTReset or PBDTDelete - afpItemNotFound -5012 Information not found - - __________ - - Also see: DTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment, - FSpDTGetComment -*/ - -/*****************************************************************************/ - -#ifdef __cplusplus -} -#endif - -#include "optimend.h" - -#endif /* __MOREDESKTOPMGR__ */ diff --git a/src/mac/morefile/MoreDesk.cpp b/src/mac/morefile/MoreDesktopMgr.c similarity index 95% rename from src/mac/morefile/MoreDesk.cpp rename to src/mac/morefile/MoreDesktopMgr.c index 5c74005ffd..880ed263f0 100644 --- a/src/mac/morefile/MoreDesk.cpp +++ b/src/mac/morefile/MoreDesktopMgr.c @@ -1,41 +1,57 @@ /* -** Apple Macintosh Developer Technical Support -** -** A collection of useful high-level Desktop Manager routines. -** If the Desktop Manager isn't available, use the Desktop file -** for 'read' operations. -** -** We do more because we can... -** -** by Jim Luther and Nitin Ganatra, Apple Developer Technical Support Emeriti -** -** File: MoreDesktopMgr.c -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: MoreDesktopMgr.c + + Contains: A collection of useful high-level Desktop Manager routines. + If the Desktop Manager is not available, use the Desktop file + for 'read' operations. + + Version: MoreFiles + + Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + (NG) Nitin Ganatra + + Change History (most recent first): + + <2> 2/7/01 JL Added standard header. Updated names of includes. Updated + various routines to use new calling convention of the + MoreFilesExtras accessor functions. + <1> 12/06/99 JL MoreFiles 1.5. */ -#include -#include -#include +#include +#include +#include #include #include #include #define __COMPILINGMOREFILES -#include "morefile.h" -#include "moreextr.h" -#include "mfsearch.h" -#include "moredesk.h" +#include "MoreFiles.h" +#include "MoreFilesExtras.h" +#include "Search.h" +#include "MoreDesktopMgr.h" /*****************************************************************************/ @@ -81,11 +97,7 @@ enum /* local data structures */ #if PRAGMA_STRUCT_ALIGN - #pragma options align=mac68k -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(push, 2) -#elif PRAGMA_STRUCT_PACK - #pragma pack(2) +#pragma options align=mac68k #endif struct IDRec @@ -134,11 +146,7 @@ typedef struct APPLRec APPLRec; typedef APPLRec *APPLRecPtr; #if PRAGMA_STRUCT_ALIGN - #pragma options align=reset -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(pop) -#elif PRAGMA_STRUCT_PACK - #pragma pack() +#pragma options align=reset #endif /*****************************************************************************/ @@ -245,7 +253,7 @@ pascal OSErr DTOpen(ConstStr255Param volName, error = HGetVolParms(volName, vRefNum, &volParmsInfo, &infoSize); if ( error == noErr ) { - if ( hasDesktopMgr(volParmsInfo) ) + if ( hasDesktopMgr(&volParmsInfo) ) { pb.ioNamePtr = (StringPtr)volName; pb.ioVRefNum = vRefNum; @@ -317,11 +325,7 @@ static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName, applResHandle = Get1Resource(kAPPLResType, 0); if ( applResHandle != NULL ) { -#if !TARGET_CARBON - applSize = InlineGetHandleSize((Handle)applResHandle); -#else applSize = GetHandleSize((Handle)applResHandle); -#endif if ( applSize != 0 ) /* make sure the APPL resource isn't empty */ { foundCreator = false; @@ -1117,11 +1121,7 @@ static OSErr GetCommentFromDesktopFile(short vRefNum, commentHandle = (StringHandle)Get1Resource(kFCMTResType,commentID); if ( commentHandle != NULL ) { -#if !TARGET_CARBON - if ( InlineGetHandleSize((Handle)commentHandle) > 0 ) -#else if ( GetHandleSize((Handle)commentHandle) > 0 ) -#endif { BlockMoveData(*commentHandle, comment, *commentHandle[0] + 1); } diff --git a/src/mac/morefile/MoreDesktopMgr.h b/src/mac/morefile/MoreDesktopMgr.h new file mode 100644 index 0000000000..110c673403 --- /dev/null +++ b/src/mac/morefile/MoreDesktopMgr.h @@ -0,0 +1,628 @@ +/* + File: MoreDesktopMgr.h + + Contains: A collection of useful high-level Desktop Manager routines. If the Desktop Manager is not available, use the Desktop file for 'read' operations. + + 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 __MOREDESKTOPMGR__ +#define __MOREDESKTOPMGR__ + +#ifndef __MACTYPES__ +#include +#endif + +#ifndef __FILES__ +#include +#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 ) +DTOpen( + ConstStr255Param volName, + short vRefNum, + short * dtRefNum, + Boolean * newDTDatabase); + + +/* + The DTOpen function opens a volume's desktop database. It returns + the reference number of the desktop database and indicates if the + desktop database was created as a result of this call (if it was created, + then it is empty). + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + dtRefNum output: The reference number of Desktop Manager's + desktop database on the specified volume. + newDTDatabase output: true if the desktop database was created as a + result of this call and thus empty. + false if the desktop database was already created, + or if it could not be determined if it was already + created. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + paramErr -50 Volume doesn't support this function + extFSErr -58 External file system error - no file + system claimed this call. + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DTXGetAPPL( + ConstStr255Param volName, + short vRefNum, + OSType creator, + Boolean searchCatalog, + short * applVRefNum, + long * applParID, + Str255 applName); + + +/* + The DTXGetAPPL function finds an application (file type 'APPL') with + the specified creator on the specified volume. It first tries to get + the application mapping from the desktop database. If that fails, + then it tries to find an application in the Desktop file. If that + fails and searchCatalog is true, then it tries to find an application + with the specified creator using the File Manager's CatSearch routine. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + creator input: The file's creator type. + searchCatalog input: If true, search the catalog for the application + if it isn't found in the desktop database. + applVRefNum output: The volume reference number of the volume the + application is on. + applParID output: The parent directory ID of the application. + applName output: The name of the application. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + paramErr -50 No default volume + rfNumErr -51 Reference number invalid + extFSErr -58 External file system error - no file + system claimed this call + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + afpItemNotFound -5012 Information not found + + __________ + + Also see: FSpDTGetAPPL +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpDTXGetAPPL( + ConstStr255Param volName, + short vRefNum, + OSType creator, + Boolean searchCatalog, + FSSpec * spec); + + +/* + The FSpDTXGetAPPL function finds an application (file type 'APPL') with + the specified creator on the specified volume. It first tries to get + the application mapping from the desktop database. If that fails, + then it tries to find an application in the Desktop file. If that + fails and searchCatalog is true, then it tries to find an application + with the specified creator using the File Manager's CatSearch routine. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + creator input: The file's creator type. + searchCatalog input: If true, search the catalog for the application + if it isn't found in the desktop database. + spec output: FSSpec record containing the application name and + location. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + paramErr -50 No default volume + rfNumErr -51 Reference number invalid + extFSErr -58 External file system error - no file + system claimed this call + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + afpItemNotFound -5012 Information not found + + __________ + + Also see: FSpDTGetAPPL +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DTGetAPPL( + ConstStr255Param volName, + short vRefNum, + OSType creator, + short * applVRefNum, + long * applParID, + Str255 applName); + + +/* + The DTGetAPPL function finds an application (file type 'APPL') with + the specified creator on the specified volume. It first tries to get + the application mapping from the desktop database. If that fails, + then it tries to find an application in the Desktop file. If that + fails, then it tries to find an application with the specified creator + using the File Manager's CatSearch routine. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + creator input: The file's creator type. + applVRefNum output: The volume reference number of the volume the + application is on. + applParID output: The parent directory ID of the application. + applName output: The name of the application. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + paramErr -50 No default volume + rfNumErr -51 Reference number invalid + extFSErr -58 External file system error - no file + system claimed this call + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + afpItemNotFound -5012 Information not found + + __________ + + Also see: FSpDTGetAPPL +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpDTGetAPPL( + ConstStr255Param volName, + short vRefNum, + OSType creator, + FSSpec * spec); + + +/* + The FSpDTGetAPPL function finds an application (file type 'APPL') with + the specified creator on the specified volume. It first tries to get + the application mapping from the desktop database. If that fails, + then it tries to find an application in the Desktop file. If that + fails, then it tries to find an application with the specified creator + using the File Manager's CatSearch routine. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + creator input: The file's creator type. + spec output: FSSpec record containing the application name and + location. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + paramErr -50 No default volume + rfNumErr -51 Reference number invalid + extFSErr -58 External file system error - no file + system claimed this call + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + afpItemNotFound -5012 Information not found + + __________ + + Also see: DTGetAPPL +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DTGetIcon( + ConstStr255Param volName, + short vRefNum, + short iconType, + OSType fileCreator, + OSType fileType, + Handle * iconHandle); + + +/* + The DTGetIcon function retrieves the specified icon and returns it in + a newly created handle. The icon is retrieves from the Desktop Manager + or if the Desktop Manager is not available, from the Finder's Desktop + file. Your program is responsible for disposing of the handle when it is + done using the icon. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + iconType input: The icon type as defined in Files.h. Valid values are: + kLargeIcon + kLarge4BitIcon + kLarge8BitIcon + kSmallIcon + kSmall4BitIcon + kSmall8BitIcon + fileCreator input: The icon's creator type. + fileType input: The icon's file type. + iconHandle output: A Handle containing the newly created icon. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + paramErr -50 Volume doesn't support this function + rfNumErr -51 Reference number invalid + extFSErr -58 External file system error - no file + system claimed this call + memFullErr -108 iconHandle could not be allocated + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + afpItemNotFound -5012 Information not found +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DTSetComment( + short vRefNum, + long dirID, + ConstStr255Param name, + ConstStr255Param comment); + + +/* + The DTSetComment function sets a file or directory's Finder comment + field. The volume must support the Desktop Manager because you only + have read access to the Desktop file. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + comment input: The comment to add. Comments are limited to 200 characters; + longer comments are truncated. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr Ð43 File or directory doesnÕt exist + paramErr -50 Volume doesn't support this function + wPrErr Ð44 Volume is locked through hardware + vLckdErr Ð46 Volume is locked through software + rfNumErr Ð51 Reference number invalid + extFSErr -58 External file system error - no file + system claimed this call. + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + + __________ + + Also see: DTCopyComment, FSpDTCopyComment, FSpDTSetComment, DTGetComment, + FSpDTGetComment +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpDTSetComment( + const FSSpec * spec, + ConstStr255Param comment); + + +/* + The FSpDTSetComment function sets a file or directory's Finder comment + field. The volume must support the Desktop Manager because you only + have read access to the Desktop file. + + spec input: An FSSpec record specifying the file or directory. + comment input: The comment to add. Comments are limited to 200 characters; + longer comments are truncated. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr Ð43 File or directory doesnÕt exist + wPrErr Ð44 Volume is locked through hardware + vLckdErr Ð46 Volume is locked through software + rfNumErr Ð51 Reference number invalid + paramErr -50 Volume doesn't support this function + extFSErr -58 External file system error - no file + system claimed this call. + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + + __________ + + Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, DTGetComment, + FSpDTGetComment +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DTGetComment( + short vRefNum, + long dirID, + ConstStr255Param name, + Str255 comment); + + +/* + The DTGetComment function gets a file or directory's Finder comment + field (if any) from the Desktop Manager or if the Desktop Manager is + not available, from the Finder's Desktop file. + + IMPORTANT NOTE: Inside Macintosh says that comments are up to + 200 characters. While that may be correct for the HFS file system's + Desktop Manager, other file systems (such as Apple Photo Access) return + up to 255 characters. Make sure the comment buffer is a Str255 or you'll + regret it. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + comment output: A Str255 where the comment is to be returned. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr -43 File not found + paramErr -50 Volume doesn't support this function + rfNumErr Ð51 Reference number invalid + extFSErr -58 External file system error - no file + system claimed this call. + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + afpItemNotFound -5012 Information not found + + __________ + + Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment, + FSpDTGetComment +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpDTGetComment( + const FSSpec * spec, + Str255 comment); + + +/* + The FSpDTGetComment function gets a file or directory's Finder comment + field (if any) from the Desktop Manager or if the Desktop Manager is + not available, from the Finder's Desktop file. + + IMPORTANT NOTE: Inside Macintosh says that comments are up to + 200 characters. While that may be correct for the HFS file system's + Desktop Manager, other file systems (such as Apple Photo Access) return + up to 255 characters. Make sure the comment buffer is a Str255 or you'll + regret it. + + spec input: An FSSpec record specifying the file or directory. + comment output: A Str255 where the comment is to be returned. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr -43 File not found + paramErr -50 Volume doesn't support this function + rfNumErr Ð51 Reference number invalid + extFSErr -58 External file system error - no file + system claimed this call. + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + afpItemNotFound -5012 Information not found + + __________ + + Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment, + DTGetComment +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DTCopyComment( + short srcVRefNum, + long srcDirID, + ConstStr255Param srcName, + short dstVRefNum, + long dstDirID, + ConstStr255Param dstName); + + +/* + The DTCopyComment function copies the file or folder comment from the + source to the destination object. The destination volume must support + the Desktop Manager because you only have read access to the Desktop file. + + srcVRefNum input: Source volume specification. + srcDirID input: Source directory ID. + srcName input: Pointer to source object name, or nil when srcDirID + specifies a directory that's the object. + dstVRefNum input: Destination volume specification. + dstDirID input: Destination directory ID. + dstName input: Pointer to destination object name, or nil when + dstDirID specifies a directory that's the object. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr Ð43 File or directory doesnÕt exist + wPrErr Ð44 Volume is locked through hardware + vLckdErr Ð46 Volume is locked through software + paramErr -50 Volume doesn't support this function + rfNumErr Ð51 Reference number invalid + paramErr -50 Volume doesn't support this function + extFSErr -58 External file system error - no file + system claimed this call. + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + afpItemNotFound -5012 Information not found + + __________ + + Also see: FSpDTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment, + FSpDTGetComment +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpDTCopyComment( + const FSSpec * srcSpec, + const FSSpec * dstSpec); + + +/* + The FSpDTCopyComment function copies the desktop database comment from + the source to the destination object. Both the source and the + destination volumes must support the Desktop Manager. + + srcSpec input: An FSSpec record specifying the source object. + dstSpec input: An FSSpec record specifying the destination object. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr Ð43 File or directory doesnÕt exist + wPrErr Ð44 Volume is locked through hardware + vLckdErr Ð46 Volume is locked through software + paramErr -50 Volume doesn't support this function + rfNumErr Ð51 Reference number invalid + paramErr -50 Volume doesn't support this function + extFSErr -58 External file system error - no file + system claimed this call. + desktopDamagedErr -1305 The desktop database has become corrupted - + the Finder will fix this, but if your + application is not running with the + Finder, use PBDTReset or PBDTDelete + afpItemNotFound -5012 Information not found + + __________ + + Also see: DTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment, + FSpDTGetComment +*/ + +/*****************************************************************************/ + +#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 /* __MOREDESKTOPMGR__ */ + diff --git a/src/mac/morefile/MoreExtr.h b/src/mac/morefile/MoreExtr.h deleted file mode 100644 index c0fd7a006b..0000000000 --- a/src/mac/morefile/MoreExtr.h +++ /dev/null @@ -1,3149 +0,0 @@ -/* -** Apple Macintosh Developer Technical Support -** -** A collection of useful high-level File Manager routines. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: MoreFilesExtras.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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 __MOREFILESEXTRAS__ -#define __MOREFILESEXTRAS__ - -#include -#include - -#ifndef true -#define true 1 -#define false 0 -#endif - -#include "optim.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************************/ - -/* Constants and types from Universal Interfaces 3.0.1 Files.h */ - -#if UNIVERSAL_INTERFACES_VERSION < 0x0301 - -enum { - volMountNoLoginMsgFlagBit = 0, /* Input to VolumeMount: If set, the file system */ - volMountNoLoginMsgFlagMask = 0x0001, /* should suppresss any log-in message/greeting dialog */ - volMountExtendedFlagsBit = 7, /* Input to VolumeMount: If set, the mount info is a */ - volMountExtendedFlagsMask = 0x0080 /* AFPXVolMountInfo record for 3.7 AppleShare Client */ -}; - -/* AFPXVolMountInfo is the new AFP volume mount info record, requires the 3.7 AppleShare Client */ - -struct AFPXVolMountInfo { - short length; /* length of location data (including self) */ - VolumeType media; /* type of media */ - short flags; /* bits for no messages, no reconnect */ - SInt8 nbpInterval; /* NBP Interval parameter (IM2, p.322) */ - SInt8 nbpCount; /* NBP Interval parameter (IM2, p.322) */ - short uamType; /* User Authentication Method type */ - short zoneNameOffset; /* short positive offset from start of struct to Zone Name */ - short serverNameOffset; /* offset to pascal Server Name string */ - short volNameOffset; /* offset to pascal Volume Name string */ - short userNameOffset; /* offset to pascal User Name string */ - short userPasswordOffset; /* offset to pascal User Password string */ - short volPasswordOffset; /* offset to pascal Volume Password string */ - short extendedFlags; /* extended flags word */ - short uamNameOffset; /* offset to a pascal UAM name string */ - short alternateAddressOffset; /* offset to Alternate Addresses in tagged format */ - char AFPData[176]; /* variable length data may follow */ -}; -typedef struct AFPXVolMountInfo AFPXVolMountInfo; -typedef AFPXVolMountInfo * AFPXVolMountInfoPtr; - -enum { - kAFPExtendedFlagsAlternateAddressMask = 1 /* bit in AFPXVolMountInfo.extendedFlags that means alternateAddressOffset is used*/ -}; - -enum { - /* constants for use in AFPTagData.fType field*/ - kAFPTagTypeIP = 0x01, - kAFPTagTypeIPPort = 0x02, - kAFPTagTypeDDP = 0x03 /* Currently unused*/ -}; - -enum { - /* constants for use in AFPTagData.fLength field*/ - kAFPTagLengthIP = 0x06, - kAFPTagLengthIPPort = 0x08, - kAFPTagLengthDDP = 0x06 -}; - -struct AFPTagData { - UInt8 fLength; /* length of this data tag including the fLength field */ - UInt8 fType; - UInt8 fData[1]; /* variable length data */ -}; -typedef struct AFPTagData AFPTagData; - -struct AFPAlternateAddress { - UInt8 fAddressCount; - UInt8 fAddressList[1]; /* actually variable length packed set of AFPTagData */ -}; -typedef struct AFPAlternateAddress AFPAlternateAddress; - -#endif - -/*****************************************************************************/ - -/* -** Macros to get information out of GetVolParmsInfoBuffer -*/ - -#define isNetworkVolume(volParms) ((volParms).vMServerAdr != 0) -#define hasLimitFCBs(volParms) (((volParms).vMAttrib & (1L << bLimitFCBs)) != 0) -#define hasLocalWList(volParms) (((volParms).vMAttrib & (1L << bLocalWList)) != 0) -#define hasNoMiniFndr(volParms) (((volParms).vMAttrib & (1L << bNoMiniFndr)) != 0) -#define hasNoVNEdit(volParms) (((volParms).vMAttrib & (1L << bNoVNEdit)) != 0) -#define hasNoLclSync(volParms) (((volParms).vMAttrib & (1L << bNoLclSync)) != 0) -#define hasTrshOffLine(volParms) (((volParms).vMAttrib & (1L << bTrshOffLine)) != 0) -#define hasNoSwitchTo(volParms) (((volParms).vMAttrib & (1L << bNoSwitchTo)) != 0) -#define hasNoDeskItems(volParms) (((volParms).vMAttrib & (1L << bNoDeskItems)) != 0) -#define hasNoBootBlks(volParms) (((volParms).vMAttrib & (1L << bNoBootBlks)) != 0) -#define hasAccessCntl(volParms) (((volParms).vMAttrib & (1L << bAccessCntl)) != 0) -#define hasNoSysDir(volParms) (((volParms).vMAttrib & (1L << bNoSysDir)) != 0) -#define hasExtFSVol(volParms) (((volParms).vMAttrib & (1L << bHasExtFSVol)) != 0) -#define hasOpenDeny(volParms) (((volParms).vMAttrib & (1L << bHasOpenDeny)) != 0) -#define hasCopyFile(volParms) (((volParms).vMAttrib & (1L << bHasCopyFile)) != 0) -#define hasMoveRename(volParms) (((volParms).vMAttrib & (1L << bHasMoveRename)) != 0) -#define hasDesktopMgr(volParms) (((volParms).vMAttrib & (1L << bHasDesktopMgr)) != 0) -#define hasShortName(volParms) (((volParms).vMAttrib & (1L << bHasShortName)) != 0) -#define hasFolderLock(volParms) (((volParms).vMAttrib & (1L << bHasFolderLock)) != 0) -#define hasPersonalAccessPrivileges(volParms) \ - (((volParms).vMAttrib & (1L << bHasPersonalAccessPrivileges)) != 0) -#define hasUserGroupList(volParms) (((volParms).vMAttrib & (1L << bHasUserGroupList)) != 0) -#define hasCatSearch(volParms) (((volParms).vMAttrib & (1L << bHasCatSearch)) != 0) -#define hasFileIDs(volParms) (((volParms).vMAttrib & (1L << bHasFileIDs)) != 0) -#define hasBTreeMgr(volParms) (((volParms).vMAttrib & (1L << bHasBTreeMgr)) != 0) -#define hasBlankAccessPrivileges(volParms) \ - (((volParms).vMAttrib & (1L << bHasBlankAccessPrivileges)) != 0) - -/*****************************************************************************/ - - -/* -** Bit masks and macros to get common information out of ioACUser returned -** by PBGetCatInfo (remember to clear ioACUser before calling PBGetCatInfo -** since some file systems don't bother to set this field). -** -** Use the GetDirAccessRestrictions or FSpGetDirAccessRestrictions -** functions to retrieve the ioACUser access restrictions byte for -** a folder. -** -** Note: The access restriction byte returned by PBGetCatInfo is the -** 2's complement of the user's privileges byte returned in -** ioACAccess by PBHGetDirAccess. -*/ - -enum -{ - /* bits defined in ioACUser */ - acUserNoSeeFoldersMask = 0x01, - acUserNoSeeFilesMask = 0x02, - acUserNoMakeChangesMask = 0x04, - acUserNotOwnerMask = 0x80, - - /* mask for just the access restriction bits */ - acUserAccessMask = 0x07, - - /* common access privilege settings */ - acUserFull = 0x00, /* no access restiction bits on */ - acUserNone = acUserAccessMask, /* all access restiction bits on */ - acUserDropBox = acUserNoSeeFoldersMask + acUserNoSeeFilesMask, /* make changes, but not see files or folders */ - acUserBulletinBoard = acUserNoMakeChangesMask /* see files and folders, but not make changes */ -}; - -/* Macros for testing ioACUser bits */ -#define userIsOwner(ioACUser) \ - (((ioACUser) & acUserNotOwnerMask) == 0) -#define userHasFullAccess(ioACUser) \ - (((ioACUser) & (acUserAccessMask)) == acUserFull) -#define userHasDropBoxAccess(ioACUser) \ - (((ioACUser) & acUserAccessMask) == acUserDropBox) -#define userHasBulletinBoard(ioACUser) \ - (((ioACUser) & acUserAccessMask) == acUserBulletinBoard) -#define userHasNoAccess(ioACUser) \ - (((ioACUser) & acUserAccessMask) == acUserNone) - -/*****************************************************************************/ - -/* -** Deny mode permissions for use with the HOpenAware, HOpenRFAware, -** FSpOpenAware, and FSpOpenRFAware functions. -*/ - -enum -{ - dmNone = 0x0000, - dmNoneDenyRd = 0x0010, - dmNoneDenyWr = 0x0020, - dmNoneDenyRdWr = 0x0030, - dmRd = 0x0001, /* Single writer, multiple readers; the readers */ - dmRdDenyRd = 0x0011, - dmRdDenyWr = 0x0021, /* Browsing - equivalent to fsRdPerm */ - dmRdDenyRdWr = 0x0031, - dmWr = 0x0002, - dmWrDenyRd = 0x0012, - dmWrDenyWr = 0x0022, - dmWrDenyRdWr = 0x0032, - dmRdWr = 0x0003, /* Shared access - equivalent to fsRdWrShPerm */ - dmRdWrDenyRd = 0x0013, - dmRdWrDenyWr = 0x0023, /* Single writer, multiple readers; the writer */ - dmRdWrDenyRdWr = 0x0033 /* Exclusive access - equivalent to fsRdWrPerm */ -}; - -/*****************************************************************************/ - -#if PRAGMA_STRUCT_ALIGN - #pragma options align=mac68k -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(push, 2) -#elif PRAGMA_STRUCT_PACK - #pragma pack(2) -#endif - -/* -** For those times where you need to use more than one kind of File Manager parameter -** block but don't feel like wasting stack space, here's a parameter block you can reuse. -*/ - -union UniversalFMPB -{ - ParamBlockRec PB; - CInfoPBRec ciPB; - DTPBRec dtPB; - HParamBlockRec hPB; - CMovePBRec cmPB; - WDPBRec wdPB; - FCBPBRec fcbPB; - XVolumeParam xPB; -}; -typedef union UniversalFMPB UniversalFMPB; -typedef UniversalFMPB *UniversalFMPBPtr, **UniversalFMPBHandle; - - -/* -** Used by GetUGEntries to return user or group lists -*/ - -struct UGEntry -{ - short objType; /* object type: -1 = group; 0 = user */ - long objID; /* the user or group ID */ - Str31 name; /* the user or group name */ -}; -typedef struct UGEntry UGEntry; -typedef UGEntry *UGEntryPtr, **UGEntryHandle; - - -typedef unsigned char Str8[9]; - - -/* -** I use the following records instead of the AFPVolMountInfo and AFPXVolMountInfo structures in Files.h -*/ - -struct MyAFPVolMountInfo -{ - short length; /* length of this record */ - VolumeType media; /* type of media, always AppleShareMediaType */ - short flags; /* 0 = normal mount; set bit 0 to inhibit greeting messages */ - char nbpInterval; /* NBP interval parameter; 7 is a good choice */ - char nbpCount; /* NBP count parameter; 5 is a good choice */ - short uamType; /* User Authentication Method */ - short zoneNameOffset; /* offset from start of record to zoneName */ - short serverNameOffset; /* offset from start of record to serverName */ - short volNameOffset; /* offset from start of record to volName */ - short userNameOffset; /* offset from start of record to userName */ - short userPasswordOffset; /* offset from start of record to userPassword */ - short volPasswordOffset; /* offset from start of record to volPassword */ - Str32 zoneName; /* server's AppleTalk zone name */ - char filler1; /* to word align volPassword */ - Str32 serverName; /* server name */ - char filler2; /* to word align volPassword */ - Str27 volName; /* volume name */ - Str31 userName; /* user name (zero length Pascal string for guest) */ - Str8 userPassword; /* user password (zero length Pascal string if no user password) */ - char filler3; /* to word align volPassword */ - Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */ - char filler4; /* to end record on word boundry */ -}; -typedef struct MyAFPVolMountInfo MyAFPVolMountInfo; -typedef MyAFPVolMountInfo *MyAFPVolMountInfoPtr, **MyAFPVolMountInfoHandle; - -struct MyAFPXVolMountInfo -{ - short length; /* length of this record */ - VolumeType media; /* type of media, always AppleShareMediaType */ - short flags; /* bits for no messages, no reconnect, etc */ - char nbpInterval; /* NBP interval parameter; 7 is a good choice */ - char nbpCount; /* NBP count parameter; 5 is a good choice */ - short uamType; /* User Authentication Method */ - short zoneNameOffset; /* offset from start of record to zoneName */ - short serverNameOffset; /* offset from start of record to serverName */ - short volNameOffset; /* offset from start of record to volName */ - short userNameOffset; /* offset from start of record to userName */ - short userPasswordOffset; /* offset from start of record to userPassword */ - short volPasswordOffset; /* offset from start of record to volPassword */ - short extendedFlags; /* extended flags word */ - short uamNameOffset; /* offset to a pascal UAM name string */ - short alternateAddressOffset; /* offset to Alternate Addresses in tagged format */ - Str32 zoneName; /* server's AppleTalk zone name */ - char filler1; /* to word align volPassword */ - Str32 serverName; /* server name */ - char filler2; /* to word align volPassword */ - Str27 volName; /* volume name */ - Str31 userName; /* user name (zero length Pascal string for guest) */ - Str8 userPassword; /* user password (zero length Pascal string if no user password) */ - char filler3; /* to word align volPassword */ - Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */ - char filler4; /* to word align uamNameOffset */ - Str32 uamName; /* UAM name */ - char filler5; /* to word align alternateAddress */ - char alternateAddress[kVariableLengthArray]; /* AFPAlternateAddress */ -}; -typedef struct MyAFPXVolMountInfo MyAFPXVolMountInfo; -typedef MyAFPXVolMountInfo *MyAFPXVolMountInfoPtr, **MyAFPXVolMountInfoHandle; - -#if PRAGMA_STRUCT_ALIGN - #pragma options align=reset -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(pop) -#elif PRAGMA_STRUCT_PACK - #pragma pack() -#endif - -/*****************************************************************************/ - -pascal void TruncPString(StringPtr destination, - ConstStr255Param source, - short maxLength); -/* ¦ International friendly string truncate routine. - The TruncPString function copies up to maxLength characters from - the source Pascal string to the destination Pascal string. TruncPString - ensures that the truncated string ends on a single-byte character, or on - the last byte of a multi-byte character. - - destination output: destination Pascal string. - source input: source Pascal string. - maxLength output: The maximum allowable length of the destination - string. -*/ - -/*****************************************************************************/ - -pascal Ptr GetTempBuffer(long buffReqSize, - long *buffActSize); -/* ¦ Allocate a temporary copy or search buffer. - The GetTempBuffer function allocates a temporary buffer for file system - operations which is at least 1024 bytes (1K) and a multiple of - 1024 bytes. - - buffReqSize input: Size you'd like the buffer to be. - buffActSize output: Size of buffer allocated. - function result output: Pointer to memory allocated or nil if no memory - was available. The caller is responsible for - disposing of this buffer with DisposePtr. -*/ - -/*****************************************************************************/ - -pascal OSErr GetVolumeInfoNoName(ConstStr255Param pathname, - short vRefNum, - HParmBlkPtr pb); -/* ¦ Call PBHGetVInfoSync ignoring returned name. - GetVolumeInfoNoName uses pathname and vRefNum to call PBHGetVInfoSync - in cases where the returned volume name is not needed by the caller. - The pathname and vRefNum parameters are not touched, and the pb - parameter is initialized by PBHGetVInfoSync except that ioNamePtr in - the parameter block is always returned as NULL (since it might point - to GetVolumeInfoNoName's local variable tempPathname). - - I noticed using this code in several places, so here it is once. - This reduces the code size of MoreFiles. - - pathName input: Pointer to a full pathname or nil. If you pass in a - partial pathname, it is ignored. A full pathname to a - volume must end with a colon character (:). - vRefNum input: Volume specification (volume reference number, working - directory number, drive number, or 0). - pb input: A pointer to HParamBlockRec. - output: The parameter block as filled in by PBHGetVInfoSync - except that ioNamePtr will always be NULL. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - paramErr -50 No default volume, or pb was NULL -*/ - -/*****************************************************************************/ - -pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname, - short vRefNum, - XVolumeParamPtr pb); -/* ¦ Call PBXGetVolInfoSync ignoring returned name. - XGetVolumeInfoNoName uses pathname and vRefNum to call PBXGetVolInfoSync - in cases where the returned volume name is not needed by the caller. - The pathname and vRefNum parameters are not touched, and the pb - parameter is initialized by PBXGetVolInfoSync except that ioNamePtr in - the parameter block is always returned as NULL (since it might point - to XGetVolumeInfoNoName's local variable tempPathname). - - pathName input: Pointer to a full pathname or nil. If you pass in a - partial pathname, it is ignored. A full pathname to a - volume must end with a colon character (:). - vRefNum input: Volume specification (volume reference number, working - directory number, drive number, or 0). - pb input: A pointer to HParamBlockRec. - output: The parameter block as filled in by PBXGetVolInfoSync - except that ioNamePtr will always be NULL. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - paramErr -50 No default volume, or pb was NULL -*/ - -/*****************************************************************************/ - -pascal OSErr GetCatInfoNoName(short vRefNum, - long dirID, - ConstStr255Param name, - CInfoPBPtr pb); -/* ¦ Call PBGetCatInfoSync ignoring returned name. - GetCatInfoNoName uses vRefNum, dirID and name to call PBGetCatInfoSync - in cases where the returned object is not needed by the caller. - The vRefNum, dirID and name parameters are not touched, and the pb - parameter is initialized by PBGetCatInfoSync except that ioNamePtr in - the parameter block is always returned as NULL (since it might point - to GetCatInfoNoName's local variable tempName). - - I noticed using this code in several places, so here it is once. - This reduces the code size of MoreFiles. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - pb input: A pointer to CInfoPBRec. - output: The parameter block as filled in by - PBGetCatInfoSync except that ioNamePtr will - always be NULL. - - 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 - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - -*/ - -/*****************************************************************************/ - -pascal OSErr DetermineVRefNum(ConstStr255Param pathname, - short vRefNum, - short *realVRefNum); -/* ¦ Determine the real volume reference number. - The DetermineVRefNum function determines the volume reference number of - a volume from a pathname, a volume specification, or a combination - of the two. - WARNING: Volume names on the Macintosh are *not* unique -- Multiple - mounted volumes can have the same name. For this reason, the use of a - volume name or full pathname to identify a specific volume may not - produce the results you expect. If more than one volume has the same - name and a volume name or full pathname is used, the File Manager - currently uses the first volume it finds with a matching name in the - volume queue. - - pathName input: Pointer to a full pathname or nil. If you pass in a - partial pathname, it is ignored. A full pathname to a - volume must end with a colon character (:). - vRefNum input: Volume specification (volume reference number, working - directory number, drive number, or 0). - realVRefNum output: The real volume reference number. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - paramErr -50 No default volume -*/ - -/*****************************************************************************/ - -pascal OSErr HGetVInfo(short volReference, - StringPtr volName, - short *vRefNum, - unsigned long *freeBytes, - unsigned long *totalBytes); -/* ¦ Get information about a mounted volume. - The HGetVInfo function returns the name, volume reference number, - available space (in bytes), and total space (in bytes) for the - specified volume. You can specify the volume by providing its drive - number, volume reference number, or 0 for the default volume. - This routine is compatible with volumes up to 4 gigabytes. - - volReference input: The drive number, volume reference number, - or 0 for the default volume. - volName input: A pointer to a buffer (minimum Str27) where - the volume name is to be returned or must - be nil. - output: The volume name. - vRefNum output: The volume reference number. - freeBytes output: The number of free bytes on the volume. - freeBytes is an unsigned long value. - totalBytes output: The total number of bytes on the volume. - totalBytes is an unsigned long value. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - paramErr -50 No default volume - - __________ - - Also see: XGetVInfo -*/ - -/*****************************************************************************/ - -pascal OSErr XGetVInfo(short volReference, - StringPtr volName, - short *vRefNum, - UnsignedWide *freeBytes, - UnsignedWide *totalBytes); -/* ¦ Get extended information about a mounted volume. - The XGetVInfo function returns the name, volume reference number, - available space (in bytes), and total space (in bytes) for the - specified volume. You can specify the volume by providing its drive - number, volume reference number, or 0 for the default volume. - This routine is compatible with volumes up to 2 terabytes. - - volReference input: The drive number, volume reference number, - or 0 for the default volume. - volName input: A pointer to a buffer (minimum Str27) where - the volume name is to be returned or must - be nil. - output: The volume name. - vRefNum output: The volume reference number. - freeBytes output: The number of free bytes on the volume. - freeBytes is an UnsignedWide value. - totalBytes output: The total number of bytes on the volume. - totalBytes is an UnsignedWide value. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - paramErr -50 No default volume - - __________ - - Also see: HGetVInfo -*/ - -/*****************************************************************************/ - -pascal OSErr CheckVolLock(ConstStr255Param pathname, - short vRefNum); -/* ¦ Determine if a volume is locked. - The CheckVolLock function determines if a volume is locked - either by - hardware or by software. If CheckVolLock returns noErr, then the volume - is not locked. - - pathName input: Pointer to a full pathname or nil. If you pass in a - partial pathname, it is ignored. A full pathname to a - volume must end with a colon character (:). - vRefNum input: Volume specification (volume reference number, working - directory number, drive number, or 0). - - Result Codes - noErr 0 No error - volume not locked - nsvErr -35 No such volume - wPrErr -44 Volume locked by hardware - vLckdErr -46 Volume locked by software - paramErr -50 No default volume -*/ - -/*****************************************************************************/ - -pascal OSErr GetDriverName(short driverRefNum, - Str255 driverName); -/* ¦ Get a device driver's name. - The GetDriverName function returns a device driver's name. - - driverRefNum input: The driver reference number. - driverName output: The driver's name. - - Result Codes - noErr 0 No error - badUnitErr -21 Bad driver reference number -*/ - -/*****************************************************************************/ - -pascal OSErr FindDrive(ConstStr255Param pathname, - short vRefNum, - DrvQElPtr *driveQElementPtr); -/* ¦ Find a volume's drive queue element in the drive queue. - The FindDrive function returns a pointer to a mounted volume's - drive queue element. - - pathName input: Pointer to a full pathname or nil. If you - pass in a partial pathname, it is ignored. - A full pathname to a volume must end with - a colon character (:). - vRefNum input: Volume specification (volume reference - number, working directory number, drive - number, or 0). - driveQElementPtr output: Pointer to a volume's drive queue element - in the drive queue. DO NOT change the - DrvQEl. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - paramErr -50 No default volume - nsDrvErr -56 No such drive -*/ - -/*****************************************************************************/ - -pascal OSErr GetDiskBlocks(ConstStr255Param pathname, - short vRefNum, - unsigned long *numBlocks); -/* ¦ Return the number of physical disk blocks on a disk drive. - The GetDiskBlocks function returns the number of physical disk - blocks on a disk drive. NOTE: This is not the same as volume - allocation blocks! - - pathName input: Pointer to a full pathname or nil. If you - pass in a partial pathname, it is ignored. - A full pathname to a volume must end with - a colon character (:). - vRefNum input: Volume specification (volume reference - number, working directory number, drive - number, or 0). - numBlocks output: The number of physical disk blocks on the disk drive. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - paramErr -50 No default volume, driver reference - number is zero, ReturnFormatList - returned zero blocks, DriveStatus - returned an unknown value, or - driveQElementPtr->qType is unknown - nsDrvErr -56 No such drive - statusErr Ð18 Driver does not respond to this - status request - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies - a nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open -*/ - -/*****************************************************************************/ - -pascal OSErr GetVolFileSystemID(ConstStr255Param pathname, - short vRefNum, - short *fileSystemID); -/* ¦ Get a volume's file system ID. - The GetVolFileSystemID function returned the file system ID of - a mounted volume. The file system ID identifies the file system - that handles requests to a particular volume. Here's a partial list - of file system ID numbers (only Apple's file systems are listed): - FSID File System - ----- ----------------------------------------------------- - $0000 Macintosh HFS or MFS - $0100 ProDOS File System - $0101 PowerTalk Mail Enclosures - $4147 ISO 9660 File Access (through Foreign File Access) - $4242 High Sierra File Access (through Foreign File Access) - $464D QuickTake File System (through Foreign File Access) - $4953 Macintosh PC Exchange (MS-DOS) - $4A48 Audio CD Access (through Foreign File Access) - $4D4B Apple Photo Access (through Foreign File Access) - - See the Technical Note "FL 35 - Determining Which File System - Is Active" and the "Guide to the File System Manager" for more - information. - - pathName input: Pointer to a full pathname or nil. If you pass - in a partial pathname, it is ignored. A full - pathname to a volume must contain at least - one colon character (:) and must not start with - a colon character. - vRefNum input: Volume specification (volume reference number, - working directory number, drive number, or 0). - fileSystemID output: The volume's file system ID. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - paramErr -50 No default volume, or pb was NULL -*/ - -/*****************************************************************************/ - -pascal OSErr GetVolState(ConstStr255Param pathname, - short vRefNum, - Boolean *volumeOnline, - Boolean *volumeEjected, - Boolean *driveEjectable, - Boolean *driverWantsEject); -/* ¦ Returns a volume's online and eject information. - The GetVolState function determines if a volume is online or offline, - if an offline volume is ejected, and if the volume's driver is - ejectable or wants eject calls. - - pathName input: Pointer to a full pathname or nil. - vRefNum input: Volume specification (volume reference number, - working directory number, drive number, or 0). - volumeOnline output: True if the volume is online; - False if the volume is offline. - volumeEjected output: True if the volume is ejected (ejected - volumes are always offline); False if the - volume is not ejected. - driveEjectable output: True if the volume's drive is ejectable; - False if the volume's drive is not ejectable. - driverWantsEject output: True if the volume's driver wants an Eject - request after unmount (even if the drive - is not ejectable); False if the volume's - driver does not need an eject request. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - paramErr -50 No default volume, or pb was NULL -*/ - -/*****************************************************************************/ - -pascal OSErr UnmountAndEject(ConstStr255Param pathname, - short vRefNum); -/* ¦ Unmount and eject a volume. - The UnmountAndEject function unmounts and ejects a volume. The volume - is ejected only if it is ejectable and not already ejected. - - pathName input: Pointer to a full pathname or nil. If you pass in a - partial pathname, it is ignored. A full pathname to a - volume must end with a colon character (:). - vRefNum input: Volume specification (volume reference number, working - directory number, drive number, or 0). - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad volume name - fBsyErr -47 One or more files are open - paramErr -50 No default volume - nsDrvErr -56 No such drive - extFSErr -58 External file system error - no file - system claimed this call. -*/ - -/*****************************************************************************/ - -pascal OSErr OnLine(FSSpecPtr volumes, - short reqVolCount, - short *actVolCount, - short *volIndex); -/* ¦ Return the list of volumes currently mounted. - The OnLine function returns the list of volumes currently mounted in - an array of FSSpec records. - - A noErr result indicates that the volumes array was filled - (actVolCount == reqVolCount) and there may be additional volumes - mounted. A nsvErr result indicates that the end of the volume list - was found and actVolCount volumes were actually found this time. - - volumes input: Pointer to array of FSSpec where the volume list - is returned. - reqVolCount input: Maximum number of volumes to return (the number of - elements in the volumes array). - actVolCount output: The number of volumes actually returned. - volIndex input: The current volume index position. Set to 1 to - start with the first volume. - output: The volume index position to get the next volume. - Pass this value the next time you call OnLine to - start where you left off. - - Result Codes - noErr 0 No error, but there are more volumes - to list - nsvErr -35 No more volumes to be listed - paramErr -50 volIndex was <= 0 -*/ - -/*****************************************************************************/ - -pascal OSErr SetDefault(short newVRefNum, - long newDirID, - short *oldVRefNum, - long *oldDirID); -/* ¦ Set the default volume before making Standard I/O requests. - The SetDefault function sets the default volume and directory to the - volume specified by newVRefNum and the directory specified by newDirID. - The current default volume reference number and directory ID are - returned in oldVRefNum and oldDir and must be used to restore the - default volume and directory to their previous state *as soon as - possible* with the RestoreDefault function. These two functions are - designed to be used as a wrapper around Standard I/O routines where - the location of the file is implied to be the default volume and - directory. In other words, this is how you should use these functions: - - error = SetDefault(newVRefNum, newDirID, &oldVRefNum, &oldDirID); - if ( error == noErr ) - { - // call the Stdio functions like remove, rename, tmpfile, - // fopen, freopen, etc. or non-ANSI extensions like - // fdopen,fsetfileinfo, -- create, open, unlink, etc. here! - - error = RestoreDefault(oldVRefNum, oldDirID); - } - - By using these functions as a wrapper, you won't need to open a working - directory (because SetDefault and RestoreDefault use HSetVol) and you - won't have to worry about the effects of using HSetVol (documented in - Technical Note "FL 11 - PBHSetVol is Dangerous" and in the - Inside Macintosh: Files book in the description of the HSetVol and - PBHSetVol functions) because the default volume/directory is restored - before giving up control to code that might be affected by HSetVol. - - newVRefNum input: Volume specification (volume reference number, - working directory number, drive number, or 0) of - the new default volume. - newDirID input: Directory ID of the new default directory. - oldVRefNum output: The volume specification to save for use with - RestoreDefault. - oldDirID output: The directory ID to save for use with - RestoreDefault. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - bdNamErr -37 Bad volume name - fnfErr -43 Directory not found - paramErr -50 No default volume - afpAccessDenied -5000 User does not have access to the directory - - __________ - - Also see: RestoreDefault -*/ - -/*****************************************************************************/ - -pascal OSErr RestoreDefault(short oldVRefNum, - long oldDirID); -/* ¦ Restore the default volume after making Standard C I/O requests. - The RestoreDefault function restores the default volume and directory - to the volume specified by oldVRefNum and the directory specified by - oldDirID. The oldVRefNum and oldDirID parameters were previously - obtained from the SetDefault function. These two functions are designed - to be used as a wrapper around Standard C I/O routines where the - location of the file is implied to be the default volume and directory. - In other words, this is how you should use these functions: - - error = SetDefault(newVRefNum, newDirID, &oldVRefNum, &oldDirID); - if ( error == noErr ) - { - // call the Stdio functions like remove, rename, tmpfile, - // fopen, freopen, etc. or non-ANSI extensions like - // fdopen,fsetfileinfo, -- create, open, unlink, etc. here! - - error = RestoreDefault(oldVRefNum, oldDirID); - } - - By using these functions as a wrapper, you won't need to open a working - directory (because SetDefault and RestoreDefault use HSetVol) and you - won't have to worry about the effects of using HSetVol (documented in - Technical Note "FL 11 - PBHSetVol is Dangerous" and in the - Inside Macintosh: Files book in the description of the HSetVol and - PBHSetVol functions) because the default volume/directory is restored - before giving up control to code that might be affected by HSetVol. - - oldVRefNum input: The volume specification to restore. - oldDirID input: The directory ID to restore. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - bdNamErr -37 Bad volume name - fnfErr -43 Directory not found - paramErr -50 No default volume - rfNumErr -51 Bad working directory reference number - afpAccessDenied -5000 User does not have access to the directory - - __________ - - Also see: SetDefault -*/ - -/*****************************************************************************/ - -pascal OSErr GetDInfo(short vRefNum, - long dirID, - ConstStr255Param name, - DInfo *fndrInfo); -/* ¦ Get the finder information for a directory. - The GetDInfo function gets the finder information for a directory. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - fndrInfo output: If the object is a directory, then its DInfo. - - 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 - dirNFErr -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, FSpGetFInfoCompat -*/ - -/*****************************************************************************/ - -pascal OSErr FSpGetDInfo(const FSSpec *spec, - DInfo *fndrInfo); -/* ¦ Get the finder information for a directory. - The FSpGetDInfo function gets the finder information for a directory. - - spec input: An FSSpec record specifying the directory. - fndrInfo output: If the object is a directory, then its DInfo. - - 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 - dirNFErr -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: FSpGetFInfoCompat, GetDInfo -*/ - -/*****************************************************************************/ - -pascal OSErr SetDInfo(short vRefNum, - long dirID, - ConstStr255Param name, - const DInfo *fndrInfo); -/* ¦ Set the finder information for a directory. - The SetDInfo function sets the finder information for a directory. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - fndrInfo input: The DInfo. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -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: FSpSetDInfo, FSpSetFInfoCompat -*/ - -/*****************************************************************************/ - -pascal OSErr FSpSetDInfo(const FSSpec *spec, - const DInfo *fndrInfo); -/* ¦ Set the finder information for a directory. - The FSpSetDInfo function sets the finder information for a directory. - - spec input: An FSSpec record specifying the directory. - fndrInfo input: The DInfo. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -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: FSpSetFInfoCompat, SetDInfo -*/ - -/*****************************************************************************/ - -#if OLDROUTINENAMES -#define GetDirID(vRefNum, dirID, name, theDirID, isDirectory) \ - GetDirectoryID(vRefNum, dirID, name, theDirID, isDirectory) -#endif - -pascal OSErr GetDirectoryID(short vRefNum, - long dirID, - ConstStr255Param name, - long *theDirID, - Boolean *isDirectory); -/* ¦ Get the directory ID number of the directory specified. - The GetDirectoryID function gets the directory ID number of the - directory specified. If a file is specified, then the parent - directory of the file is returned and isDirectory is false. If - a directory is specified, then that directory's ID number is - returned and isDirectory is true. - WARNING: Volume names on the Macintosh are *not* unique -- Multiple - mounted volumes can have the same name. For this reason, the use of a - volume name or full pathname to identify a specific volume may not - produce the results you expect. If more than one volume has the same - name and a volume name or full pathname is used, the File Manager - currently uses the first volume it finds with a matching name in the - volume queue. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - theDirID output: If the object is a file, then its parent directory - ID. If the object is a directory, then its ID. - isDirectory output: True if object is a directory; false if - object is a file. - - 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 - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname -*/ - -/*****************************************************************************/ - -#if OLDROUTINENAMES -#define DirIDFromFSSpec(spec, theDirID, isDirectory) \ - FSpGetDirectoryID(spec, theDirID, isDirectory) -#endif - -pascal OSErr FSpGetDirectoryID(const FSSpec *spec, - long *theDirID, - Boolean *isDirectory); -/* ¦ Get the directory ID number of a directory. - The FSpGetDirectoryID function gets the directory ID number of the - directory specified by spec. If spec is to a file, then the parent - directory of the file is returned and isDirectory is false. If - spec is to a directory, then that directory's ID number is - returned and isDirectory is true. - - spec input: An FSSpec record specifying the directory. - theDirID output: The directory ID. - isDirectory output: True if object is a directory; false if - object is a file. - - 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 - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname -*/ - -/*****************************************************************************/ - -pascal OSErr GetDirName(short vRefNum, - long dirID, - Str31 name); -/* ¦ Get the name of a directory from its directory ID. - The GetDirName function gets the name of a directory from its - directory ID. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name output: Points to a Str31 where the directory name is to be - returned. - - 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 or - name parameter was NULL - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname -*/ - -/*****************************************************************************/ - -pascal OSErr GetIOACUser(short vRefNum, - long dirID, - ConstStr255Param name, - SInt8 *ioACUser); -/* ¦ Get a directory's access restrictions byte. - GetIOACUser returns a directory's access restrictions byte. - Use the masks and macro defined in MoreFilesExtras to check for - specific access priviledges. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - ioACUser output: The access restriction byte - - 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 - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname -*/ - -/*****************************************************************************/ - -pascal OSErr FSpGetIOACUser(const FSSpec *spec, - SInt8 *ioACUser); -/* ¦ Get a directory's access restrictions byte. - FSpGetIOACUser returns a directory's access restrictions byte. - Use the masks and macro defined in MoreFilesExtras to check for - specific access priviledges. - - spec input: An FSSpec record specifying the directory. - ioACUser output: The access restriction byte - - 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 - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname -*/ - -/*****************************************************************************/ - -pascal OSErr GetParentID(short vRefNum, - long dirID, - ConstStr255Param name, - long *parID); -/* ¦ Get the parent directory ID number of the specified object. - The GetParentID function gets the parent directory ID number of the - specified object. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - parID output: The parent directory ID of the specified object. - - 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 - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname -*/ - -/*****************************************************************************/ - -pascal OSErr GetFilenameFromPathname(ConstStr255Param pathname, - Str255 filename); -/* ¦ Get the object name from the end of a full or partial pathname. - The GetFilenameFromPathname function gets the file (or directory) name - from the end of a full or partial pathname. Returns notAFileErr if the - pathname is nil, the pathname is empty, or the pathname cannot refer to - a filename (with a noErr result, the pathname could still refer to a - directory). - - pathname input: A full or partial pathname. - filename output: The file (or directory) name. - - Result Codes - noErr 0 No error - notAFileErr -1302 The pathname is nil, the pathname - is empty, or the pathname cannot refer - to a filename - - __________ - - See also: GetObjectLocation. -*/ - -/*****************************************************************************/ - -pascal OSErr GetObjectLocation(short vRefNum, - long dirID, - ConstStr255Param pathname, - short *realVRefNum, - long *realParID, - Str255 realName, - Boolean *isDirectory); -/* ¦ Get a file system object's location. - The GetObjectLocation function gets a file system object's location - - that is, its real volume reference number, real parent directory ID, - and name. While we're at it, determine if the object is a file or directory. - If GetObjectLocation returns fnfErr, then the location information - returned is valid, but it describes an object that doesn't exist. - You can use the location information for another operation, such as - creating a file or directory. - - vRefNum input: Volume specification. - dirID input: Directory ID. - pathname input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - realVRefNum output: The real volume reference number. - realParID output: The parent directory ID of the specified object. - realName output: The name of the specified object (the case of the - object name may not be the same as the object's - catalog entry on disk - since the Macintosh file - system is not case sensitive, it shouldn't matter). - isDirectory output: True if object is a directory; false if object - is a file. - - 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 - dirNFErr -120 Directory not found or incomplete pathname - notAFileErr -1302 The pathname is nil, the pathname - is empty, or the pathname cannot refer - to a filename - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSMakeFSSpecCompat -*/ - -/*****************************************************************************/ - -pascal OSErr GetDirItems(short vRefNum, - long dirID, - ConstStr255Param name, - Boolean getFiles, - Boolean getDirectories, - FSSpecPtr items, - short reqItemCount, - short *actItemCount, - short *itemIndex); -/* ¦ Return a list of items in a directory. - The GetDirItems function returns a list of items in the specified - directory in an array of FSSpec records. File, subdirectories, or - both can be returned in the list. - - A noErr result indicates that the items array was filled - (actItemCount == reqItemCount) and there may be additional items - left in the directory. A fnfErr result indicates that the end of - the directory list was found and actItemCount items were actually - found this time. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - getFiles input: Pass true to have files added to the items list. - getDirectories input: Pass true to have directories added to the - items list. - items input: Pointer to array of FSSpec where the item list - is returned. - reqItemCount input: Maximum number of items to return (the number - of elements in the items array). - actItemCount output: The number of items actually returned. - itemIndex input: The current item index position. Set to 1 to - start with the first item in the directory. - output: The item index position to get the next item. - Pass this value the next time you call - GetDirItems to start where you left off. - - Result Codes - noErr 0 No error, but there are more items - to list - nsvErr -35 No such volume - ioErr -36 I/O error - bdNamErr -37 Bad filename - fnfErr -43 File not found, there are no more items - to be listed. - paramErr -50 No default volume or itemIndex was <= 0 - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname -*/ - -/*****************************************************************************/ - -pascal OSErr DeleteDirectoryContents(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Delete the contents of a directory. - The DeleteDirectoryContents function deletes the contents of a directory. - All files and subdirectories in the specified directory are deleted. - If a locked file or directory is encountered, it is unlocked and then - deleted. If any unexpected errors are encountered, - DeleteDirectoryContents quits and returns to the caller. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to directory name, or nil when dirID specifies - a directory that's the object. - - 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 - paramErr -50 No default volume - dirNFErr -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: DeleteDirectory -*/ - -/*****************************************************************************/ - -pascal OSErr DeleteDirectory(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Delete a directory and its contents. - The DeleteDirectory function deletes a directory and its contents. - All files and subdirectories in the specified directory are deleted. - If a locked file or directory is encountered, it is unlocked and then - deleted. After deleting the directories contents, the directory is - deleted. If any unexpected errors are encountered, DeleteDirectory - quits and returns to the caller. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to directory name, or nil when dirID specifies - a directory that's the object. - - 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 - paramErr -50 No default volume - dirNFErr -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: DeleteDirectoryContents -*/ - -/*****************************************************************************/ - -pascal OSErr CheckObjectLock(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Determine if a file or directory is locked. - The CheckObjectLock function determines if a file or directory is locked. - If CheckObjectLock returns noErr, then the file or directory - is not locked. If CheckObjectLock returns fLckdErr, the it is locked. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - paramErr -50 No default volume - dirNFErr -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: FSpCheckObjectLock -*/ - -/*****************************************************************************/ - -pascal OSErr FSpCheckObjectLock(const FSSpec *spec); -/* ¦ Determine if a file or directory is locked. - The FSpCheckObjectLock function determines if a file or directory is locked. - If FSpCheckObjectLock returns noErr, then the file or directory - is not locked. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - paramErr -50 No default volume - dirNFErr -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: CheckObjectLock -*/ - -/*****************************************************************************/ - -pascal OSErr GetFileSize(short vRefNum, - long dirID, - ConstStr255Param fileName, - long *dataSize, - long *rsrcSize); -/* ¦ Get the logical sizes of a file's forks. - The GetFileSize function returns the logical size of a file's - data and resource fork. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: The name of the file. - dataSize output: The number of bytes in the file's data fork. - rsrcSize output: The number of bytes in 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 - 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 - - __________ - - See also: FSpGetFileSize -*/ - -/*****************************************************************************/ - -pascal OSErr FSpGetFileSize(const FSSpec *spec, - long *dataSize, - long *rsrcSize); -/* ¦ Get the logical sizes of a file's forks. - The FSpGetFileSize function returns the logical size of a file's - data and resource fork. - - spec input: An FSSpec record specifying the file. - dataSize output: The number of bytes in the file's data fork. - rsrcSize output: The number of bytes in 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 - 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 - - __________ - - See also: GetFileSize -*/ - -/*****************************************************************************/ - -pascal OSErr BumpDate(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Update the modification date of a file or directory. - The BumpDate function changes the modification date of a file or - directory to the current date/time. If the modification date is already - equal to the current date/time, then add one second to the - modification date. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpBumpDate -*/ - -/*****************************************************************************/ - -pascal OSErr FSpBumpDate(const FSSpec *spec); -/* ¦ Update the modification date of a file or directory. - The FSpBumpDate function changes the modification date of a file or - directory to the current date/time. If the modification date is already - equal to the current date/time, then add one second to the - modification date. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: BumpDate -*/ - -/*****************************************************************************/ - -pascal OSErr ChangeCreatorType(short vRefNum, - long dirID, - ConstStr255Param name, - OSType creator, - OSType fileType); -/* ¦ Change the creator or file type of a file. - The ChangeCreatorType function changes the creator or file type of a file. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: The name of the file. - creator input: The new creator type or 0x00000000 to leave - the creator type alone. - fileType input: The new file type or 0x00000000 to leave the - file type alone. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - notAFileErr -1302 Name was not a file - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpChangeCreatorType -*/ - -/*****************************************************************************/ - -pascal OSErr FSpChangeCreatorType(const FSSpec *spec, - OSType creator, - OSType fileType); -/* ¦ Change the creator or file type of a file. - The FSpChangeCreatorType function changes the creator or file type of a file. - - spec input: An FSSpec record specifying the file. - creator input: The new creator type or 0x00000000 to leave - the creator type alone. - fileType input: The new file type or 0x00000000 to leave the - file type alone. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - notAFileErr -1302 Name was not a file - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: ChangeCreatorType -*/ - -/*****************************************************************************/ - -pascal OSErr ChangeFDFlags(short vRefNum, - long dirID, - ConstStr255Param name, - Boolean setBits, - unsigned short flagBits); -/* ¦ Set or clear Finder Flag bits. - The ChangeFDFlags function sets or clears Finder Flag bits in the - fdFlags field of a file or directory's FInfo record. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - setBits input: If true, then set the bits specified in flagBits. - If false, then clear the bits specified in flagBits. - flagBits input: The flagBits parameter specifies which Finder Flag - bits to set or clear. If a bit in flagBits is set, - then the same bit in fdFlags is either set or - cleared depending on the state of the setBits - parameter. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpChangeFDFlags -*/ - -/*****************************************************************************/ - -pascal OSErr FSpChangeFDFlags(const FSSpec *spec, - Boolean setBits, - unsigned short flagBits); -/* ¦ Set or clear Finder Flag bits. - The FSpChangeFDFlags function sets or clears Finder Flag bits in the - fdFlags field of a file or directory's FInfo record. - - spec input: An FSSpec record specifying the object. - setBits input: If true, then set the bits specified in flagBits. - If false, then clear the bits specified in flagBits. - flagBits input: The flagBits parameter specifies which Finder Flag - bits to set or clear. If a bit in flagBits is set, - then the same bit in fdFlags is either set or - cleared depending on the state of the setBits - parameter. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: ChangeFDFlags -*/ - -/*****************************************************************************/ - -pascal OSErr SetIsInvisible(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Set the invisible Finder Flag bit. - The SetIsInvisible function sets the invisible bit in the fdFlags - word of the specified file or directory's finder information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpSetIsInvisible, ClearIsInvisible, FSpClearIsInvisible -*/ - -/*****************************************************************************/ - -pascal OSErr FSpSetIsInvisible(const FSSpec *spec); -/* ¦ Set the invisible Finder Flag bit. - The FSpSetIsInvisible function sets the invisible bit in the fdFlags - word of the specified file or directory's finder information. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetIsInvisible, ClearIsInvisible, FSpClearIsInvisible -*/ - -/*****************************************************************************/ - -pascal OSErr ClearIsInvisible(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Clear the invisible Finder Flag bit. - The ClearIsInvisible function clears the invisible bit in the fdFlags - word of the specified file or directory's finder information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetIsInvisible, FSpSetIsInvisible, FSpClearIsInvisible -*/ - -/*****************************************************************************/ - -pascal OSErr FSpClearIsInvisible(const FSSpec *spec); -/* ¦ Clear the invisible Finder Flag bit. - The FSpClearIsInvisible function clears the invisible bit in the fdFlags - word of the specified file or directory's finder information. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetIsInvisible, FSpSetIsInvisible, ClearIsInvisible -*/ - -/*****************************************************************************/ - -pascal OSErr SetNameLocked(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Set the nameLocked Finder Flag bit. - The SetNameLocked function sets the nameLocked bit in the fdFlags word - of the specified file or directory's finder information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpSetNameLocked, ClearNameLocked, FSpClearNameLocked -*/ - -/*****************************************************************************/ - -pascal OSErr FSpSetNameLocked(const FSSpec *spec); -/* ¦ Set the nameLocked Finder Flag bit. - The FSpSetNameLocked function sets the nameLocked bit in the fdFlags word - of the specified file or directory's finder information. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetNameLocked, ClearNameLocked, FSpClearNameLocked -*/ - -/*****************************************************************************/ - -pascal OSErr ClearNameLocked(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Clear the nameLocked Finder Flag bit. - The ClearNameLocked function clears the nameLocked bit in the fdFlags - word of the specified file or directory's finder information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetNameLocked, FSpSetNameLocked, FSpClearNameLocked -*/ - -/*****************************************************************************/ - -pascal OSErr FSpClearNameLocked(const FSSpec *spec); -/* ¦ Clear the nameLocked Finder Flag bit. - The FSpClearNameLocked function clears the nameLocked bit in the fdFlags - word of the specified file or directory's finder information. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetNameLocked, FSpSetNameLocked, ClearNameLocked -*/ - -/*****************************************************************************/ - -pascal OSErr SetIsStationery(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Set the isStationery Finder Flag bit. - The SetIsStationery function sets the isStationery bit in the - fdFlags word of the specified file or directory's finder information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpSetIsStationery, ClearIsStationery, FSpClearIsStationery -*/ - -/*****************************************************************************/ - -pascal OSErr FSpSetIsStationery(const FSSpec *spec); -/* ¦ Set the isStationery Finder Flag bit. - The FSpSetIsStationery function sets the isStationery bit in the - fdFlags word of the specified file or directory's finder information. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetIsStationery, ClearIsStationery, FSpClearIsStationery -*/ - -/*****************************************************************************/ - -pascal OSErr ClearIsStationery(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Clear the isStationery Finder Flag bit. - The ClearIsStationery function clears the isStationery bit in the - fdFlags word of the specified file or directory's finder information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetIsStationery, FSpSetIsStationery, FSpClearIsStationery -*/ - -/*****************************************************************************/ - -pascal OSErr FSpClearIsStationery(const FSSpec *spec); -/* ¦ Clear the isStationery Finder Flag bit. - The FSpClearIsStationery function clears the isStationery bit in the - fdFlags word of the specified file or directory's finder information. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetIsStationery, FSpSetIsStationery, ClearIsStationery -*/ - -/*****************************************************************************/ - -pascal OSErr SetHasCustomIcon(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Set the hasCustomIcon Finder Flag bit. - The SetHasCustomIcon function sets the hasCustomIcon bit in the - fdFlags word of the specified file or directory's finder information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpSetHasCustomIcon, ClearHasCustomIcon, FSpClearHasCustomIcon -*/ - -/*****************************************************************************/ - -pascal OSErr FSpSetHasCustomIcon(const FSSpec *spec); -/* ¦ Set the hasCustomIcon Finder Flag bit. - The FSpSetHasCustomIcon function sets the hasCustomIcon bit in the - fdFlags word of the specified file or directory's finder information. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetHasCustomIcon, ClearHasCustomIcon, FSpClearHasCustomIcon -*/ - -/*****************************************************************************/ - -pascal OSErr ClearHasCustomIcon(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Clear the hasCustomIcon Finder Flag bit. - The ClearHasCustomIcon function clears the hasCustomIcon bit in the - fdFlags word of the specified file or directory's finder information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetHasCustomIcon, FSpSetHasCustomIcon, FSpClearHasCustomIcon -*/ - -/*****************************************************************************/ - -pascal OSErr FSpClearHasCustomIcon(const FSSpec *spec); -/* ¦ Clear the hasCustomIcon Finder Flag bit. - The FSpClearHasCustomIcon function clears the hasCustomIcon bit in the - fdFlags word of the specified file or directory's finder information. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: SetHasCustomIcon, FSpSetHasCustomIcon, ClearHasCustomIcon -*/ - -/*****************************************************************************/ - -pascal OSErr ClearHasBeenInited(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Clear the hasBeenInited Finder Flag bit. - The ClearHasBeenInited function clears the hasBeenInited bit in the - fdFlags word of the specified file or directory's finder information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID specifies - a directory that's the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpClearHasBeenInited -*/ - -/*****************************************************************************/ - -pascal OSErr FSpClearHasBeenInited(const FSSpec *spec); -/* ¦ Clear the hasBeenInited Finder Flag bit. - The FSpClearHasBeenInited function clears the hasBeenInited bit in the - fdFlags word of the specified file or directory's finder information. - - spec input: An FSSpec record specifying the object. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: ClearHasBeenInited -*/ - -/*****************************************************************************/ - -pascal OSErr CopyFileMgrAttributes(short srcVRefNum, - long srcDirID, - ConstStr255Param srcName, - short dstVRefNum, - long dstDirID, - ConstStr255Param dstName, - Boolean copyLockBit); -/* ¦ Copy all File Manager attributes from the source to the destination. - The CopyFileMgrAttributes function copies all File Manager attributes - from the source file or directory to the destination file or directory. - If copyLockBit is true, then set the locked state of the destination - to match the source. - - srcVRefNum input: Source volume specification. - srcDirID input: Source directory ID. - srcName input: Pointer to source object name, or nil when - srcDirID specifies a directory that's the object. - dstVRefNum input: Destination volume specification. - dstDirID input: Destination directory ID. - dstName input: Pointer to destination object name, or nil when - dstDirID specifies a directory that's the object. - copyLockBit input: If true, set the locked state of the destination - to match the source. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: FSpCopyFileMgrAttributes -*/ - -/*****************************************************************************/ - -pascal OSErr FSpCopyFileMgrAttributes(const FSSpec *srcSpec, - const FSSpec *dstSpec, - Boolean copyLockBit); -/* ¦ Copy all File Manager attributes from the source to the destination. - The FSpCopyFileMgrAttributes function copies all File Manager attributes - from the source file or directory to the destination file or directory. - If copyLockBit is true, then set the locked state of the destination - to match the source. - - srcSpec input: An FSSpec record specifying the source object. - dstSpec input: An FSSpec record specifying the destination object. - copyLockBit input: If true, set the locked state of the destination - to match the source. - - 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 - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - paramErr -50 No default volume - dirNFErr -120 Directory not found or incomplete pathname - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Directory not found or incomplete pathname - - __________ - - See also: CopyFileMgrAttributes -*/ - -/*****************************************************************************/ - -pascal OSErr HOpenAware(short vRefNum, - long dirID, - ConstStr255Param fileName, - short denyModes, - short *refNum); -/* ¦ Open the data fork of a file using deny mode permissions. - The HOpenAware function opens the data fork of a file using deny mode - permissions instead the normal File Manager permissions. If OpenDeny - is not available, then HOpenAware translates the deny modes to the - closest File Manager permissions and tries to open the file with - OpenDF first, and then Open if OpenDF isn't available. By using - HOpenAware with deny mode permissions, a program can be "AppleShare - aware" and fall back on the standard File Manager open calls - automatically. - - vRefNum input: Volume specification. - dirID input: Directory ID. - fileName input: The name of the file. - denyModes input: The deny modes access under which to open the file. - refNum output: The file reference number of the opened file. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - tmfoErr -42 Too many files open - fnfErr -43 File not found - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - opWrErr -49 File already open for writing - paramErr -50 No default volume - permErr -54 File is already open and cannot be opened using specified deny modes - afpAccessDenied -5000 User does not have the correct access to the file - afpDenyConflict -5006 Requested access permission not possible - - __________ - - See also: FSpOpenAware, HOpenRFAware, FSpOpenRFAware -*/ - -/*****************************************************************************/ - -pascal OSErr FSpOpenAware(const FSSpec *spec, - short denyModes, - short *refNum); -/* ¦ Open the data fork of a file using deny mode permissions. - The FSpOpenAware function opens the data fork of a file using deny mode - permissions instead the normal File Manager permissions. If OpenDeny - is not available, then FSpOpenAware translates the deny modes to the - closest File Manager permissions and tries to open the file with - OpenDF first, and then Open if OpenDF isn't available. By using - FSpOpenAware with deny mode permissions, a program can be "AppleShare - aware" and fall back on the standard File Manager open calls - automatically. - - spec input: An FSSpec record specifying the file. - denyModes input: The deny modes access under which to open the file. - refNum output: The file reference number of the opened file. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - tmfoErr -42 Too many files open - fnfErr -43 File not found - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - opWrErr -49 File already open for writing - paramErr -50 No default volume - permErr -54 File is already open and cannot be opened using specified deny modes - afpAccessDenied -5000 User does not have the correct access to the file - afpDenyConflict -5006 Requested access permission not possible - - __________ - - See also: HOpenAware, HOpenRFAware, FSpOpenRFAware -*/ - -/*****************************************************************************/ - -pascal OSErr HOpenRFAware(short vRefNum, - long dirID, - ConstStr255Param fileName, - short denyModes, - short *refNum); -/* ¦ Open the resource fork of a file using deny mode permissions. - The HOpenRFAware function opens the resource fork of a file using deny - mode permissions instead the normal File Manager permissions. If - OpenRFDeny is not available, then HOpenRFAware translates the deny - modes to the closest File Manager permissions and tries to open the - file with OpenRF. By using HOpenRFAware with deny mode permissions, - a program can be "AppleShare aware" and fall back on the standard - File Manager open calls automatically. - - vRefNum input: Volume specification. - dirID input: Directory ID. - fileName input: The name of the file. - denyModes input: The deny modes access under which to open the file. - refNum output: The file reference number of the opened file. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - tmfoErr -42 Too many files open - fnfErr -43 File not found - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - opWrErr -49 File already open for writing - paramErr -50 No default volume - permErr -54 File is already open and cannot be opened using specified deny modes - afpAccessDenied -5000 User does not have the correct access to the file - afpDenyConflict -5006 Requested access permission not possible - - __________ - - See also: HOpenAware, FSpOpenAware, FSpOpenRFAware -*/ - -/*****************************************************************************/ - -pascal OSErr FSpOpenRFAware(const FSSpec *spec, - short denyModes, - short *refNum); -/* ¦ Open the resource fork of a file using deny mode permissions. - The FSpOpenRFAware function opens the resource fork of a file using deny - mode permissions instead the normal File Manager permissions. If - OpenRFDeny is not available, then FSpOpenRFAware translates the deny - modes to the closest File Manager permissions and tries to open the - file with OpenRF. By using FSpOpenRFAware with deny mode permissions, - a program can be "AppleShare aware" and fall back on the standard - File Manager open calls automatically. - - spec input: An FSSpec record specifying the file. - denyModes input: The deny modes access under which to open the file. - refNum output: The file reference number of the opened file. - - Result Codes - noErr 0 No error - nsvErr -35 No such volume - tmfoErr -42 Too many files open - fnfErr -43 File not found - wPrErr -44 Volume locked by hardware - fLckdErr -45 File is locked - vLckdErr -46 Volume is locked or read-only - opWrErr -49 File already open for writing - paramErr -50 No default volume - permErr -54 File is already open and cannot be opened using specified deny modes - afpAccessDenied -5000 User does not have the correct access to the file - afpDenyConflict -5006 Requested access permission not possible - - __________ - - See also: HOpenAware, FSpOpenAware, HOpenRFAware -*/ - -/*****************************************************************************/ - -pascal OSErr FSReadNoCache(short refNum, - long *count, - void *buffPtr); -/* ¦ Read any number of bytes from an open file requesting no caching. - The FSReadNoCache function reads any number of bytes from an open file - while asking the file system to bypass its cache mechanism. - - refNum input: The file reference number of an open file. - count input: The number of bytes to read. - output: The number of bytes actually read. - buffPtr input: A pointer to the data buffer into which the bytes are - to be read. - - Result Codes - noErr 0 No error - readErr Ð19 Driver does not respond to read requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - ioErr Ð36 Data does not match in read-verify mode - fnOpnErr -38 File not open - rfNumErr -51 Bad reference number - afpAccessDenied -5000 User does not have the correct access to - the file - - __________ - - See also: FSWriteNoCache -*/ - -/*****************************************************************************/ - -pascal OSErr FSWriteNoCache(short refNum, - long *count, - const void *buffPtr); -/* ¦ Write any number of bytes to an open file requesting no caching. - The FSReadNoCache function writes any number of bytes to an open file - while asking the file system to bypass its cache mechanism. - - refNum input: The file reference number of an open file. - count input: The number of bytes to write to the file. - output: The number of bytes actually written. - buffPtr input: A pointer to the data buffer from which the bytes are - to be written. - - Result Codes - noErr 0 No error - writErr Ð20 Driver does not respond to write requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - dskFulErr -34 Disk full - ioErr Ð36 Data does not match in read-verify mode - fnOpnErr -38 File not open - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock - rfNumErr -51 Bad reference number - wrPermErr -61 Read/write permission doesnÕt - allow writing - afpAccessDenied -5000 User does not have the correct access to - the file - - __________ - - See also: FSReadNoCache -*/ - -/*****************************************************************************/ - -pascal OSErr FSWriteVerify(short refNum, - long *count, - const void *buffPtr); -/* ¦ Write any number of bytes to an open file and then verify the data was written. - The FSWriteVerify function writes any number of bytes to an open file - and then verifies that the data was actually written to the device. - - refNum input: The file reference number of an open file. - count input: The number of bytes to write to the file. - output: The number of bytes actually written and verified. - buffPtr input: A pointer to the data buffer from which the bytes are - to be written. - - Result Codes - noErr 0 No error - readErr Ð19 Driver does not respond to read requests - writErr Ð20 Driver does not respond to write requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - dskFulErr -34 Disk full - ioErr Ð36 Data does not match in read-verify mode - fnOpnErr -38 File not open - eofErr -39 Logical end-of-file reached - posErr -40 Attempt to position mark before start - of file - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock - rfNumErr -51 Bad reference number - gfpErr -52 Error during GetFPos - wrPermErr -61 Read/write permission doesnÕt - allow writing - memFullErr -108 Not enough room in heap zone to allocate - verify buffer - afpAccessDenied -5000 User does not have the correct access to - the file -*/ - -/*****************************************************************************/ - -pascal OSErr CopyFork(short srcRefNum, - short dstRefNum, - void *copyBufferPtr, - long copyBufferSize); -/* ¦ Copy all data from the source fork to the destination fork of open file forks. - The CopyFork function copies all data from the source fork to the - destination fork of open file forks and makes sure the destination EOF - is equal to the source EOF. - - srcRefNum input: The source file reference number. - dstRefNum input: The destination file reference number. - copyBufferPtr input: Pointer to buffer to use during copy. The - buffer should be at least 512-bytes minimum. - The larger the buffer, the faster the copy. - copyBufferSize input: The size of the copy buffer. - - Result Codes - noErr 0 No error - readErr Ð19 Driver does not respond to read requests - writErr Ð20 Driver does not respond to write requests - badUnitErr Ð21 Driver reference number does not - match unit table - unitEmptyErr Ð22 Driver reference number specifies a - nil handle in unit table - abortErr Ð27 Request aborted by KillIO - notOpenErr Ð28 Driver not open - dskFulErr -34 Disk full - ioErr Ð36 Data does not match in read-verify mode - fnOpnErr -38 File not open - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Software volume lock - rfNumErr -51 Bad reference number - wrPermErr -61 Read/write permission doesnÕt - allow writing - afpAccessDenied -5000 User does not have the correct access to - the file -*/ - -/*****************************************************************************/ - -pascal OSErr GetFileLocation(short refNum, - short *vRefNum, - long *dirID, - StringPtr fileName); -/* ¦ Get the location of an open file. - The GetFileLocation function gets the location (volume reference number, - directory ID, and fileName) of an open file. - - refNum input: The file reference number of an open file. - vRefNum output: The volume reference number. - dirID output: The parent directory ID. - fileName input: Points to a buffer (minimum Str63) where the - filename is to be returned or must be nil. - output: The filename. - - Result Codes - noErr 0 No error - nsvErr -35 Specified volume doesnÕt exist - fnOpnErr -38 File not open - rfNumErr -51 Reference number specifies nonexistent - access path - - __________ - - See also: FSpGetFileLocation -*/ - -/*****************************************************************************/ - -pascal OSErr FSpGetFileLocation(short refNum, - FSSpec *spec); -/* ¦ Get the location of an open file in an FSSpec record. - The FSpGetFileLocation function gets the location of an open file in - an FSSpec record. - - refNum input: The file reference number of an open file. - spec output: FSSpec record containing the file name and location. - - Result Codes - noErr 0 No error - nsvErr -35 Specified volume doesnÕt exist - fnOpnErr -38 File not open - rfNumErr -51 Reference number specifies nonexistent - access path - - __________ - - See also: GetFileLocation -*/ - -/*****************************************************************************/ - -pascal OSErr CopyDirectoryAccess(short srcVRefNum, - long srcDirID, - ConstStr255Param srcName, - short dstVRefNum, - long dstDirID, - ConstStr255Param dstName); -/* ¦ Copy the AFP directory access privileges. - The CopyDirectoryAccess function copies the AFP directory access - privileges from one directory to another. Both directories must be on - the same file server, but not necessarily on the same server volume. - - srcVRefNum input: Source volume specification. - srcDirID input: Source directory ID. - srcName input: Pointer to source directory name, or nil when - srcDirID specifies the directory. - dstVRefNum input: Destination volume specification. - dstDirID input: Destination directory ID. - dstName input: Pointer to destination directory name, or nil when - dstDirID specifies the directory. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - fnfErr -43 Directory not found - vLckdErr -46 Volume is locked or read-only - paramErr -50 Volume doesn't support this function - afpAccessDenied -5000 User does not have the correct access - to the directory - afpObjectTypeErr -5025 Object is a file, not a directory - - __________ - - See also: FSpCopyDirectoryAccess -*/ - -/*****************************************************************************/ - -pascal OSErr FSpCopyDirectoryAccess(const FSSpec *srcSpec, - const FSSpec *dstSpec); -/* ¦ Copy the AFP directory access privileges. - The FSpCopyDirectoryAccess function copies the AFP directory access - privileges from one directory to another. Both directories must be on - the same file server, but not necessarily on the same server volume. - - srcSpec input: An FSSpec record specifying the source directory. - dstSpec input: An FSSpec record specifying the destination directory. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - fnfErr -43 Directory not found - vLckdErr -46 Volume is locked or read-only - paramErr -50 Volume doesn't support this function - afpAccessDenied -5000 User does not have the correct access - to the directory - afpObjectTypeErr -5025 Object is a file, not a directory - - __________ - - See also: CopyDirectoryAccess -*/ - -/*****************************************************************************/ - -pascal OSErr HMoveRenameCompat(short vRefNum, - long srcDirID, - ConstStr255Param srcName, - long dstDirID, - ConstStr255Param dstpathName, - ConstStr255Param copyName); -/* ¦ Move a file or directory and optionally rename it. - The HMoveRenameCompat function moves a file or directory and optionally - renames it. The source and destination locations must be on the same - volume. This routine works even if the volume doesn't support MoveRename. - - vRefNum input: Volume specification. - srcDirID input: Source directory ID. - srcName input: The source object name. - dstDirID input: Destination directory ID. - dstName input: Pointer to destination directory name, or - nil when dstDirID specifies a directory. - copyName input: Points to the new name if the object is to be - renamed or nil if the object isn't to be renamed. - - Result Codes - noErr 0 No error - dirFulErr -33 File directory full - dskFulErr -34 Disk is full - nsvErr -35 Volume not found - ioErr -36 I/O error - bdNamErr -37 Bad filename or attempt to move into - a file - fnfErr -43 Source file or directory not found - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - fBsyErr -47 File busy, directory not empty, or - working directory control block open - dupFNErr -48 Destination already exists - paramErr -50 Volume doesn't support this function, - no default volume, or source and - volOfflinErr -53 Volume is offline - fsRnErr -59 Problem during rename - dirNFErr -120 Directory not found or incomplete pathname - badMovErr -122 Attempted to move directory into - offspring - wrgVolTypErr -123 Not an HFS volume (it's a MFS volume) - notAFileErr -1302 The pathname is nil, the pathname - is empty, or the pathname cannot refer - to a filename - diffVolErr -1303 Files on different volumes - afpAccessDenied -5000 The user does not have the right to - move the file or directory - afpObjectTypeErr -5025 Directory not found or incomplete pathname - afpSameObjectErr -5038 Source and destination files are the same - - __________ - - See also: FSpMoveRenameCompat -*/ - -/*****************************************************************************/ - -pascal OSErr FSpMoveRenameCompat(const FSSpec *srcSpec, - const FSSpec *dstSpec, - ConstStr255Param copyName); -/* ¦ Move a file or directory and optionally rename it. - The FSpMoveRenameCompat function moves a file or directory and optionally - renames it. The source and destination locations must be on the same - volume. This routine works even if the volume doesn't support MoveRename. - - srcSpec input: An FSSpec record specifying the source object. - dstSpec input: An FSSpec record specifying the destination - directory. - copyName input: Points to the new name if the object is to be - renamed or nil if the object isn't to be renamed. - - Result Codes - noErr 0 No error - dirFulErr -33 File directory full - dskFulErr -34 Disk is full - nsvErr -35 Volume not found - ioErr -36 I/O error - bdNamErr -37 Bad filename or attempt to move into - a file - fnfErr -43 Source file or directory not found - wPrErr -44 Hardware volume lock - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - fBsyErr -47 File busy, directory not empty, or - working directory control block open - dupFNErr -48 Destination already exists - paramErr -50 Volume doesn't support this function, - no default volume, or source and - volOfflinErr -53 Volume is offline - fsRnErr -59 Problem during rename - dirNFErr -120 Directory not found or incomplete pathname - badMovErr -122 Attempted to move directory into - offspring - wrgVolTypErr -123 Not an HFS volume (it's a MFS volume) - notAFileErr -1302 The pathname is nil, the pathname - is empty, or the pathname cannot refer - to a filename - diffVolErr -1303 Files on different volumes - afpAccessDenied -5000 The user does not have the right to - move the file or directory - afpObjectTypeErr -5025 Directory not found or incomplete pathname - afpSameObjectErr -5038 Source and destination files are the same - - __________ - - See also: HMoveRenameCompat -*/ - -/*****************************************************************************/ - -pascal OSErr BuildAFPVolMountInfo(short flags, - char nbpInterval, - char nbpCount, - short uamType, - Str32 zoneName, - Str31 serverName, - Str27 volName, - Str31 userName, - Str8 userPassword, - Str8 volPassword, - AFPVolMountInfoPtr *afpInfoPtr); -/* ¦ Allocate and initializes the fields of an AFPVolMountInfo record. - The BuildAFPVolMountInfo function allocates and initializes the fields - of an AFPVolMountInfo record before using that record to call - the VolumeMount function. - - flags input: The AFP mounting flags. 0 = normal mount; - set bit 0 to inhibit greeting messages. - nbpInterval input: The interval used for VolumeMount's - NBP Lookup call. 7 is a good choice. - nbpCount input: The retry count used for VolumeMount's - NBP Lookup call. 5 is a good choice. - uamType input: The user authentication method to use. - zoneName input: The AppleTalk zone name of the server. - serverName input: The AFP server name. - volName input: The AFP volume name. - userName input: The user name (zero length Pascal string for - guest). - userPassWord input: The user password (zero length Pascal string - if no user password) - volPassWord input: The volume password (zero length Pascal string - if no volume password) - afpInfoPtr output: A pointer to the newly created and initialized - AFPVolMountInfo record. If the function fails to - create an AFPVolMountInfo record, it sets - afpInfoPtr to NULL and the function result is - memFullErr. Your program is responsible - for disposing of this pointer when it is finished - with it. - - Result Codes - noErr 0 No error - memFullErr -108 memory full error - - __________ - - Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, - RetrieveAFPVolMountInfo, BuildAFPXVolMountInfo, - RetrieveAFPXVolMountInfo -*/ - -/*****************************************************************************/ - -pascal OSErr RetrieveAFPVolMountInfo(AFPVolMountInfoPtr afpInfoPtr, - short *flags, - short *uamType, - StringPtr zoneName, - StringPtr serverName, - StringPtr volName, - StringPtr userName); -/* ¦ Retrieve the AFP mounting information from an AFPVolMountInfo record. - The RetrieveAFPVolMountInfo function retrieves the AFP mounting - information returned in an AFPVolMountInfo record by the - GetVolMountInfo function. - - afpInfoPtr input: Pointer to AFPVolMountInfo record that contains - the AFP mounting information. - flags output: The AFP mounting flags. - uamType output: The user authentication method used. - zoneName output: The AppleTalk zone name of the server. - serverName output: The AFP server name. - volName output: The AFP volume name. - userName output: The user name (zero length Pascal string for - guest). - - Result Codes - noErr 0 No error - paramErr -50 media field in AFP mounting information - was not AppleShareMediaType - - __________ - - Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, - BuildAFPVolMountInfo, BuildAFPXVolMountInfo, - RetrieveAFPXVolMountInfo -*/ - -/*****************************************************************************/ - -pascal OSErr BuildAFPXVolMountInfo(short flags, - char nbpInterval, - char nbpCount, - short uamType, - Str32 zoneName, - Str31 serverName, - Str27 volName, - Str31 userName, - Str8 userPassword, - Str8 volPassword, - Str32 uamName, - unsigned long alternateAddressLength, - void *alternateAddress, - AFPXVolMountInfoPtr *afpXInfoPtr); -/* ¦ Allocate and initializes the fields of an AFPXVolMountInfo record. - The BuildAFPXVolMountInfo function allocates and initializes the fields - of an AFPXVolMountInfo record before using that record to call - the VolumeMount function. - - flags input: The AFP mounting flags. - nbpInterval input: The interval used for VolumeMount's - NBP Lookup call. 7 is a good choice. - nbpCount input: The retry count used for VolumeMount's - NBP Lookup call. 5 is a good choice. - uamType input: The user authentication method to use. - zoneName input: The AppleTalk zone name of the server. - serverName input: The AFP server name. - volName input: The AFP volume name. - userName input: The user name (zero length Pascal string - for guest). - userPassWord input: The user password (zero length Pascal - string if no user password) - volPassWord input: The volume password (zero length Pascal - string if no volume password) - uamName input: The User Authentication Method name. - alternateAddressLength input: Length of alternateAddress data. - alternateAddress input The AFPAlternateAddress (variable length) - afpXInfoPtr output: A pointer to the newly created and - initialized AFPVolMountInfo record. - If the function fails to create an - AFPVolMountInfo record, it sets - afpInfoPtr to NULL and the function - result is memFullErr. Your program is - responsible for disposing of this pointer - when it is finished with it. - - Result Codes - noErr 0 No error - memFullErr -108 memory full error - - __________ - - Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, - BuildAFPVolMountInfo, RetrieveAFPVolMountInfo, - RetrieveAFPXVolMountInfo -*/ - -/*****************************************************************************/ - -pascal OSErr RetrieveAFPXVolMountInfo(AFPXVolMountInfoPtr afpXInfoPtr, - short *flags, - short *uamType, - StringPtr zoneName, - StringPtr serverName, - StringPtr volName, - StringPtr userName, - StringPtr uamName, - unsigned long *alternateAddressLength, - AFPAlternateAddress **alternateAddress); -/* ¦ Retrieve the AFP mounting information from an AFPXVolMountInfo record. - The RetrieveAFPXVolMountInfo function retrieves the AFP mounting - information returned in an AFPXVolMountInfo record by the - GetVolMountInfo function. - - afpXInfoPtr input: Pointer to AFPXVolMountInfo record that - contains the AFP mounting information. - flags output: The AFP mounting flags. - uamType output: The user authentication method used. - zoneName output: The AppleTalk zone name of the server. - serverName output: The AFP server name. - volName output: The AFP volume name. - userName output: The user name (zero length Pascal - string for guest). - uamName output: The User Authentication Method name. - alternateAddressLength output: Length of alternateAddress data returned. - alternateAddress: output: A pointer to the newly created and - AFPAlternateAddress record (a variable - length record). If the function fails to - create an AFPAlternateAddress record, - it sets alternateAddress to NULL and the - function result is memFullErr. Your - program is responsible for disposing of - this pointer when it is finished with it. - - Result Codes - noErr 0 No error - paramErr -50 media field in AFP mounting information - was not AppleShareMediaType - memFullErr -108 memory full error - - __________ - - Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, - BuildAFPVolMountInfo, RetrieveAFXVolMountInfo, - BuildAFPXVolMountInfo -*/ - -/*****************************************************************************/ - -pascal OSErr GetUGEntries(short objType, - UGEntryPtr entries, - long reqEntryCount, - long *actEntryCount, - long *objID); -/* ¦ Retrieve a list of user or group entries from the local file server. - The GetUGEntries functions retrieves a list of user or group entries - from the local file server. - - objType input: The object type: -1 = group; 0 = user - UGEntries input: Pointer to array of UGEntry records where the list - is returned. - reqEntryCount input: The number of elements in the UGEntries array. - actEntryCount output: The number of entries returned. - objID input: The current index position. Set to 0 to start with - the first entry. - output: The index position to get the next entry. Pass this - value the next time you call GetUGEntries to start - where you left off. - - Result Codes - noErr 0 No error - fnfErr -43 No more users or groups - paramErr -50 Function not supported; or, ioObjID is - negative - - __________ - - Also see: GetUGEntry -*/ - -/*****************************************************************************/ - -#ifdef __cplusplus -} -#endif - -#include "optimend.h" - -#endif /* __MOREFILESEXTRAS__ */ diff --git a/src/mac/morefile/MoreFile.h b/src/mac/morefile/MoreFile.h deleted file mode 100644 index a2b069279c..0000000000 --- a/src/mac/morefile/MoreFile.h +++ /dev/null @@ -1,1244 +0,0 @@ -/* -** Apple Macintosh Developer Technical Support -** -** The long lost high-level and FSSpec File Manager functions. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: MoreFiles.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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 __MOREFILES__ -#define __MOREFILES__ - -#include -#include - -#ifndef true -#define true 1 -#define false 0 -#endif - -#include "optim.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************************/ - -pascal OSErr HGetVolParms(ConstStr255Param volName, - short vRefNum, - GetVolParmsInfoBuffer *volParmsInfo, - long *infoSize); -/* ¦ Determine the characteristics of a volume. - The HGetVolParms function returns information about the characteristics - of a volume. A result of paramErr usually just means the volume doesn't - support PBHGetVolParms and the feature you were going to check - for isn't available. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - volParmsInfo input: Pointer to GetVolParmsInfoBuffer where the - volume attributes information is returned. - output: Atributes information. - infoSize input: Size of buffer pointed to by volParmsInfo. - output: Size of data actually returned. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - paramErr -50 Volume doesn't support this function - - __________ - - Also see the macros for checking attribute bits in MoreFilesExtras.h -*/ - -/*****************************************************************************/ - -pascal OSErr HCreateMinimum(short vRefNum, - long dirID, - ConstStr255Param fileName); -/* ¦ Create a new file with no creator or file type. - The HCreateMinimum function creates a new file without attempting to set - the creator and file type of the new file. This function is needed to - create a file in an AppleShare "drop box" where the user can make - changes, but cannot see folder or files. - - vRefNum input: Volume specification. - dirID input: Directory ID. - fileName input: The name of the new file. - - 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 - - __________ - - Also see: FSpCreateMinimum -*/ - -/*****************************************************************************/ - -pascal OSErr FSpCreateMinimum(const FSSpec *spec); -/* ¦ Create a new file with no creator or file type. - The FSpCreateMinimum function creates a new file without attempting to set - the the creator and file type of the new file. This function is needed to - create a file in an AppleShare "dropbox" where the user can make - changes, but cannot see folder or files. - - spec input: An FSSpec record specifying the file to create. - - 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 - - __________ - - Also see: HCreateMinimum -*/ - -/*****************************************************************************/ - -pascal OSErr ExchangeFiles(short vRefNum, - long srcDirID, - ConstStr255Param srcName, - long dstDirID, - ConstStr255Param dstName); -/* ¦ Exchange the data stored in two files on the same volume. - The ExchangeFiles function swaps the data in two files on the same - volume by changing some of the information in the volume catalog and, - if the files are open, in the file control blocks. - - vRefNum input: Volume specification. - srcDirID input: Source directory ID. - srcName input: Source file name. - dstDirID input: Destination directory ID. - dstName input: Destination file name. - - 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 are the same - - __________ - - Also see: FSpExchangeFilesCompat -*/ - -/*****************************************************************************/ - -pascal OSErr ResolveFileIDRef(ConstStr255Param volName, - short vRefNum, - long fileID, - long *parID, - StringPtr fileName); -/* ¦ Retrieve the location of the file with the specified file ID reference. - The ResolveFileIDRef function returns the filename and parent directory ID - of the file with the specified file ID reference. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - fileID input: The file ID reference. - parID output: The parent directory ID of the file. - name input: Points to a buffer (minimum Str63) where the filename - is to be returned or must be nil. - output: The filename. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr -43 File not found - paramErr -50 Function not supported by volume - volOfflinErr -53 Volume is offline - extFSErr -58 External file system error - no file - system claimed this call. - wrgVolTypErr -123 Not an HFS volume - fidNotFoundErr -1300 File ID reference not found - notAFileErr -1302 Specified file is a directory - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Specified file is a directory - afpIDNotFound -5034 File ID reference not found - afpBadIDErr -5039 File ID reference not found - - __________ - - Also see: FSpResolveFileIDRef, CreateFileIDRef, FSpCreateFileIDRef, - DeleteFileIDRef -*/ - -/*****************************************************************************/ - -pascal OSErr FSpResolveFileIDRef(ConstStr255Param volName, - short vRefNum, - long fileID, - FSSpecPtr spec); -/* ¦ Retrieve the location of the file with the specified file ID reference. - The FSpResolveFileIDRef function fills in an FSSpec with the location - of the file with the specified file ID reference. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - fileID input: The file ID reference. - spec input: A pointer to a FSSpec record. - output: A file system specification to be filled in by - FSpResolveFileIDRef. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr -43 File not found - paramErr -50 Function not supported by volume or - no default volume - volOfflinErr -53 Volume is offline - extFSErr -58 External file system error - no file - system claimed this call. - wrgVolTypErr -123 Not an HFS volume - fidNotFoundErr -1300 File ID reference not found - notAFileErr -1302 Specified file is a directory - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Specified file is a directory - afpIDNotFound -5034 File ID reference not found - afpBadIDErr -5039 File ID reference not found - - __________ - - Also see: ResolveFileIDRef, CreateFileIDRef, FSpCreateFileIDRef, - DeleteFileIDRef -*/ - -/*****************************************************************************/ - -pascal OSErr CreateFileIDRef(short vRefNum, - long parID, - ConstStr255Param fileName, - long *fileID); -/* ¦ Establish a file ID reference for a file. - The CreateFileIDRef function creates a file ID reference for the - specified file, or if a file ID reference already exists, supplies - the file ID reference and returns the result code fidExists. - - vRefNum input: Volume specification. - parID input: Directory ID. - fileName input: The name of the file. - fileID output: The file ID reference. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr -43 File not found - wPrErr -44 Hardware volume lock - vLckdErr -46 Software volume lock - paramErr -50 Function not supported by volume - volOfflinErr -53 Volume is offline - extFSErr -58 External file system error - no file - system claimed this call. - wrgVolTypErr -123 Not an HFS volume - fidExists -1301 File ID reference already exists - notAFileErrn -1302 Specified file is a directory - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Specified file is a directory - afpIDExists -5035 File ID reference already exists - - __________ - - Also see: FSpResolveFileIDRef, ResolveFileIDRef, FSpCreateFileIDRef, - DeleteFileIDRef -*/ - -/*****************************************************************************/ - -pascal OSErr FSpCreateFileIDRef(const FSSpec *spec, - long *fileID); -/* ¦ Establish a file ID reference for a file. - The FSpCreateFileIDRef function creates a file ID reference for the - specified file, or if a file ID reference already exists, supplies - the file ID reference and returns the result code fidExists. - - spec input: An FSSpec record specifying the file. - fileID output: The file ID reference. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr -43 File not found - wPrErr -44 Hardware volume lock - vLckdErr -46 Software volume lock - paramErr -50 Function not supported by volume - volOfflinErr -53 Volume is offline - extFSErr -58 External file system error - no file - system claimed this call. - wrgVolTypErr -123 Not an HFS volume - fidExists -1301 File ID reference already exists - notAFileErrn -1302 Specified file is a directory - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Specified file is a directory - afpIDExists -5035 File ID reference already exists - - __________ - - Also see: FSpResolveFileIDRef, ResolveFileIDRef, CreateFileIDRef, - DeleteFileIDRef -*/ - -/*****************************************************************************/ - -pascal OSErr DeleteFileIDRef(ConstStr255Param volName, - short vRefNum, - long fileID); -/* ¦ Delete a file ID reference. - The DeleteFileIDRef function deletes a file ID reference. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - fileID input: The file ID reference. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnfErr -43 File not found - wPrErr -44 Hardware volume lock - vLckdErr -46 Software volume lock - paramErr -50 Function not supported by volume - volOfflinErr -53 Volume is offline - extFSErr -58 External file system error - no file - system claimed this call. - wrgVolTypErr -123 Function is not supported by volume - fidNotFoundErr -1300 File ID reference not found - afpAccessDenied -5000 User does not have the correct access - afpObjectTypeErr -5025 Specified file is a directory - afpIDNotFound -5034 File ID reference not found - - __________ - - Also see: FSpResolveFileIDRef, ResolveFileIDRef, CreateFileIDRef, - FSpCreateFileIDRef -*/ - -/*****************************************************************************/ - -pascal OSErr FlushFile(short refNum); -/* ¦ Write the contents of a file's access path buffer (the fork data). - The FlushFile function writes the contents of a file's access path - buffer (the fork data) to the volume. Note: some of the file's catalog - information stored on the volume may not be correct until FlushVol - is called. - - refNum input: The file reference number of an open file. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - fnOpnErr -38 File not open - fnfErr -43 File not found - rfNumErr -51 Bad reference number - extFSErr -58 External file system error - no file - system claimed this call. -*/ - -/*****************************************************************************/ - -pascal OSErr LockRange(short refNum, - long rangeLength, - long rangeStart); -/* ¦ Lock a portion of a file. - The LockRange function locks (denies access to) a portion of a file - that was opened with shared read/write permission. - - refNum input: The file reference number of an open file. - rangeLength input: The number of bytes in the range. - rangeStart input: The starting byte in the range to lock. - - Result Codes - noErr 0 No error - ioErr -36 I/O error - fnOpnErr -38 File not open - eofErr -39 Logical end-of-file reached - fLckdErr -45 File is locked by another user - paramErr -50 Negative ioReqCount - rfNumErr -51 Bad reference number - extFSErr -58 External file system error - no file - system claimed this call. - volGoneErr -124 Server volume has been disconnected - afpNoMoreLocks -5015 No more ranges can be locked - afpRangeOverlap -5021 Part of range is already locked - - __________ - - Also see: UnlockRange -*/ - -/*****************************************************************************/ - -pascal OSErr UnlockRange(short refNum, - long rangeLength, - long rangeStart); -/* ¦ Unlock a previously locked range. - The UnlockRange function unlocks (allows access to) a previously locked - portion of a file that was opened with shared read/write permission. - - refNum input: The file reference number of an open file. - rangeLength input: The number of bytes in the range. - rangeStart input: The starting byte in the range to unlock. - - Result Codes - noErr 0 No error - ioErr -36 I/O error - fnOpnErr -38 File not open - eofErr -39 Logical end-of-file reached - paramErr -50 Negative ioReqCount - rfNumErr -51 Bad reference number - extFSErr -58 External file system error - no file - system claimed this call. - volGoneErr -124 Server volume has been disconnected - afpRangeNotLocked -5020 Specified range was not locked - - __________ - - Also see: LockRange -*/ - -/*****************************************************************************/ - -pascal OSErr GetForeignPrivs(short vRefNum, - long dirID, - ConstStr255Param name, - void *foreignPrivBuffer, - long *foreignPrivSize, - long *foreignPrivInfo1, - long *foreignPrivInfo2, - long *foreignPrivInfo3, - long *foreignPrivInfo4); -/* ¦ Retrieve the native access-control information. - The GetForeignPrivs function retrieves the native access-control - information for a file or directory stored on a volume managed by - a foreign file system. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - foreignPrivBuffer input: Pointer to buffer where the privilege - information is returned. - output: Privilege information. - foreignPrivSize input: Size of buffer pointed to by - foreignPrivBuffer. - output: Amount of buffer actually used. - foreignPrivInfo1 output: Information specific to privilege model. - foreignPrivInfo2 output: Information specific to privilege model. - foreignPrivInfo3 output: Information specific to privilege model. - foreignPrivInfo4 output: Information specific to privilege model. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - paramErr -50 Volume is HFS or MFS (that is, it has - no foreign privilege model), or foreign - volume does not support these calls - - __________ - - Also see: FSpGetForeignPrivs, SetForeignPrivs, FSpSetForeignPrivs -*/ - -/*****************************************************************************/ - -pascal OSErr FSpGetForeignPrivs(const FSSpec *spec, - void *foreignPrivBuffer, - long *foreignPrivSize, - long *foreignPrivInfo1, - long *foreignPrivInfo2, - long *foreignPrivInfo3, - long *foreignPrivInfo4); -/* ¦ Retrieve the native access-control information. - The FSpGetForeignPrivs function retrieves the native access-control - information for a file or directory stored on a volume managed by - a foreign file system. - - spec input: An FSSpec record specifying the object. - foreignPrivBuffer input: Pointer to buffer where the privilege - information is returned. - output: Privilege information. - foreignPrivSize input: Size of buffer pointed to by - foreignPrivBuffer. - output: Amount of buffer actually used. - foreignPrivInfo1 output: Information specific to privilege model. - foreignPrivInfo2 output: Information specific to privilege model. - foreignPrivInfo3 output: Information specific to privilege model. - foreignPrivInfo4 output: Information specific to privilege model. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - paramErr -50 Volume is HFS or MFS (that is, it has - no foreign privilege model), or foreign - volume does not support these calls - - __________ - - Also see: GetForeignPrivs, SetForeignPrivs, FSpSetForeignPrivs -*/ - -/*****************************************************************************/ - -pascal OSErr SetForeignPrivs(short vRefNum, - long dirID, - ConstStr255Param name, - const void *foreignPrivBuffer, - long *foreignPrivSize, - long foreignPrivInfo1, - long foreignPrivInfo2, - long foreignPrivInfo3, - long foreignPrivInfo4); -/* ¦ Change the native access-control information. - The SetForeignPrivs function changes the native access-control - information for a file or directory stored on a volume managed by - a foreign file system. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to object name, or nil when dirID - specifies a directory that's the object. - foreignPrivBuffer input: Pointer to privilege information buffer. - foreignPrivSize input: Size of buffer pointed to by - foreignPrivBuffer. - output: Amount of buffer actually used. - foreignPrivInfo1 input: Information specific to privilege model. - foreignPrivInfo2 input: Information specific to privilege model. - foreignPrivInfo3 input: Information specific to privilege model. - foreignPrivInfo4 input: Information specific to privilege model. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - paramErr -50 Volume is HFS or MFS (that is, it has - no foreign privilege model), or foreign - volume does not support these calls - - __________ - - Also see: GetForeignPrivs, FSpGetForeignPrivs, FSpSetForeignPrivs -*/ - -/*****************************************************************************/ - -pascal OSErr FSpSetForeignPrivs(const FSSpec *spec, - const void *foreignPrivBuffer, - long *foreignPrivSize, - long foreignPrivInfo1, - long foreignPrivInfo2, - long foreignPrivInfo3, - long foreignPrivInfo4); -/* ¦ Change the native access-control information. - The FSpSetForeignPrivs function changes the native access-control - information for a file or directory stored on a volume managed by - a foreign file system. - - spec input: An FSSpec record specifying the object. - foreignPrivBuffer input: Pointer to privilege information buffer. - foreignPrivSize input: Size of buffer pointed to by - foreignPrivBuffer. - output: Amount of buffer actually used. - foreignPrivInfo1 input: Information specific to privilege model. - foreignPrivInfo2 input: Information specific to privilege model. - foreignPrivInfo3 input: Information specific to privilege model. - foreignPrivInfo4 input: Information specific to privilege model. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - paramErr -50 Volume is HFS or MFS (that is, it has - no foreign privilege model), or foreign - volume does not support these calls - - __________ - - Also see: GetForeignPrivs, FSpGetForeignPrivs, SetForeignPrivs -*/ - -/*****************************************************************************/ - -pascal OSErr HGetLogInInfo(ConstStr255Param volName, - short vRefNum, - short *loginMethod, - StringPtr userName); -/* ¦ Get the login method and user name used to log on to a shared volume. - The HGetLogInInfo function retrieves the login method and user name - used to log on to a particular shared volume. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: The volume reference number. - loginMethod output: The login method used (kNoUserAuthentication, - kPassword, kEncryptPassword, or - kTwoWayEncryptPassword). - userName input: Points to a buffer (minimum Str31) where the user - name is to be returned or must be nil. - output: The user name. - - Result Codes - noErr 0 No error - nsvErr -35 Specified volume doesnÕt exist - paramErr -50 Function not supported by volume - - __________ - - Also see: HGetDirAccess, FSpGetDirAccess, HSetDirAccess, - FSpSetDirAccess, HMapName, HMapID -*/ - -/*****************************************************************************/ - -pascal OSErr HGetDirAccess(short vRefNum, - long dirID, - ConstStr255Param name, - long *ownerID, - long *groupID, - long *accessRights); -/* ¦ Get a directory's access control information on a shared volume. - The HGetDirAccess function retrieves the directory access control - information for a directory on a shared volume. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to directory name, or nil if dirID - specifies the directory. - ownerID output: The directory's owner ID. - groupID output: The directory's group ID or - 0 if no group affiliation. - accessRights output: The directory's access rights. - - Result Codes - noErr 0 No error - fnfErr -43 Directory not found - paramErr -50 Function not supported by volume - afpAccessDenied -5000 User does not have the correct access - to the directory - - __________ - - Also see: HGetLogInInfo, FSpGetDirAccess, HSetDirAccess, - FSpSetDirAccess, HMapName, HMapID -*/ - -/*****************************************************************************/ - -pascal OSErr FSpGetDirAccess(const FSSpec *spec, - long *ownerID, - long *groupID, - long *accessRights); -/* ¦ Get a directory's access control information on a shared volume. - The FSpGetDirAccess function retrieves the directory access control - information for a directory on a shared volume. - - spec input: An FSSpec record specifying the directory. - ownerID output: The directory's owner ID. - groupID output: The directory's group ID or - 0 if no group affiliation. - accessRights output: The directory's access rights. - - Result Codes - noErr 0 No error - fnfErr -43 Directory not found - paramErr -50 Function not supported by volume - afpAccessDenied -5000 User does not have the correct access - to the directory - - __________ - - Also see: HGetLogInInfo, HGetDirAccess, HSetDirAccess, - FSpSetDirAccess, HMapName, HMapID -*/ - -/*****************************************************************************/ - -pascal OSErr HSetDirAccess(short vRefNum, - long dirID, - ConstStr255Param name, - long ownerID, - long groupID, - long accessRights); -/* ¦ Set a directory's access control information on a shared volume. - The HSetDirAccess function changes the directory access control - information for a directory on a shared volume. You must own a directory - to change its access control information. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to directory name, or nil if dirID - specifies the directory. - ownerID input: The directory's owner ID. - groupID input: The directory's group ID or - 0 if no group affiliation. - accessRights input: The directory's access rights. - - Result Codes - noErr 0 No error - fnfErr -43 Directory not found - vLckdErr -46 Volume is locked or read-only - paramErr -50 Parameter error - afpAccessDenied -5000 User does not have the correct access - to the directory - afpObjectTypeErr -5025 Object is a file, not a directory - - __________ - - Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, - FSpSetDirAccess, HMapName, HMapID -*/ - -/*****************************************************************************/ - -pascal OSErr FSpSetDirAccess(const FSSpec *spec, - long ownerID, - long groupID, - long accessRights); -/* ¦ Set a directory's access control information on a shared volume. - The FSpSetDirAccess function changes the directory access control - information for a directory on a shared volume. You must own a directory - to change its access control information. - - spec input: An FSSpec record specifying the directory. - ownerID input: The directory's owner ID. - groupID input: The directory's group ID or - 0 if no group affiliation. - accessRights input: The directory's access rights. - - Result Codes - noErr 0 No error - fnfErr -43 Directory not found - vLckdErr -46 Volume is locked or read-only - paramErr -50 Parameter error - afpAccessDenied -5000 User does not have the correct access - to the directory - afpObjectTypeErr -5025 Object is a file, not a directory - - __________ - - Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, - HMapName, HMapID -*/ - -/*****************************************************************************/ - -pascal OSErr HMapID(ConstStr255Param volName, - short vRefNum, - long ugID, - short objType, - StringPtr name); -/* ¦ Map a user or group ID to a user or group name. - The HMapID function determines the name of a user or group if you know - the user or group ID. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - objType input: The mapping function code: 1 if you're mapping a - user ID to a user name or 2 if you're mapping a - group ID to a group name. - name input: Points to a buffer (minimum Str31) where the user - or group name is to be returned or must be nil. - output: The user or group name. - - Result Codes - noErr 0 No error - fnfErr -43 Unrecognizable owner or group name - paramErr -50 Function not supported by volume - - __________ - - Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, - FSpSetDirAccess, HMapName -*/ - -/*****************************************************************************/ - -pascal OSErr HMapName(ConstStr255Param volName, - short vRefNum, - ConstStr255Param name, - short objType, - long *ugID); -/* ¦ Map a user or group name to a user or group ID. - The HMapName function determines the user or group ID if you know the - user or group name. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - name input: The user or group name. - objType input: The mapping function code: 3 if you're mapping a - user name to a user ID or 4 if you're mapping a - group name to a group ID. - ugID output: The user or group ID. - - Result Codes - noErr 0 No error - fnfErr -43 Unrecognizable owner or group name - paramErr -50 Function not supported by volume - - __________ - - Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, - FSpSetDirAccess, HMapID -*/ - -/*****************************************************************************/ - -pascal OSErr HCopyFile(short srcVRefNum, - long srcDirID, - ConstStr255Param srcName, - short dstVRefNum, - long dstDirID, - ConstStr255Param dstPathname, - ConstStr255Param copyName); -/* ¦ Duplicate a file on a file server and optionally to rename it. - The HCopyFile function duplicates a file and optionally to renames it. - The source and destination volumes must be on the same file server. - This function instructs the server to copy the file. - - srcVRefNum input: Source volume specification. - srcDirID input: Source directory ID. - srcName input: Source file name. - dstVRefNum input: Destination volume specification. - dstDirID input: Destination directory ID. - dstPathname input: Pointer to destination directory name, or - nil when dstDirID specifies a directory. - copyName input: Points to the new file name if the file is to be - renamed or nil if the file isn't to be renamed. - - Result Codes - noErr 0 No error - dskFulErr -34 Destination volume is full - fnfErr -43 Source file not found, or destination - directory does not exist - vLckdErr -46 Destination volume is read-only - fBsyErr -47 The source or destination file could - not be opened with the correct access - modes - dupFNErr -48 Destination file already exists - paramErr -50 Function not supported by volume - wrgVolTypErr -123 Function not supported by volume - afpAccessDenied -5000 The user does not have the right to - read the source or write to the - destination - afpDenyConflict -5006 The source or destination file could - not be opened with the correct access - modes - afpObjectTypeErr -5025 Source is a directory - - __________ - - Also see: FSpCopyFile, FileCopy, FSpFileCopy -*/ - -/*****************************************************************************/ - -pascal OSErr FSpCopyFile(const FSSpec *srcSpec, - const FSSpec *dstSpec, - ConstStr255Param copyName); -/* ¦ Duplicate a file on a file server and optionally to rename it. - The FSpCopyFile function duplicates a file and optionally to renames it. - The source and destination volumes must be on the same file server. - This function instructs the server to copy the file. - - srcSpec input: An FSSpec record specifying the source file. - dstSpec input: An FSSpec record specifying the destination - directory. - copyName input: Points to the new file name if the file is to be - renamed or nil if the file isn't to be renamed. - - Result Codes - noErr 0 No error - dskFulErr -34 Destination volume is full - fnfErr -43 Source file not found, or destination - directory does not exist - vLckdErr -46 Destination volume is read-only - fBsyErr -47 The source or destination file could - not be opened with the correct access - modes - dupFNErr -48 Destination file already exists - paramErr -50 Function not supported by volume - wrgVolTypErr -123 Function not supported by volume - afpAccessDenied -5000 The user does not have the right to - read the source or write to the - destination - afpDenyConflict -5006 The source or destination file could - not be opened with the correct access - modes - afpObjectTypeErr -5025 Source is a directory - - __________ - - Also see: HCopyFile, FileCopy, FSpFileCopy -*/ - -/*****************************************************************************/ - -pascal OSErr HMoveRename(short vRefNum, - long srcDirID, - ConstStr255Param srcName, - long dstDirID, - ConstStr255Param dstpathName, - ConstStr255Param copyName); -/* ¦ Move a file or directory on a file server and optionally to rename it. - The HMoveRename function moves a file or directory and optionally - renames it. The source and destination locations must be on the same - shared volume. - - vRefNum input: Volume specification. - srcDirID input: Source directory ID. - srcName input: The source object name. - dstDirID input: Destination directory ID. - dstName input: Pointer to destination directory name, or - nil when dstDirID specifies a directory. - copyName input: Points to the new name if the object is to be - renamed or nil if the object isn't to be renamed. - - Result Codes - noErr 0 No error - fnfErr -43 Source file or directory not found - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - dupFNErr -48 Destination already exists - paramErr -50 Function not supported by volume - badMovErr -122 Attempted to move directory into - offspring - afpAccessDenied -5000 The user does not have the right to - move the file or directory - - __________ - - Also see: FSpMoveRename, HMoveRenameCompat, FSpMoveRenameCompat -*/ - -/*****************************************************************************/ - -pascal OSErr FSpMoveRename(const FSSpec *srcSpec, - const FSSpec *dstSpec, - ConstStr255Param copyName); -/* ¦ Move a file or directory on a file server and optionally to rename it. - The FSpMoveRename function moves a file or directory and optionally - renames it. The source and destination locations must be on the same - shared volume. - - srcSpec input: An FSSpec record specifying the source object. - dstSpec input: An FSSpec record specifying the destination - directory. - copyName input: Points to the new name if the object is to be - renamed or nil if the object isn't to be renamed. - - Result Codes - noErr 0 No error - fnfErr -43 Source file or directory not found - fLckdErr -45 File is locked - vLckdErr -46 Destination volume is read-only - dupFNErr -48 Destination already exists - paramErr -50 Function not supported by volume - badMovErr -122 Attempted to move directory into - offspring - afpAccessDenied -5000 The user does not have the right to - move the file or directory - - __________ - - Also see: HMoveRename, HMoveRenameCompat, FSpMoveRenameCompat -*/ - -/*****************************************************************************/ - -pascal OSErr GetVolMountInfoSize(ConstStr255Param volName, - short vRefNum, - short *size); -/* ¦ Get the size of a volume mounting information record. - The GetVolMountInfoSize function determines the how much space the - program needs to allocate for a volume mounting information record. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - size output: The space needed (in bytes) of the volume mounting - information record. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - paramErr -50 Parameter error - extFSErr -58 External file system error - no file - system claimed this call. - - __________ - - Also see: GetVolMountInfo, VolumeMount BuildAFPVolMountInfo, - RetrieveAFPVolMountInfo -*/ - -/*****************************************************************************/ - -pascal OSErr GetVolMountInfo(ConstStr255Param volName, - short vRefNum, - void *volMountInfo); -/* ¦ Retrieve a volume mounting information record. - The GetVolMountInfo function retrieves a volume mounting information - record containing all the information needed to mount the volume, - except for passwords. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - volMountInfo output: Points to a volume mounting information - record where the mounting information is to - be returned. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - paramErr -50 Parameter error - extFSErr -58 External file system error - no file - system claimed this call. - - __________ - - Also see: GetVolMountInfoSize, VolumeMount, BuildAFPVolMountInfo, - RetrieveAFPVolMountInfo -*/ - -/*****************************************************************************/ - -pascal OSErr VolumeMount(const void *volMountInfo, - short *vRefNum); -/* ¦ Mount a volume using a volume mounting information record. - The VolumeMount function mounts a volume using a volume mounting - information record. - - volMountInfo input: Points to a volume mounting information record. - vRefNum output: A volume reference number. - - Result Codes - noErr 0 No error - notOpenErr -28 AppleTalk is not open - nsvErr -35 Volume not found - paramErr -50 Parameter error; typically, zone, server, - and volume name combination is not valid - or not complete, or the user name is not - recognized - extFSErr -58 External file system error - no file - system claimed this call. - memFullErr -108 Not enough memory to create a new volume - control block for mounting the volume - afpBadUAM -5002 User authentication method is unknown - afpBadVersNum -5003 Workstation is using an AFP version that - the server doesnÕt recognize - afpNoServer -5016 Server is not responding - afpUserNotAuth -5023 User authentication failed (usually, - password is not correct) - afpPwdExpired -5042 Password has expired on server - afpBadDirIDType -5060 Not a fixed directory ID volume - afpCantMountMoreSrvrs -5061 Maximum number of volumes has been - mounted - afpAlreadyMounted -5062 Volume already mounted - afpSameNodeErr -5063 Attempt to log on to a server running - on the same machine - - __________ - - Also see: GetVolMountInfoSize, GetVolMountInfo, BuildAFPVolMountInfo, - RetrieveAFPVolMountInfo -*/ - -/*****************************************************************************/ - -pascal OSErr Share(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Establish a local volume or directory as a share point. - The Share function establishes a local volume or directory as a - share point. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to directory name, or nil if dirID - specifies the directory. - - Result Codes - noErr 0 No error - tmfoErr -42 Too many share points - fnfErr -43 File not found - dupFNErr -48 Already a share point with this name - paramErr -50 Function not supported by volume - dirNFErrdirNFErr -120 Directory not found - afpAccessDenied -5000 This directory cannot be shared - afpObjectTypeErr -5025 Object was a file, not a directory - afpContainsSharedErr -5033 The directory contains a share point - afpInsideSharedErr -5043 The directory is inside a shared directory - - __________ - - Also see: FSpShare, Unshare, FSpUnshare -*/ - -/*****************************************************************************/ - -pascal OSErr FSpShare(const FSSpec *spec); -/* ¦ Establish a local volume or directory as a share point. - The FSpShare function establishes a local volume or directory as a - share point. - - spec input: An FSSpec record specifying the share point. - - Result Codes - noErr 0 No error - tmfoErr -42 Too many share points - fnfErr -43 File not found - dupFNErr -48 Already a share point with this name - paramErr -50 Function not supported by volume - dirNFErrdirNFErr -120 Directory not found - afpAccessDenied -5000 This directory cannot be shared - afpObjectTypeErr -5025 Object was a file, not a directory - afpContainsSharedErr -5033 The directory contains a share point - afpInsideSharedErr -5043 The directory is inside a shared directory - - __________ - - Also see: Share, Unshare, FSpUnshare -*/ - -/*****************************************************************************/ - -pascal OSErr Unshare(short vRefNum, - long dirID, - ConstStr255Param name); -/* ¦ Remove a share point. - The Unshare function removes a share point. - - vRefNum input: Volume specification. - dirID input: Directory ID. - name input: Pointer to directory name, or nil if dirID - specifies the directory. - - Result Codes - noErr 0 No error - fnfErr -43 File not found - paramErr -50 Function not supported by volume - dirNFErrdirNFErr -120 Directory not found - afpObjectTypeErr -5025 Object was a file, not a directory; or, - this directory is not a share point - - __________ - - Also see: Share, FSpShare, FSpUnshare -*/ - -/*****************************************************************************/ - -pascal OSErr FSpUnshare(const FSSpec *spec); -/* ¦ Remove a share point. - The FSpUnshare function removes a share point. - - spec input: An FSSpec record specifying the share point. - - Result Codes - noErr 0 No error - fnfErr -43 File not found - paramErr -50 Function not supported by volume - dirNFErrdirNFErr -120 Directory not found - afpObjectTypeErr -5025 Object was a file, not a directory; or, - this directory is not a share point - - __________ - - Also see: Share, FSpShare, Unshare -*/ - -/*****************************************************************************/ - -pascal OSErr GetUGEntry(short objType, - StringPtr objName, - long *objID); -/* ¦ Retrieve a user or group entry from the local file server. - The GetUGEntry function retrieves user or group entries from the - local file server. - - objType input: The object type: -1 = group; 0 = user - objName input: Points to a buffer (minimum Str31) where the user - or group name is to be returned or must be nil. - output: The user or group name. - objID input: O to get the first user or group. If the entry objID - last returned by GetUGEntry is passed, then user or - group whose alphabetically next in the list of entries - is returned. - output: The user or group ID. - - Result Codes - noErr 0 No error - fnfErr -43 No more users or groups - paramErr -50 Function not supported; or, ioObjID is - negative - - __________ - - Also see: GetUGEntries -*/ - -/*****************************************************************************/ - -#ifdef __cplusplus -} -#endif - -#include "optimend.h" - -#endif /* __MOREFILES__ */ diff --git a/src/mac/morefile/MoreFile.cpp b/src/mac/morefile/MoreFiles.c similarity index 92% rename from src/mac/morefile/MoreFile.cpp rename to src/mac/morefile/MoreFiles.c index 581e1b742a..8426bdaffe 100644 --- a/src/mac/morefile/MoreFile.cpp +++ b/src/mac/morefile/MoreFiles.c @@ -1,32 +1,47 @@ /* -** Apple Macintosh Developer Technical Support -** -** The long lost high-level and FSSpec File Manager functions. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: MoreFiles.c -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: MoreFiles.c + + Contains: The long lost high-level and FSSpec File Manager functions. + + Version: MoreFiles + + Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <2> 2/7/01 JL Added standard header. Updated names of includes. + <1> 12/06/99 JL MoreFiles 1.5. */ -#include -#include +#include +#include #include #define __COMPILINGMOREFILES -#include "morefile.h" -#include "moreextr.h" +#include "MoreFiles.h" +#include "MoreFilesExtras.h" /*****************************************************************************/ @@ -153,7 +168,7 @@ pascal OSErr CreateFileIDRef(short vRefNum, pb.fidParam.ioVRefNum = vRefNum; pb.fidParam.ioSrcDirID = parID; error = PBCreateFileIDRefSync(&pb); - if ( error == noErr ) + if ( (error == noErr) || (error == fidExists) || (error == afpIDExists) ) { *fileID = pb.fidParam.ioFileID; } diff --git a/src/mac/morefile/MoreFiles.h b/src/mac/morefile/MoreFiles.h new file mode 100644 index 0000000000..25b1fcf13e --- /dev/null +++ b/src/mac/morefile/MoreFiles.h @@ -0,0 +1,1420 @@ +/* + File: MoreFiles.h + + Contains: The long lost high-level and FSSpec File Manager 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 __MOREFILES__ +#define __MOREFILES__ + +#ifndef __MACTYPES__ +#include +#endif + +#ifndef __FILES__ +#include +#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 ) +HGetVolParms( + ConstStr255Param volName, + short vRefNum, + GetVolParmsInfoBuffer * volParmsInfo, + long * infoSize); + + +/* + The HGetVolParms function returns information about the characteristics + of a volume. A result of paramErr usually just means the volume doesn't + support PBHGetVolParms and the feature you were going to check + for isn't available. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + volParmsInfo input: Pointer to GetVolParmsInfoBuffer where the + volume attributes information is returned. + output: Atributes information. + infoSize input: Size of buffer pointed to by volParmsInfo. + output: Size of data actually returned. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + paramErr -50 Volume doesn't support this function + + __________ + + Also see the macros for checking attribute bits in MoreFilesExtras.h +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HCreateMinimum( + short vRefNum, + long dirID, + ConstStr255Param fileName); + + +/* + The HCreateMinimum function creates a new file without attempting to set + the creator and file type of the new file. This function is needed to + create a file in an AppleShare "drop box" where the user can make + changes, but cannot see folder or files. + + vRefNum input: Volume specification. + dirID input: Directory ID. + fileName input: The name of the new file. + + 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 + + __________ + + Also see: FSpCreateMinimum +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpCreateMinimum(const FSSpec * spec); + + +/* + The FSpCreateMinimum function creates a new file without attempting to set + the the creator and file type of the new file. This function is needed to + create a file in an AppleShare "dropbox" where the user can make + changes, but cannot see folder or files. + + spec input: An FSSpec record specifying the file to create. + + 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 + + __________ + + Also see: HCreateMinimum +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +ExchangeFiles( + short vRefNum, + long srcDirID, + ConstStr255Param srcName, + long dstDirID, + ConstStr255Param dstName); + + +/* + The ExchangeFiles function swaps the data in two files on the same + volume by changing some of the information in the volume catalog and, + if the files are open, in the file control blocks. + + vRefNum input: Volume specification. + srcDirID input: Source directory ID. + srcName input: Source file name. + dstDirID input: Destination directory ID. + dstName input: Destination file name. + + 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 are the same + + __________ + + Also see: FSpExchangeFilesCompat +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +ResolveFileIDRef( + ConstStr255Param volName, + short vRefNum, + long fileID, + long * parID, + StringPtr fileName); + + +/* + The ResolveFileIDRef function returns the filename and parent directory ID + of the file with the specified file ID reference. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + fileID input: The file ID reference. + parID output: The parent directory ID of the file. + name input: Points to a buffer (minimum Str63) where the filename + is to be returned or must be nil. + output: The filename. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr -43 File not found + paramErr -50 Function not supported by volume + volOfflinErr -53 Volume is offline + extFSErr -58 External file system error - no file + system claimed this call. + wrgVolTypErr -123 Not an HFS volume + fidNotFoundErr -1300 File ID reference not found + notAFileErr -1302 Specified file is a directory + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Specified file is a directory + afpIDNotFound -5034 File ID reference not found + afpBadIDErr -5039 File ID reference not found + + __________ + + Also see: FSpResolveFileIDRef, CreateFileIDRef, FSpCreateFileIDRef, + DeleteFileIDRef +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpResolveFileIDRef( + ConstStr255Param volName, + short vRefNum, + long fileID, + FSSpecPtr spec); + + +/* + The FSpResolveFileIDRef function fills in an FSSpec with the location + of the file with the specified file ID reference. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + fileID input: The file ID reference. + spec input: A pointer to a FSSpec record. + output: A file system specification to be filled in by + FSpResolveFileIDRef. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr -43 File not found + paramErr -50 Function not supported by volume or + no default volume + volOfflinErr -53 Volume is offline + extFSErr -58 External file system error - no file + system claimed this call. + wrgVolTypErr -123 Not an HFS volume + fidNotFoundErr -1300 File ID reference not found + notAFileErr -1302 Specified file is a directory + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Specified file is a directory + afpIDNotFound -5034 File ID reference not found + afpBadIDErr -5039 File ID reference not found + + __________ + + Also see: ResolveFileIDRef, CreateFileIDRef, FSpCreateFileIDRef, + DeleteFileIDRef +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +CreateFileIDRef( + short vRefNum, + long parID, + ConstStr255Param fileName, + long * fileID); + + +/* + The CreateFileIDRef function creates a file ID reference for the + specified file, or if a file ID reference already exists, supplies + the file ID reference and returns the result code fidExists or afpIDExists. + + vRefNum input: Volume specification. + parID input: Directory ID. + fileName input: The name of the file. + fileID output: The file ID reference (if result is noErr, + fidExists, or afpIDExists). + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr -43 File not found + wPrErr -44 Hardware volume lock + vLckdErr -46 Software volume lock + paramErr -50 Function not supported by volume + volOfflinErr -53 Volume is offline + extFSErr -58 External file system error - no file + system claimed this call. + wrgVolTypErr -123 Not an HFS volume + fidExists -1301 File ID reference already exists + notAFileErrn -1302 Specified file is a directory + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Specified file is a directory + afpIDExists -5035 File ID reference already exists + + __________ + + Also see: FSpResolveFileIDRef, ResolveFileIDRef, FSpCreateFileIDRef, + DeleteFileIDRef +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpCreateFileIDRef( + const FSSpec * spec, + long * fileID); + + +/* + The FSpCreateFileIDRef function creates a file ID reference for the + specified file, or if a file ID reference already exists, supplies + the file ID reference and returns the result code fidExists or afpIDExists. + + spec input: An FSSpec record specifying the file. + fileID output: The file ID reference (if result is noErr, + fidExists, or afpIDExists). + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr -43 File not found + wPrErr -44 Hardware volume lock + vLckdErr -46 Software volume lock + paramErr -50 Function not supported by volume + volOfflinErr -53 Volume is offline + extFSErr -58 External file system error - no file + system claimed this call. + wrgVolTypErr -123 Not an HFS volume + fidExists -1301 File ID reference already exists + notAFileErrn -1302 Specified file is a directory + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Specified file is a directory + afpIDExists -5035 File ID reference already exists + + __________ + + Also see: FSpResolveFileIDRef, ResolveFileIDRef, CreateFileIDRef, + DeleteFileIDRef +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DeleteFileIDRef( + ConstStr255Param volName, + short vRefNum, + long fileID); + + +/* + The DeleteFileIDRef function deletes a file ID reference. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + fileID input: The file ID reference. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnfErr -43 File not found + wPrErr -44 Hardware volume lock + vLckdErr -46 Software volume lock + paramErr -50 Function not supported by volume + volOfflinErr -53 Volume is offline + extFSErr -58 External file system error - no file + system claimed this call. + wrgVolTypErr -123 Function is not supported by volume + fidNotFoundErr -1300 File ID reference not found + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Specified file is a directory + afpIDNotFound -5034 File ID reference not found + + __________ + + Also see: FSpResolveFileIDRef, ResolveFileIDRef, CreateFileIDRef, + FSpCreateFileIDRef +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FlushFile(short refNum); + + +/* + The FlushFile function writes the contents of a file's access path + buffer (the fork data) to the volume. Note: some of the file's catalog + information stored on the volume may not be correct until FlushVol + is called. + + refNum input: The file reference number of an open file. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + fnOpnErr -38 File not open + fnfErr -43 File not found + rfNumErr -51 Bad reference number + extFSErr -58 External file system error - no file + system claimed this call. +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +LockRange( + short refNum, + long rangeLength, + long rangeStart); + + +/* + The LockRange function locks (denies access to) a portion of a file + that was opened with shared read/write permission. + + refNum input: The file reference number of an open file. + rangeLength input: The number of bytes in the range. + rangeStart input: The starting byte in the range to lock. + + Result Codes + noErr 0 No error + ioErr -36 I/O error + fnOpnErr -38 File not open + eofErr -39 Logical end-of-file reached + fLckdErr -45 File is locked by another user + paramErr -50 Negative ioReqCount + rfNumErr -51 Bad reference number + extFSErr -58 External file system error - no file + system claimed this call. + volGoneErr -124 Server volume has been disconnected + afpNoMoreLocks -5015 No more ranges can be locked + afpRangeOverlap -5021 Part of range is already locked + + __________ + + Also see: UnlockRange +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +UnlockRange( + short refNum, + long rangeLength, + long rangeStart); + + +/* + The UnlockRange function unlocks (allows access to) a previously locked + portion of a file that was opened with shared read/write permission. + + refNum input: The file reference number of an open file. + rangeLength input: The number of bytes in the range. + rangeStart input: The starting byte in the range to unlock. + + Result Codes + noErr 0 No error + ioErr -36 I/O error + fnOpnErr -38 File not open + eofErr -39 Logical end-of-file reached + paramErr -50 Negative ioReqCount + rfNumErr -51 Bad reference number + extFSErr -58 External file system error - no file + system claimed this call. + volGoneErr -124 Server volume has been disconnected + afpRangeNotLocked -5020 Specified range was not locked + + __________ + + Also see: LockRange +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetForeignPrivs( + short vRefNum, + long dirID, + ConstStr255Param name, + void * foreignPrivBuffer, + long * foreignPrivSize, + long * foreignPrivInfo1, + long * foreignPrivInfo2, + long * foreignPrivInfo3, + long * foreignPrivInfo4); + + +/* + The GetForeignPrivs function retrieves the native access-control + information for a file or directory stored on a volume managed by + a foreign file system. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + foreignPrivBuffer input: Pointer to buffer where the privilege + information is returned. + output: Privilege information. + foreignPrivSize input: Size of buffer pointed to by + foreignPrivBuffer. + output: Amount of buffer actually used. + foreignPrivInfo1 output: Information specific to privilege model. + foreignPrivInfo2 output: Information specific to privilege model. + foreignPrivInfo3 output: Information specific to privilege model. + foreignPrivInfo4 output: Information specific to privilege model. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + paramErr -50 Volume is HFS or MFS (that is, it has + no foreign privilege model), or foreign + volume does not support these calls + + __________ + + Also see: FSpGetForeignPrivs, SetForeignPrivs, FSpSetForeignPrivs +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpGetForeignPrivs( + const FSSpec * spec, + void * foreignPrivBuffer, + long * foreignPrivSize, + long * foreignPrivInfo1, + long * foreignPrivInfo2, + long * foreignPrivInfo3, + long * foreignPrivInfo4); + + +/* + The FSpGetForeignPrivs function retrieves the native access-control + information for a file or directory stored on a volume managed by + a foreign file system. + + spec input: An FSSpec record specifying the object. + foreignPrivBuffer input: Pointer to buffer where the privilege + information is returned. + output: Privilege information. + foreignPrivSize input: Size of buffer pointed to by + foreignPrivBuffer. + output: Amount of buffer actually used. + foreignPrivInfo1 output: Information specific to privilege model. + foreignPrivInfo2 output: Information specific to privilege model. + foreignPrivInfo3 output: Information specific to privilege model. + foreignPrivInfo4 output: Information specific to privilege model. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + paramErr -50 Volume is HFS or MFS (that is, it has + no foreign privilege model), or foreign + volume does not support these calls + + __________ + + Also see: GetForeignPrivs, SetForeignPrivs, FSpSetForeignPrivs +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +SetForeignPrivs( + short vRefNum, + long dirID, + ConstStr255Param name, + const void * foreignPrivBuffer, + long * foreignPrivSize, + long foreignPrivInfo1, + long foreignPrivInfo2, + long foreignPrivInfo3, + long foreignPrivInfo4); + + +/* + The SetForeignPrivs function changes the native access-control + information for a file or directory stored on a volume managed by + a foreign file system. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + foreignPrivBuffer input: Pointer to privilege information buffer. + foreignPrivSize input: Size of buffer pointed to by + foreignPrivBuffer. + output: Amount of buffer actually used. + foreignPrivInfo1 input: Information specific to privilege model. + foreignPrivInfo2 input: Information specific to privilege model. + foreignPrivInfo3 input: Information specific to privilege model. + foreignPrivInfo4 input: Information specific to privilege model. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + paramErr -50 Volume is HFS or MFS (that is, it has + no foreign privilege model), or foreign + volume does not support these calls + + __________ + + Also see: GetForeignPrivs, FSpGetForeignPrivs, FSpSetForeignPrivs +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpSetForeignPrivs( + const FSSpec * spec, + const void * foreignPrivBuffer, + long * foreignPrivSize, + long foreignPrivInfo1, + long foreignPrivInfo2, + long foreignPrivInfo3, + long foreignPrivInfo4); + + +/* + The FSpSetForeignPrivs function changes the native access-control + information for a file or directory stored on a volume managed by + a foreign file system. + + spec input: An FSSpec record specifying the object. + foreignPrivBuffer input: Pointer to privilege information buffer. + foreignPrivSize input: Size of buffer pointed to by + foreignPrivBuffer. + output: Amount of buffer actually used. + foreignPrivInfo1 input: Information specific to privilege model. + foreignPrivInfo2 input: Information specific to privilege model. + foreignPrivInfo3 input: Information specific to privilege model. + foreignPrivInfo4 input: Information specific to privilege model. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + paramErr -50 Volume is HFS or MFS (that is, it has + no foreign privilege model), or foreign + volume does not support these calls + + __________ + + Also see: GetForeignPrivs, FSpGetForeignPrivs, SetForeignPrivs +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HGetLogInInfo( + ConstStr255Param volName, + short vRefNum, + short * loginMethod, + StringPtr userName); + + +/* + The HGetLogInInfo function retrieves the login method and user name + used to log on to a particular shared volume. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: The volume reference number. + loginMethod output: The login method used (kNoUserAuthentication, + kPassword, kEncryptPassword, or + kTwoWayEncryptPassword). + userName input: Points to a buffer (minimum Str31) where the user + name is to be returned or must be nil. + output: The user name. + + Result Codes + noErr 0 No error + nsvErr -35 Specified volume doesnÕt exist + paramErr -50 Function not supported by volume + + __________ + + Also see: HGetDirAccess, FSpGetDirAccess, HSetDirAccess, + FSpSetDirAccess, HMapName, HMapID +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HGetDirAccess( + short vRefNum, + long dirID, + ConstStr255Param name, + long * ownerID, + long * groupID, + long * accessRights); + + +/* + The HGetDirAccess function retrieves the directory access control + information for a directory on a shared volume. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to directory name, or nil if dirID + specifies the directory. + ownerID output: The directory's owner ID. + groupID output: The directory's group ID or + 0 if no group affiliation. + accessRights output: The directory's access rights. + + Result Codes + noErr 0 No error + fnfErr -43 Directory not found + paramErr -50 Function not supported by volume + afpAccessDenied -5000 User does not have the correct access + to the directory + + __________ + + Also see: HGetLogInInfo, FSpGetDirAccess, HSetDirAccess, + FSpSetDirAccess, HMapName, HMapID +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpGetDirAccess( + const FSSpec * spec, + long * ownerID, + long * groupID, + long * accessRights); + + +/* + The FSpGetDirAccess function retrieves the directory access control + information for a directory on a shared volume. + + spec input: An FSSpec record specifying the directory. + ownerID output: The directory's owner ID. + groupID output: The directory's group ID or + 0 if no group affiliation. + accessRights output: The directory's access rights. + + Result Codes + noErr 0 No error + fnfErr -43 Directory not found + paramErr -50 Function not supported by volume + afpAccessDenied -5000 User does not have the correct access + to the directory + + __________ + + Also see: HGetLogInInfo, HGetDirAccess, HSetDirAccess, + FSpSetDirAccess, HMapName, HMapID +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HSetDirAccess( + short vRefNum, + long dirID, + ConstStr255Param name, + long ownerID, + long groupID, + long accessRights); + + +/* + The HSetDirAccess function changes the directory access control + information for a directory on a shared volume. You must own a directory + to change its access control information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to directory name, or nil if dirID + specifies the directory. + ownerID input: The directory's owner ID. + groupID input: The directory's group ID or + 0 if no group affiliation. + accessRights input: The directory's access rights. + + Result Codes + noErr 0 No error + fnfErr -43 Directory not found + vLckdErr -46 Volume is locked or read-only + paramErr -50 Parameter error + afpAccessDenied -5000 User does not have the correct access + to the directory + afpObjectTypeErr -5025 Object is a file, not a directory + + __________ + + Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, + FSpSetDirAccess, HMapName, HMapID +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpSetDirAccess( + const FSSpec * spec, + long ownerID, + long groupID, + long accessRights); + + +/* + The FSpSetDirAccess function changes the directory access control + information for a directory on a shared volume. You must own a directory + to change its access control information. + + spec input: An FSSpec record specifying the directory. + ownerID input: The directory's owner ID. + groupID input: The directory's group ID or + 0 if no group affiliation. + accessRights input: The directory's access rights. + + Result Codes + noErr 0 No error + fnfErr -43 Directory not found + vLckdErr -46 Volume is locked or read-only + paramErr -50 Parameter error + afpAccessDenied -5000 User does not have the correct access + to the directory + afpObjectTypeErr -5025 Object is a file, not a directory + + __________ + + Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, + HMapName, HMapID +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HMapID( + ConstStr255Param volName, + short vRefNum, + long ugID, + short objType, + StringPtr name); + + +/* + The HMapID function determines the name of a user or group if you know + the user or group ID. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + objType input: The mapping function code: 1 if you're mapping a + user ID to a user name or 2 if you're mapping a + group ID to a group name. + name input: Points to a buffer (minimum Str31) where the user + or group name is to be returned or must be nil. + output: The user or group name. + + Result Codes + noErr 0 No error + fnfErr -43 Unrecognizable owner or group name + paramErr -50 Function not supported by volume + + __________ + + Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, + FSpSetDirAccess, HMapName +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HMapName( + ConstStr255Param volName, + short vRefNum, + ConstStr255Param name, + short objType, + long * ugID); + + +/* + The HMapName function determines the user or group ID if you know the + user or group name. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + name input: The user or group name. + objType input: The mapping function code: 3 if you're mapping a + user name to a user ID or 4 if you're mapping a + group name to a group ID. + ugID output: The user or group ID. + + Result Codes + noErr 0 No error + fnfErr -43 Unrecognizable owner or group name + paramErr -50 Function not supported by volume + + __________ + + Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess, + FSpSetDirAccess, HMapID +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HCopyFile( + short srcVRefNum, + long srcDirID, + ConstStr255Param srcName, + short dstVRefNum, + long dstDirID, + ConstStr255Param dstPathname, + ConstStr255Param copyName); + + +/* + The HCopyFile function duplicates a file and optionally renames it. + The source and destination volumes must be on the same file server. + This function instructs the server to copy the file. + + srcVRefNum input: Source volume specification. + srcDirID input: Source directory ID. + srcName input: Source file name. + dstVRefNum input: Destination volume specification. + dstDirID input: Destination directory ID. + dstPathname input: Pointer to destination directory name, or + nil when dstDirID specifies a directory. + copyName input: Points to the new file name if the file is to be + renamed or nil if the file isn't to be renamed. + + Result Codes + noErr 0 No error + dskFulErr -34 Destination volume is full + fnfErr -43 Source file not found, or destination + directory does not exist + vLckdErr -46 Destination volume is read-only + fBsyErr -47 The source or destination file could + not be opened with the correct access + modes + dupFNErr -48 Destination file already exists + paramErr -50 Function not supported by volume + wrgVolTypErr -123 Function not supported by volume + afpAccessDenied -5000 The user does not have the right to + read the source or write to the + destination + afpDenyConflict -5006 The source or destination file could + not be opened with the correct access + modes + afpObjectTypeErr -5025 Source is a directory + + __________ + + Also see: FSpCopyFile, FileCopy, FSpFileCopy +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpCopyFile( + const FSSpec * srcSpec, + const FSSpec * dstSpec, + ConstStr255Param copyName); + + +/* + The FSpCopyFile function duplicates a file and optionally renames it. + The source and destination volumes must be on the same file server. + This function instructs the server to copy the file. + + srcSpec input: An FSSpec record specifying the source file. + dstSpec input: An FSSpec record specifying the destination + directory. + copyName input: Points to the new file name if the file is to be + renamed or nil if the file isn't to be renamed. + + Result Codes + noErr 0 No error + dskFulErr -34 Destination volume is full + fnfErr -43 Source file not found, or destination + directory does not exist + vLckdErr -46 Destination volume is read-only + fBsyErr -47 The source or destination file could + not be opened with the correct access + modes + dupFNErr -48 Destination file already exists + paramErr -50 Function not supported by volume + wrgVolTypErr -123 Function not supported by volume + afpAccessDenied -5000 The user does not have the right to + read the source or write to the + destination + afpDenyConflict -5006 The source or destination file could + not be opened with the correct access + modes + afpObjectTypeErr -5025 Source is a directory + + __________ + + Also see: HCopyFile, FileCopy, FSpFileCopy +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HMoveRename( + short vRefNum, + long srcDirID, + ConstStr255Param srcName, + long dstDirID, + ConstStr255Param dstpathName, + ConstStr255Param copyName); + + +/* + The HMoveRename function moves a file or directory and optionally + renames it. The source and destination locations must be on the same + shared volume. + + vRefNum input: Volume specification. + srcDirID input: Source directory ID. + srcName input: The source object name. + dstDirID input: Destination directory ID. + dstName input: Pointer to destination directory name, or + nil when dstDirID specifies a directory. + copyName input: Points to the new name if the object is to be + renamed or nil if the object isn't to be renamed. + + Result Codes + noErr 0 No error + fnfErr -43 Source file or directory not found + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + dupFNErr -48 Destination already exists + paramErr -50 Function not supported by volume + badMovErr -122 Attempted to move directory into + offspring + afpAccessDenied -5000 The user does not have the right to + move the file or directory + + __________ + + Also see: FSpMoveRename, HMoveRenameCompat, FSpMoveRenameCompat +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpMoveRename( + const FSSpec * srcSpec, + const FSSpec * dstSpec, + ConstStr255Param copyName); + + +/* + The FSpMoveRename function moves a file or directory and optionally + renames it. The source and destination locations must be on the same + shared volume. + + srcSpec input: An FSSpec record specifying the source object. + dstSpec input: An FSSpec record specifying the destination + directory. + copyName input: Points to the new name if the object is to be + renamed or nil if the object isn't to be renamed. + + Result Codes + noErr 0 No error + fnfErr -43 Source file or directory not found + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + dupFNErr -48 Destination already exists + paramErr -50 Function not supported by volume + badMovErr -122 Attempted to move directory into + offspring + afpAccessDenied -5000 The user does not have the right to + move the file or directory + + __________ + + Also see: HMoveRename, HMoveRenameCompat, FSpMoveRenameCompat +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetVolMountInfoSize( + ConstStr255Param volName, + short vRefNum, + short * size); + + +/* + The GetVolMountInfoSize function determines the how much space the + program needs to allocate for a volume mounting information record. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + size output: The space needed (in bytes) of the volume mounting + information record. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + paramErr -50 Parameter error + extFSErr -58 External file system error - no file + system claimed this call. + + __________ + + Also see: GetVolMountInfo, VolumeMount BuildAFPVolMountInfo, + RetrieveAFPVolMountInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetVolMountInfo( + ConstStr255Param volName, + short vRefNum, + void * volMountInfo); + + +/* + The GetVolMountInfo function retrieves a volume mounting information + record containing all the information needed to mount the volume, + except for passwords. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + volMountInfo output: Points to a volume mounting information + record where the mounting information is to + be returned. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + paramErr -50 Parameter error + extFSErr -58 External file system error - no file + system claimed this call. + + __________ + + Also see: GetVolMountInfoSize, VolumeMount, BuildAFPVolMountInfo, + RetrieveAFPVolMountInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +VolumeMount( + const void * volMountInfo, + short * vRefNum); + + +/* + The VolumeMount function mounts a volume using a volume mounting + information record. + + volMountInfo input: Points to a volume mounting information record. + vRefNum output: A volume reference number. + + Result Codes + noErr 0 No error + notOpenErr -28 AppleTalk is not open + nsvErr -35 Volume not found + paramErr -50 Parameter error; typically, zone, server, + and volume name combination is not valid + or not complete, or the user name is not + recognized + extFSErr -58 External file system error - no file + system claimed this call. + memFullErr -108 Not enough memory to create a new volume + control block for mounting the volume + afpBadUAM -5002 User authentication method is unknown + afpBadVersNum -5003 Workstation is using an AFP version that + the server doesnÕt recognize + afpNoServer -5016 Server is not responding + afpUserNotAuth -5023 User authentication failed (usually, + password is not correct) + afpPwdExpired -5042 Password has expired on server + afpBadDirIDType -5060 Not a fixed directory ID volume + afpCantMountMoreSrvrs -5061 Maximum number of volumes has been + mounted + afpAlreadyMounted -5062 Volume already mounted + afpSameNodeErr -5063 Attempt to log on to a server running + on the same machine + + __________ + + Also see: GetVolMountInfoSize, GetVolMountInfo, BuildAFPVolMountInfo, + RetrieveAFPVolMountInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +Share( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The Share function establishes a local volume or directory as a + share point. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to directory name, or nil if dirID + specifies the directory. + + Result Codes + noErr 0 No error + tmfoErr -42 Too many share points + fnfErr -43 File not found + dupFNErr -48 Already a share point with this name + paramErr -50 Function not supported by volume + dirNFErrdirNFErr -120 Directory not found + afpAccessDenied -5000 This directory cannot be shared + afpObjectTypeErr -5025 Object was a file, not a directory + afpContainsSharedErr -5033 The directory contains a share point + afpInsideSharedErr -5043 The directory is inside a shared directory + + __________ + + Also see: FSpShare, Unshare, FSpUnshare +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpShare(const FSSpec * spec); + + +/* + The FSpShare function establishes a local volume or directory as a + share point. + + spec input: An FSSpec record specifying the share point. + + Result Codes + noErr 0 No error + tmfoErr -42 Too many share points + fnfErr -43 File not found + dupFNErr -48 Already a share point with this name + paramErr -50 Function not supported by volume + dirNFErrdirNFErr -120 Directory not found + afpAccessDenied -5000 This directory cannot be shared + afpObjectTypeErr -5025 Object was a file, not a directory + afpContainsSharedErr -5033 The directory contains a share point + afpInsideSharedErr -5043 The directory is inside a shared directory + + __________ + + Also see: Share, Unshare, FSpUnshare +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +Unshare( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The Unshare function removes a share point. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to directory name, or nil if dirID + specifies the directory. + + Result Codes + noErr 0 No error + fnfErr -43 File not found + paramErr -50 Function not supported by volume + dirNFErrdirNFErr -120 Directory not found + afpObjectTypeErr -5025 Object was a file, not a directory; or, + this directory is not a share point + + __________ + + Also see: Share, FSpShare, FSpUnshare +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpUnshare(const FSSpec * spec); + + +/* + The FSpUnshare function removes a share point. + + spec input: An FSSpec record specifying the share point. + + Result Codes + noErr 0 No error + fnfErr -43 File not found + paramErr -50 Function not supported by volume + dirNFErrdirNFErr -120 Directory not found + afpObjectTypeErr -5025 Object was a file, not a directory; or, + this directory is not a share point + + __________ + + Also see: Share, FSpShare, Unshare +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetUGEntry( + short objType, + StringPtr objName, + long * objID); + + +/* + The GetUGEntry function retrieves user or group entries from the + local file server. + + objType input: The object type: -1 = group; 0 = user + objName input: Points to a buffer (minimum Str31) where the user + or group name is to be returned or must be nil. + output: The user or group name. + objID input: O to get the first user or group. If the entry objID + last returned by GetUGEntry is passed, then user or + group whose alphabetically next in the list of entries + is returned. + output: The user or group ID. + + Result Codes + noErr 0 No error + fnfErr -43 No more users or groups + paramErr -50 Function not supported; or, ioObjID is + negative + + __________ + + Also see: GetUGEntries +*/ + +/*****************************************************************************/ + +#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 /* __MOREFILES__ */ + diff --git a/src/mac/morefile/MoreExtr.cpp b/src/mac/morefile/MoreFilesExtras.c similarity index 73% rename from src/mac/morefile/MoreExtr.cpp rename to src/mac/morefile/MoreFilesExtras.c index d24c3c996b..7a5a083524 100644 --- a/src/mac/morefile/MoreExtr.cpp +++ b/src/mac/morefile/MoreFilesExtras.c @@ -1,28 +1,50 @@ /* -** Apple Macintosh Developer Technical Support -** -** A collection of useful high-level File Manager routines. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: MoreFilesExtras.c -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: MoreFilesExtras.c + + Contains: A collection of useful high-level File Manager routines + + Version: MoreFiles + + Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Jim Luther + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <2> 2/7/01 JL [2500429] Changed null output parameters to real variables when + calling GetSharedLibrary to prevent crashes with older versions + of CFM. Added standard header. Updated names of includes. Added + C function implementations of accessors that used to be macros + since the generated Pascal headers no longer contain + implementations. Updated various other routines to use new + calling convention of the accessor functions. + <1> 12/06/99 JL MoreFiles 1.5. */ -#include +#include #include #include -#include +#include +#include #include #include #include @@ -32,16 +54,280 @@ #include #include #include -#include -#include #include +#include +#include #define __COMPILINGMOREFILES -#include "morefile.h" -#include "moreextr.h" -#include "moredesk.h" -#include "fspcompa.h" +#include "MoreFiles.h" +#include "MoreDesktopMgr.h" +#include "FSpCompat.h" + +#include "MoreFilesExtras.h" + +/*****************************************************************************/ + +/* Functions to get information out of GetVolParmsInfoBuffer. */ + +/* version 1 field getters */ + +pascal short GetVolParmsInfoVersion(const GetVolParmsInfoBuffer *volParms) +{ + return ( volParms->vMVersion ); +} + +pascal long GetVolParmsInfoAttrib(const GetVolParmsInfoBuffer *volParms) +{ + return ( volParms->vMAttrib ); +} + +pascal Handle GetVolParmsInfoLocalHand(const GetVolParmsInfoBuffer *volParms) +{ + return ( volParms->vMLocalHand ); +} + +pascal long GetVolParmsInfoServerAdr(const GetVolParmsInfoBuffer *volParms) +{ + return ( volParms->vMServerAdr ); +} + +/* version 2 field getters (assume zero result if version < 2) */ + +pascal long GetVolParmsInfoVolumeGrade(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMVersion >= 2) ? volParms->vMVolumeGrade : 0 ); +} + +pascal long GetVolParmsInfoForeignPrivID(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMVersion >= 2) ? volParms->vMForeignPrivID : 0 ); +} + +/* version 3 field getters (assume zero result if version < 3) */ + +pascal long GetVolParmsInfoExtendedAttributes(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMVersion >= 3) ? volParms->vMExtendedAttributes : 0 ); +} + +/* attribute bits supported by all versions of GetVolParmsInfoBuffer */ + +pascal Boolean isNetworkVolume(const GetVolParmsInfoBuffer *volParms) +{ + return ( volParms->vMServerAdr != 0 ); +} + +pascal Boolean hasLimitFCBs(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bLimitFCBs)) != 0 ); +} + +pascal Boolean hasLocalWList(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bLocalWList)) != 0 ); +} + +pascal Boolean hasNoMiniFndr(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bNoMiniFndr)) != 0 ); +} + +pascal Boolean hasNoVNEdit(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bNoVNEdit)) != 0 ); +} + +pascal Boolean hasNoLclSync(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bNoLclSync)) != 0 ); +} + +pascal Boolean hasTrshOffLine(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bTrshOffLine)) != 0 ); +} + +pascal Boolean hasNoSwitchTo(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bNoSwitchTo)) != 0 ); +} + +pascal Boolean hasNoDeskItems(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bNoDeskItems)) != 0 ); +} + +pascal Boolean hasNoBootBlks(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bNoBootBlks)) != 0 ); +} + +pascal Boolean hasAccessCntl(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bAccessCntl)) != 0 ); +} + +pascal Boolean hasNoSysDir(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bNoSysDir)) != 0 ); +} + +pascal Boolean hasExtFSVol(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasExtFSVol)) != 0 ); +} + +pascal Boolean hasOpenDeny(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasOpenDeny)) != 0 ); +} + +pascal Boolean hasCopyFile(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasCopyFile)) != 0 ); +} + +pascal Boolean hasMoveRename(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasMoveRename)) != 0 ); +} + +pascal Boolean hasDesktopMgr(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasDesktopMgr)) != 0 ); +} + +pascal Boolean hasShortName(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasShortName)) != 0 ); +} + +pascal Boolean hasFolderLock(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasFolderLock)) != 0 ); +} + +pascal Boolean hasPersonalAccessPrivileges(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasPersonalAccessPrivileges)) != 0 ); +} + +pascal Boolean hasUserGroupList(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasUserGroupList)) != 0 ); +} + +pascal Boolean hasCatSearch(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasCatSearch)) != 0 ); +} + +pascal Boolean hasFileIDs(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasFileIDs)) != 0 ); +} + +pascal Boolean hasBTreeMgr(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasBTreeMgr)) != 0 ); +} + +pascal Boolean hasBlankAccessPrivileges(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bHasBlankAccessPrivileges)) != 0 ); +} + +pascal Boolean supportsAsyncRequests(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bSupportsAsyncRequests)) != 0 ); +} + +pascal Boolean supportsTrashVolumeCache(const GetVolParmsInfoBuffer *volParms) +{ + return ( (volParms->vMAttrib & (1L << bSupportsTrashVolumeCache)) != 0 ); +} + +/* attribute bits supported by version 3 and greater versions of GetVolParmsInfoBuffer */ + +pascal Boolean volIsEjectable(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bIsEjectable)) != 0 ); +} + +pascal Boolean volSupportsHFSPlusAPIs(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsHFSPlusAPIs)) != 0 ); +} + +pascal Boolean volSupportsFSCatalogSearch(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsFSCatalogSearch)) != 0 ); +} + +pascal Boolean volSupportsFSExchangeObjects(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsFSExchangeObjects)) != 0 ); +} + +pascal Boolean volSupports2TBFiles(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupports2TBFiles)) != 0 ); +} + +pascal Boolean volSupportsLongNames(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsLongNames)) != 0 ); +} + +pascal Boolean volSupportsMultiScriptNames(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsMultiScriptNames)) != 0 ); +} + +pascal Boolean volSupportsNamedForks(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsNamedForks)) != 0 ); +} + +pascal Boolean volSupportsSubtreeIterators(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsSubtreeIterators)) != 0 ); +} + +pascal Boolean volL2PCanMapFileBlocks(const GetVolParmsInfoBuffer *volParms) +{ + return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bL2PCanMapFileBlocks)) != 0 ); +} + +/*****************************************************************************/ + +/* Functions for testing ioACUser bits. */ + +pascal Boolean userIsOwner(SInt8 ioACUser) +{ + return ( (ioACUser & kioACUserNotOwnerMask) == 0 ); +} + +pascal Boolean userHasFullAccess(SInt8 ioACUser) +{ + return ( (ioACUser & acUserAccessMask) == acUserFull ); +} + +pascal Boolean userHasDropBoxAccess(SInt8 ioACUser) +{ + return ( (ioACUser & acUserAccessMask) == acUserDropBox ); +} + +pascal Boolean userHasBulletinBoard(SInt8 ioACUser) +{ + return ( (ioACUser & acUserAccessMask) == acUserBulletinBoard ); +} + +pascal Boolean userHasNoAccess(SInt8 ioACUser) +{ + return ( (ioACUser & acUserAccessMask) == acUserNone ); +} /*****************************************************************************/ @@ -52,12 +338,8 @@ ** global information that might be needed at any time. */ #if PRAGMA_STRUCT_ALIGN - #pragma options align=mac68k -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(push, 2) -#elif PRAGMA_STRUCT_PACK - #pragma pack(2) -#endif + #pragma options align=mac68k +#endif // PRAGMA_STRUCT_ALIGN struct DeleteEnumGlobals { OSErr error; /* temporary holder of results - saves 2 bytes of stack each level */ @@ -65,18 +347,108 @@ struct DeleteEnumGlobals UniversalFMPB myPB; /* the parameter block used for PBGetCatInfo calls */ }; #if PRAGMA_STRUCT_ALIGN - #pragma options align=reset -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(pop) -#elif PRAGMA_STRUCT_PACK - #pragma pack() -#endif + #pragma options align=reset +#endif // PRAGMA_STRUCT_ALIGN typedef struct DeleteEnumGlobals DeleteEnumGlobals; typedef DeleteEnumGlobals *DeleteEnumGlobalsPtr; /*****************************************************************************/ +/* +** CallPBXGetVolInfoSync is the glue code needed to make PBXGetVolInfoSync +** File Manager requests from CFM-based programs. Apple added PBXGetVolInfoSync +** to InterfaceLib in Mac OS 8.5, so if __MACOSEIGHTFIVEORLATER is defined, +** CallPBXGetVolInfoSync is defined back to PBXGetVolInfoSync. +** +** Non-CFM 68K programs don't needs this glue (and won't get it) because +** they instead use the inline assembly glue found in the Files.h interface +** file. +*/ + +#if TARGET_API_MAC_CARBON || !TARGET_RT_MAC_CFM + + // Carbon builds and 68K builds don't need this glue + #define CallPBXGetVolInfoSync PBXGetVolInfoSync + +#else // TARGET_API_MAC_CARBON || !TARGET_RT_MAC_CFM + + #if __WANTPASCALELIMINATION + #undef pascal + #endif // __WANTPASCALELIMINATION + + /* This is exactly like the simple mixed mode glue in InterfaceLib in Mac OS 8.5 and 8.6 */ + static pascal OSErr PBXGetVolInfoSyncGlue(XVolumeParamPtr paramBlock) + { + enum + { + uppFSDispatchProcInfo = kRegisterBased + | REGISTER_RESULT_LOCATION(kRegisterD0) + | RESULT_SIZE(SIZE_CODE(sizeof(OSErr))) + | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(long))) /* selector */ + | REGISTER_ROUTINE_PARAMETER(2, kRegisterD1, SIZE_CODE(sizeof(long))) /* trap word */ + | REGISTER_ROUTINE_PARAMETER(3, kRegisterA0, SIZE_CODE(sizeof(XVolumeParamPtr))) + }; + + static UniversalProcPtr fsDispatchTrapAddress = NULL; + + /* Is this the first time we've been called? */ + if ( fsDispatchTrapAddress == NULL ) + { + /* Yes - Get the trap address of _FSDispatch */ + fsDispatchTrapAddress = NGetTrapAddress(_FSDispatch, OSTrap); + } + return ( CallOSTrapUniversalProc(fsDispatchTrapAddress, + uppFSDispatchProcInfo, + kFSMXGetVolInfo, + _FSDispatch, + paramBlock) ); + } + + /* + ** PBXGetVolInfoSync was added to the File Manager in System software 7.5.2. + ** However, PBXGetVolInfoSync wasn't added to InterfaceLib until Mac OS 8.5. + ** This wrapper calls PBXGetVolInfoSync if it is found in InterfaceLib; + ** otherwise, it calls PBXGetVolInfoSyncGlue. This ensures that your program + ** is calling the latest implementation of PBXGetVolInfoSync. + */ + static pascal OSErr CallPBXGetVolInfoSync(XVolumeParamPtr paramBlock) + { + typedef pascal OSErr (*PBXGetVolInfoProcPtr) (XVolumeParamPtr paramBlock); + + OSErr result; + CFragConnectionID connID; + Ptr mainAddr; + Str255 errMessage; + static PBXGetVolInfoProcPtr PBXGetVolInfoSyncPtr = NULL; + + //* Is this the first time we've been called? */ + if ( PBXGetVolInfoSyncPtr == NULL ) + { + /* Yes - Get our connection ID to InterfaceLib */ + result = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kLoadCFrag, &connID, &mainAddr, errMessage); + if ( result == noErr ) + { + /* See if PBXGetVolInfoSync is in InterfaceLib */ + if ( FindSymbol(connID, "\pPBXGetVolInfoSync", &(Ptr)PBXGetVolInfoSyncPtr, NULL) != noErr ) + { + /* Use glue code if symbol isn't found */ + PBXGetVolInfoSyncPtr = PBXGetVolInfoSyncGlue; + } + } + } + /* Call PBXGetVolInfoSync if present; otherwise, call PBXGetVolInfoSyncGlue */ + return ( (*PBXGetVolInfoSyncPtr)(paramBlock) ); + } + + #if __WANTPASCALELIMINATION + #define pascal + #endif // __WANTPASCALELIMINATION + +#endif // TARGET_API_MAC_CARBON || !TARGET_RT_MAC_CFM + +/*****************************************************************************/ + pascal void TruncPString(StringPtr destination, ConstStr255Param source, short maxLength) @@ -91,11 +463,8 @@ pascal void TruncPString(StringPtr destination, /* a multi-byte character. */ while (maxLength != 0) { -#if TARGET_CARBON - charType = CharacterByteType((Ptr)&source[1], maxLength,smAllScripts); -#else - charType = CharByte((Ptr)&source[1], maxLength); -#endif + // Note: CharacterByteType's textOffset parameter is zero-based from the textPtr parameter + charType = CharacterByteType((Ptr)&source[1], maxLength - 1, smSystemScript); if ( (charType == smSingleByte) || (charType == smLastByte) ) break; /* source[maxLength] is now a valid last character */ --maxLength; @@ -234,15 +603,11 @@ pascal OSErr GetVolumeInfoNoName(ConstStr255Param pathname, ** the parameter block is always returned as NULL (since it might point ** to the local tempPathname). */ - -// #if TARGET_CARBON - pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname, short vRefNum, XVolumeParamPtr pb) { Str255 tempPathname; - long response; OSErr error; /* Make sure pb parameter is not NULL */ @@ -261,26 +626,29 @@ pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname, pb->ioNamePtr = (StringPtr)tempPathname; /* use the copy so original isn't trashed */ pb->ioVolIndex = -1; /* use ioNamePtr/ioVRefNum combination */ } -#if !__MACOSSEVENFIVEONEORLATER - /* Is PBXGetVolInfo available? */ - if ( ( Gestalt(gestaltFSAttr, &response) != noErr ) || ((response & (1L << gestaltFSSupports2TBVols)) == 0) ) + { - /* No, fall back on PBHGetVInfo */ - error = PBHGetVInfoSync((HParmBlkPtr)pb); - if ( error == noErr ) +#if !TARGET_API_MAC_CARBON + long response; + + /* Is PBXGetVolInfo available? */ + if ( ( Gestalt(gestaltFSAttr, &response) != noErr ) || ((response & (1L << gestaltFSSupports2TBVols)) == 0) ) { - /* calculate the ioVTotalBytes and ioVFreeBytes fields */ - pb->ioVTotalBytes.hi = 0; - pb->ioVTotalBytes.lo = pb->ioVNmAlBlks * pb->ioVAlBlkSiz; /* calculated total number of bytes on volume */ - pb->ioVFreeBytes.hi = 0; - pb->ioVFreeBytes.lo = pb->ioVFrBlk * pb->ioVAlBlkSiz; /* calculated number of free bytes on volume */ + /* No, fall back on PBHGetVInfo */ + error = PBHGetVInfoSync((HParmBlkPtr)pb); + if ( error == noErr ) + { + /* calculate the ioVTotalBytes and ioVFreeBytes fields */ + pb->ioVTotalBytes = U64Multiply(U64SetU(pb->ioVNmAlBlks), U64SetU(pb->ioVAlBlkSiz)); + pb->ioVFreeBytes = U64Multiply(U64SetU(pb->ioVFrBlk), U64SetU(pb->ioVAlBlkSiz)); + } + } + else +#endif + { + /* Yes, so use it */ + error = CallPBXGetVolInfoSync(pb); } - } - else -#endif // !__MACOSSEVENFIVEONEORLATER - { - /* Yes, so use it */ - error = PBXGetVolInfoSync(pb); } pb->ioNamePtr = NULL; /* ioNamePtr may point to local tempPathname, so don't return it */ } @@ -291,8 +659,6 @@ pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname, return ( error ); } -// #endif - /*****************************************************************************/ pascal OSErr GetCatInfoNoName(short vRefNum, @@ -341,164 +707,77 @@ pascal OSErr DetermineVRefNum(ConstStr255Param pathname, /*****************************************************************************/ -#if !TARGET_CARBON pascal OSErr HGetVInfo(short volReference, StringPtr volName, short *vRefNum, unsigned long *freeBytes, unsigned long *totalBytes) { - HParamBlockRec pb; - unsigned long allocationBlockSize; - unsigned short numAllocationBlocks; - unsigned short numFreeBlocks; - VCB *theVCB; - Boolean vcbFound; - OSErr result; - - /* Use the File Manager to get the real vRefNum */ - pb.volumeParam.ioVRefNum = volReference; - pb.volumeParam.ioNamePtr = volName; - pb.volumeParam.ioVolIndex = 0; /* use ioVRefNum only, return volume name */ - result = PBHGetVInfoSync(&pb); + OSErr result; + UInt64 freeBytes64; + UInt64 totalBytes64; + // get the best values possible from XGetVInfo + result = XGetVInfo(volReference, volName, vRefNum, &freeBytes64, &totalBytes64); if ( result == noErr ) { - /* The volume name was returned in volName (if not NULL) and */ - /* we have the volume's vRefNum and allocation block size */ - *vRefNum = pb.volumeParam.ioVRefNum; - allocationBlockSize = (unsigned long)pb.volumeParam.ioVAlBlkSiz; - - /* System 7.5 (and beyond) pins the number of allocation blocks and */ - /* the number of free allocation blocks returned by PBHGetVInfo to */ - /* a value so that when multiplied by the allocation block size, */ - /* the volume will look like it has $7fffffff bytes or less. This */ - /* was done so older applications that use signed math or that use */ - /* the GetVInfo function (which uses signed math) will continue to work. */ - /* However, the unpinned numbers (which we want) are always available */ - /* in the volume's VCB so we'll get those values from the VCB if possible. */ - - /* Find the volume's VCB */ - vcbFound = false; - theVCB = (VCB *)(GetVCBQHdr()->qHead); - while ( (theVCB != NULL) && !vcbFound ) - { - /* Check VCB signature before using VCB. Don't have to check for */ - /* MFS (0xd2d7) because they can't get big enough to be pinned */ - if ( theVCB->vcbSigWord == 0x4244 ) - { - if ( theVCB->vcbVRefNum == *vRefNum ) - { - vcbFound = true; - } - } - - if ( !vcbFound ) - { - theVCB = (VCB *)(theVCB->qLink); - } + // and pin those values if needed + if ( UInt64ToUnsignedWide(freeBytes64).hi != 0 ) + { + // pin to maximum 512-byte block aligned value + *freeBytes = 0xfffffe00; + } + else + { + *freeBytes = U32SetU(freeBytes64); } - if ( theVCB != NULL ) + if ( UInt64ToUnsignedWide(totalBytes64).hi != 0 ) { - /* Found a VCB we can use. Get the un-pinned number of allocation blocks */ - /* and the number of free blocks from the VCB. */ - numAllocationBlocks = (unsigned short)theVCB->vcbNmAlBlks; - numFreeBlocks = (unsigned short)theVCB->vcbFreeBks; + // pin to maximum 512-byte block aligned value + *totalBytes = 0xfffffe00; } else { - /* Didn't find a VCB we can use. Return the number of allocation blocks */ - /* and the number of free blocks returned by PBHGetVInfoSync. */ - numAllocationBlocks = (unsigned short)pb.volumeParam.ioVNmAlBlks; - numFreeBlocks = (unsigned short)pb.volumeParam.ioVFrBlk; + *totalBytes = U32SetU(totalBytes64); } - - /* Now, calculate freeBytes and totalBytes using unsigned values */ - *freeBytes = numFreeBlocks * allocationBlockSize; - *totalBytes = numAllocationBlocks * allocationBlockSize; } return ( result ); } -#endif -/*****************************************************************************/ - -/* -** PBXGetVolInfoSync is the glue code needed to make PBXGetVolInfoSync -** File Manager requests from CFM-based programs. At some point, Apple -** will get around to adding this to the standard libraries you link with -** and you'll get a duplicate symbol link error. At that time, just delete -** this code (or comment it out). -** -** Non-CFM 68K programs don't needs this glue (and won't get it) because -** they instead use the inline assembly glue found in the Files.h interface -** file. -*/ - -#if __WANTPASCALELIMINATION -#undef pascal -#endif - -#if !TARGET_CARBON - -#if GENERATINGCFM - -#if UNIVERSAL_INTERFACES_VERSION < 0x0301 - -pascal OSErr PBXGetVolInfoSync(XVolumeParamPtr paramBlock) -{ - enum - { - kXGetVolInfoSelector = 0x0012, /* Selector for XGetVolInfo */ - - uppFSDispatchProcInfo = kRegisterBased - | REGISTER_RESULT_LOCATION(kRegisterD0) - | RESULT_SIZE(SIZE_CODE(sizeof(OSErr))) - | REGISTER_ROUTINE_PARAMETER(1, kRegisterD1, SIZE_CODE(sizeof(long))) /* trap word */ - | REGISTER_ROUTINE_PARAMETER(2, kRegisterD0, SIZE_CODE(sizeof(long))) /* selector */ - | REGISTER_ROUTINE_PARAMETER(3, kRegisterA0, SIZE_CODE(sizeof(XVolumeParamPtr))) - }; - - return ( CallOSTrapUniversalProc(NGetTrapAddress(_FSDispatch, OSTrap), - uppFSDispatchProcInfo, - _FSDispatch, - kXGetVolInfoSelector, - paramBlock) ); -} -#endif - -#endif - -#endif - -#if __WANTPASCALELIMINATION -#define pascal -#endif - -#if !TARGET_CARBON - + /*****************************************************************************/ pascal OSErr XGetVInfo(short volReference, StringPtr volName, short *vRefNum, - UnsignedWide *freeBytes, - UnsignedWide *totalBytes) + UInt64 *freeBytes, + UInt64 *totalBytes) { OSErr result; - long response; XVolumeParam pb; +#if !TARGET_API_MAC_CARBON + + long response; + +#endif // !TARGET_API_MAC_CARBON + + pb.ioVRefNum = volReference; + pb.ioNamePtr = volName; + pb.ioXVersion = 0; /* this XVolumeParam version (0) */ + pb.ioVolIndex = 0; /* use ioVRefNum only, return volume name */ + +#if !TARGET_API_MAC_CARBON + /* See if large volume support is available */ if ( ( Gestalt(gestaltFSAttr, &response) == noErr ) && ((response & (1L << gestaltFSSupports2TBVols)) != 0) ) + +#endif // !TARGET_API_MAC_CARBON + { /* Large volume support is available */ - pb.ioVRefNum = volReference; - pb.ioNamePtr = volName; - pb.ioXVersion = 0; /* this XVolumeParam version (0) */ - pb.ioVolIndex = 0; /* use ioVRefNum only, return volume name */ - result = PBXGetVolInfoSync(&pb); + result = CallPBXGetVolInfoSync(&pb); if ( result == noErr ) { /* The volume name was returned in volName (if not NULL) and */ @@ -506,26 +785,72 @@ pascal OSErr XGetVInfo(short volReference, *vRefNum = pb.ioVRefNum; /* return the freeBytes and totalBytes */ - *totalBytes = UInt64ToUnsignedWide(pb.ioVTotalBytes); - *freeBytes = UInt64ToUnsignedWide(pb.ioVFreeBytes); + *totalBytes = pb.ioVTotalBytes; + *freeBytes = pb.ioVFreeBytes; } } + +#if !TARGET_API_MAC_CARBON + else { /* No large volume support */ - - /* Use HGetVInfo to get the results */ - result = HGetVInfo(volReference, volName, vRefNum, &freeBytes->lo, &totalBytes->lo); + /* Use PBHGetVInfoSync to get the results */ + result = PBHGetVInfoSync((HParmBlkPtr)&pb); if ( result == noErr ) { - /* zero the high longs of totalBytes and freeBytes */ - totalBytes->hi = 0; - freeBytes->hi = 0; + VCB *theVCB; + + /* The volume name was returned in volName (if not NULL) and */ + /* we have the volume's vRefNum */ + *vRefNum = pb.ioVRefNum; + + /* System 7.5 (and beyond) pins the number of allocation blocks and */ + /* the number of free allocation blocks returned by PBHGetVInfo to */ + /* a value so that when multiplied by the allocation block size, */ + /* the volume will look like it has $7fffffff bytes or less. This */ + /* was done so older applications that use signed math or that use */ + /* the GetVInfo function (which uses signed math) will continue to work. */ + /* However, the unpinned numbers (which we want) are always available */ + /* in the volume's VCB so we'll get those values from the VCB. */ + /* Note: Carbon doesn't support the VCB queue, so this code cannot be */ + /* used (and is conditionalized out) by Carbon applications. */ + + /* Find the volume's VCB */ + theVCB = (VCB *)(GetVCBQHdr()->qHead); + while ( theVCB != NULL ) + { + if ( theVCB->vcbVRefNum == *vRefNum ) + { + break; + } + + theVCB = (VCB *)(theVCB->qLink); /* next VCB */ + } + + if ( theVCB != NULL ) + { + /* Found a VCB we can use. Get the un-pinned number of allocation blocks */ + /* and the number of free blocks from the VCB. */ + *freeBytes = U64Multiply(U64SetU((unsigned short)theVCB->vcbFreeBks), U64SetU((unsigned long)pb.ioVAlBlkSiz)); + *totalBytes = U64Multiply(U64SetU((unsigned short)theVCB->vcbNmAlBlks), U64SetU((unsigned long)pb.ioVAlBlkSiz)); + } + else + { + /* Didn't find a VCB we can use. Return the number of allocation blocks */ + /* and the number of free blocks returned by PBHGetVInfoSync. */ + *freeBytes = U64Multiply(U64SetU((unsigned short)pb.ioVFrBlk), U64SetU((unsigned long)pb.ioVAlBlkSiz)); + *totalBytes = U64Multiply(U64SetU((unsigned short)pb.ioVNmAlBlks), U64SetU((unsigned long)pb.ioVAlBlkSiz)); + } + } } + +#endif // !TARGET_API_MAC_CARBON + return ( result ); } -#endif + /*****************************************************************************/ pascal OSErr CheckVolLock(ConstStr255Param pathname, @@ -537,11 +862,11 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, error = GetVolumeInfoNoName(pathname,vRefNum, &pb); if ( error == noErr ) { - if ( (pb.volumeParam.ioVAtrb & 0x0080) != 0 ) + if ( (pb.volumeParam.ioVAtrb & kHFSVolumeHardwareLockMask) != 0 ) { error = wPrErr; /* volume locked by hardware */ } - else if ( (pb.volumeParam.ioVAtrb & 0x8000) != 0 ) + else if ( (pb.volumeParam.ioVAtrb & kHFSVolumeSoftwareLockMask) != 0 ) { error = vLckdErr; /* volume locked by software */ } @@ -551,210 +876,238 @@ pascal OSErr CheckVolLock(ConstStr255Param pathname, } /*****************************************************************************/ +// +// The following routines call Mac OS routines that are not supported by +// Carbon: +// +// GetDriverName +// FindDrive +// GetDiskBlocks +// GetVolState -#if !TARGET_CARBON +#if !TARGET_API_MAC_CARBON // { -pascal OSErr GetDriverName(short driverRefNum, - Str255 driverName) -{ - OSErr result; - DCtlHandle theDctl; - DRVRHeaderPtr dHeaderPtr; - - theDctl = GetDCtlEntry(driverRefNum); - if ( theDctl != NULL ) - { - if ( (**theDctl).dCtlFlags & 0x40 ) - { - /* dctlDriver is handle - dereference */ - dHeaderPtr = *((DRVRHeaderHandle)(**theDctl).dCtlDriver); - } - else - { - /* dctlDriver is pointer */ - dHeaderPtr = (DRVRHeaderPtr)(**theDctl).dCtlDriver; - } - BlockMoveData((*dHeaderPtr).drvrName, driverName, (*dHeaderPtr).drvrName[0] + 1); - result = noErr; - } - else - { - driverName[0] = 0; - result = badUnitErr; /* bad reference number */ - } - - return ( result ); -} - -#endif -/*****************************************************************************/ -#if !TARGET_CARBON + /*****************************************************************************/ -pascal OSErr FindDrive(ConstStr255Param pathname, - short vRefNum, - DrvQElPtr *driveQElementPtr) -{ - OSErr result; - HParamBlockRec hPB; - short driveNumber; - - *driveQElementPtr = NULL; - - /* First, use GetVolumeInfoNoName to determine the volume */ - result = GetVolumeInfoNoName(pathname, vRefNum, &hPB); - if ( result == noErr ) + pascal OSErr GetDriverName(short driverRefNum, + Str255 driverName) { - /* - ** The volume can be either online, offline, or ejected. What we find in - ** ioVDrvInfo and ioVDRefNum will tell us which it is. - ** See Inside Macintosh: Files page 2-80 and the Technical Note - ** "FL 34 - VCBs and Drive Numbers : The Real Story" - ** Where we get the drive number depends on the state of the volume. - */ - if ( hPB.volumeParam.ioVDrvInfo != 0 ) - { - /* The volume is online and not ejected */ - /* Get the drive number */ - driveNumber = hPB.volumeParam.ioVDrvInfo; + OSErr result; + DCtlHandle theDctl; + DRVRHeaderPtr dHeaderPtr; + + theDctl = GetDCtlEntry(driverRefNum); + if ( theDctl != NULL ) + { + if ( (**theDctl).dCtlFlags & dRAMBasedMask ) + { + /* dctlDriver is handle - dereference */ + dHeaderPtr = *((DRVRHeaderHandle)(**theDctl).dCtlDriver); + } + else + { + /* dctlDriver is pointer */ + dHeaderPtr = (DRVRHeaderPtr)(**theDctl).dCtlDriver; + } + BlockMoveData((*dHeaderPtr).drvrName, driverName, (*dHeaderPtr).drvrName[0] + 1); + result = noErr; } else { - /* The volume's is either offline or ejected */ - /* in either case, the volume is NOT online */ - - /* Is it ejected or just offline? */ - if ( hPB.volumeParam.ioVDRefNum > 0 ) - { - /* It's ejected, the drive number is ioVDRefNum */ - driveNumber = hPB.volumeParam.ioVDRefNum; - } - else - { - /* It's offline, the drive number is the negative of ioVDRefNum */ - driveNumber = (short)-hPB.volumeParam.ioVDRefNum; - } - } - - /* Get pointer to first element in drive queue */ - *driveQElementPtr = (DrvQElPtr)(GetDrvQHdr()->qHead); - - /* Search for a matching drive number */ - while ( (*driveQElementPtr != NULL) && ((*driveQElementPtr)->dQDrive != driveNumber) ) - { - *driveQElementPtr = (DrvQElPtr)(*driveQElementPtr)->qLink; + driverName[0] = 0; + result = badUnitErr; /* bad reference number */ } - if ( *driveQElementPtr == NULL ) - { - /* This should never happen since every volume must have a drive, but... */ - result = nsDrvErr; - } + return ( result ); } - - return ( result ); -} -#endif -/*****************************************************************************/ -#if !TARGET_CARBON + /*****************************************************************************/ -pascal OSErr GetDiskBlocks(ConstStr255Param pathname, + pascal OSErr FindDrive(ConstStr255Param pathname, short vRefNum, - unsigned long *numBlocks) -{ - /* Various constants for GetDiskBlocks() */ - enum + DrvQElPtr *driveQElementPtr) { - /* return format list status code */ - kFmtLstCode = 6, + OSErr result; + HParamBlockRec hPB; + short driveNumber; - /* reference number of .SONY driver */ - kSonyRefNum = 0xfffb, + *driveQElementPtr = NULL; - /* values returned by DriveStatus in DrvSts.twoSideFmt */ - kSingleSided = 0, - kDoubleSided = -1, - kSingleSidedSize = 800, /* 400K */ - kDoubleSidedSize = 1600, /* 800K */ - - /* values in DrvQEl.qType */ - kWordDrvSiz = 0, - kLongDrvSiz = 1, - - /* more than enough formatListRecords */ - kMaxFormatListRecs = 16 - }; - - DrvQElPtr driveQElementPtr; - unsigned long blocks; - ParamBlockRec pb; - FormatListRec formatListRecords[kMaxFormatListRecs]; - DrvSts status; - short formatListRecIndex; - OSErr result; + /* First, use GetVolumeInfoNoName to determine the volume */ + result = GetVolumeInfoNoName(pathname, vRefNum, &hPB); + if ( result == noErr ) + { + /* + ** The volume can be either online, offline, or ejected. What we find in + ** ioVDrvInfo and ioVDRefNum will tell us which it is. + ** See Inside Macintosh: Files page 2-80 and the Technical Note + ** "FL 34 - VCBs and Drive Numbers : The Real Story" + ** Where we get the drive number depends on the state of the volume. + */ + if ( hPB.volumeParam.ioVDrvInfo != 0 ) + { + /* The volume is online and not ejected */ + /* Get the drive number */ + driveNumber = hPB.volumeParam.ioVDrvInfo; + } + else + { + /* The volume's is either offline or ejected */ + /* in either case, the volume is NOT online */ - blocks = 0; - - /* Find the drive queue element for this volume */ - result = FindDrive(pathname, vRefNum, &driveQElementPtr); - - /* - ** Make sure this is a real driver (dQRefNum < 0). - ** AOCE's Mail Enclosures volume uses 0 for dQRefNum which will cause - ** problems if you try to use it as a driver refNum. - */ - if ( (result == noErr) && (driveQElementPtr->dQRefNum >= 0) ) - { - result = paramErr; + /* Is it ejected or just offline? */ + if ( hPB.volumeParam.ioVDRefNum > 0 ) + { + /* It's ejected, the drive number is ioVDRefNum */ + driveNumber = hPB.volumeParam.ioVDRefNum; + } + else + { + /* It's offline, the drive number is the negative of ioVDRefNum */ + driveNumber = (short)-hPB.volumeParam.ioVDRefNum; + } + } + + /* Get pointer to first element in drive queue */ + *driveQElementPtr = (DrvQElPtr)(GetDrvQHdr()->qHead); + + /* Search for a matching drive number */ + while ( (*driveQElementPtr != NULL) && ((*driveQElementPtr)->dQDrive != driveNumber) ) + { + *driveQElementPtr = (DrvQElPtr)(*driveQElementPtr)->qLink; + } + + if ( *driveQElementPtr == NULL ) + { + /* This should never happen since every volume must have a drive, but... */ + result = nsDrvErr; + } + } + + return ( result ); } - else + + /*****************************************************************************/ + + pascal OSErr GetDiskBlocks(ConstStr255Param pathname, + short vRefNum, + unsigned long *numBlocks) { - /* Attempt to get the drive's format list. */ - /* (see the Technical Note "What Your Sony Drives For You") */ + /* Various constants for GetDiskBlocks() */ + enum + { + /* return format list status code */ + kFmtLstCode = 6, + + /* reference number of .SONY driver */ + kSonyRefNum = 0xfffb, + + /* values returned by DriveStatus in DrvSts.twoSideFmt */ + kSingleSided = 0, + kDoubleSided = -1, + kSingleSidedSize = 800, /* 400K */ + kDoubleSidedSize = 1600, /* 800K */ + + /* values in DrvQEl.qType */ + kWordDrvSiz = 0, + kLongDrvSiz = 1, + + /* more than enough formatListRecords */ + kMaxFormatListRecs = 16 + }; - pb.cntrlParam.ioVRefNum = driveQElementPtr->dQDrive; - pb.cntrlParam.ioCRefNum = driveQElementPtr->dQRefNum; - pb.cntrlParam.csCode = kFmtLstCode; - pb.cntrlParam.csParam[0] = kMaxFormatListRecs; - *(long *)&pb.cntrlParam.csParam[1] = (long)&formatListRecords[0]; + DrvQElPtr driveQElementPtr; + unsigned long blocks; + ParamBlockRec pb; + FormatListRec formatListRecords[kMaxFormatListRecs]; + DrvSts status; + short formatListRecIndex; + OSErr result; + + blocks = 0; - result = PBStatusSync(&pb); + /* Find the drive queue element for this volume */ + result = FindDrive(pathname, vRefNum, &driveQElementPtr); - if ( result == noErr ) + /* + ** Make sure this is a real driver (dQRefNum < 0). + ** AOCE's Mail Enclosures volume uses 0 for dQRefNum which will cause + ** problems if you try to use it as a driver refNum. + */ + if ( (result == noErr) && (driveQElementPtr->dQRefNum >= 0) ) { - /* The drive supports ReturnFormatList status call. */ - - /* Get the current disk's size. */ - for( formatListRecIndex = 0; - formatListRecIndex < pb.cntrlParam.csParam[0]; - ++formatListRecIndex ) - { - if ( (formatListRecords[formatListRecIndex].formatFlags & - diCIFmtFlagsCurrentMask) != 0 ) - { - blocks = formatListRecords[formatListRecIndex].volSize; - } - } - if ( blocks == 0 ) - { - /* This should never happen */ - result = paramErr; - } + result = paramErr; } - else if ( driveQElementPtr->dQRefNum == (short)kSonyRefNum ) + else { - /* The drive is a non-SuperDrive floppy which only supports 400K and 800K disks */ + /* Attempt to get the drive's format list. */ + /* (see the Technical Note "What Your Sony Drives For You") */ + + pb.cntrlParam.ioVRefNum = driveQElementPtr->dQDrive; + pb.cntrlParam.ioCRefNum = driveQElementPtr->dQRefNum; + pb.cntrlParam.csCode = kFmtLstCode; + pb.cntrlParam.csParam[0] = kMaxFormatListRecs; + *(long *)&pb.cntrlParam.csParam[1] = (long)&formatListRecords[0]; + + result = PBStatusSync(&pb); - result = DriveStatus(driveQElementPtr->dQDrive, &status); if ( result == noErr ) { - switch ( status.twoSideFmt ) + /* The drive supports ReturnFormatList status call. */ + + /* Get the current disk's size. */ + for( formatListRecIndex = 0; + formatListRecIndex < pb.cntrlParam.csParam[0]; + ++formatListRecIndex ) + { + if ( (formatListRecords[formatListRecIndex].formatFlags & + diCIFmtFlagsCurrentMask) != 0 ) + { + blocks = formatListRecords[formatListRecIndex].volSize; + } + } + if ( blocks == 0 ) + { + /* This should never happen */ + result = paramErr; + } + } + else if ( driveQElementPtr->dQRefNum == (short)kSonyRefNum ) + { + /* The drive is a non-SuperDrive floppy which only supports 400K and 800K disks */ + + result = DriveStatus(driveQElementPtr->dQDrive, &status); + if ( result == noErr ) { - case kSingleSided: - blocks = kSingleSidedSize; + switch ( status.twoSideFmt ) + { + case kSingleSided: + blocks = kSingleSidedSize; + break; + case kDoubleSided: + blocks = kDoubleSidedSize; + break; + default: + /* This should never happen */ + result = paramErr; + break; + } + } + } + else + { + /* The drive is not a floppy and it doesn't support ReturnFormatList */ + /* so use the dQDrvSz field(s) */ + + result = noErr; /* reset result */ + switch ( driveQElementPtr->qType ) + { + case kWordDrvSiz: + blocks = driveQElementPtr->dQDrvSz; break; - case kDoubleSided: - blocks = kDoubleSidedSize; + case kLongDrvSiz: + blocks = ((unsigned long)driveQElementPtr->dQDrvSz2 << 16) + + driveQElementPtr->dQDrvSz; break; default: /* This should never happen */ @@ -763,172 +1116,162 @@ pascal OSErr GetDiskBlocks(ConstStr255Param pathname, } } } - else + + if ( result == noErr ) { - /* The drive is not a floppy and it doesn't support ReturnFormatList */ - /* so use the dQDrvSz field(s) */ - - result = noErr; /* reset result */ - switch ( driveQElementPtr->qType ) - { - case kWordDrvSiz: - blocks = driveQElementPtr->dQDrvSz; - break; - case kLongDrvSiz: - blocks = ((unsigned long)driveQElementPtr->dQDrvSz2 << 16) + - driveQElementPtr->dQDrvSz; - break; - default: - /* This should never happen */ - result = paramErr; - break; - } + *numBlocks = blocks; } + + return ( result ); } - - if ( result == noErr ) - { - *numBlocks = blocks; - } - - return ( result ); -} -#endif - -/*****************************************************************************/ -pascal OSErr GetVolFileSystemID(ConstStr255Param pathname, - short vRefNum, - short *fileSystemID) -{ - HParamBlockRec pb; - OSErr error; + /*****************************************************************************/ - error = GetVolumeInfoNoName(pathname,vRefNum, &pb); - if ( error == noErr ) + pascal OSErr GetVolState(ConstStr255Param pathname, + short vRefNum, + Boolean *volumeOnline, + Boolean *volumeEjected, + Boolean *driveEjectable, + Boolean *driverWantsEject) { - *fileSystemID = pb.volumeParam.ioVFSID; - } - - return ( error ); -} + HParamBlockRec pb; + short driveNumber; + OSErr error; -/*****************************************************************************/ -#if !TARGET_CARBON - -pascal OSErr GetVolState(ConstStr255Param pathname, - short vRefNum, - Boolean *volumeOnline, - Boolean *volumeEjected, - Boolean *driveEjectable, - Boolean *driverWantsEject) -{ - HParamBlockRec pb; - short driveNumber; - OSErr error; - - error = GetVolumeInfoNoName(pathname,vRefNum, &pb); - if ( error == noErr ) - { - if ( pb.volumeParam.ioVDrvInfo != 0 ) - { - /* the volume is online and not ejected */ - *volumeOnline = true; - *volumeEjected = false; - - /* Get the drive number */ - driveNumber = pb.volumeParam.ioVDrvInfo; - } - else + error = GetVolumeInfoNoName(pathname,vRefNum, &pb); + if ( error == noErr ) { - /* the volume's is either offline or ejected */ - /* in either case, the volume is NOT online */ - *volumeOnline = false; - - /* Is it ejected? */ - *volumeEjected = pb.volumeParam.ioVDRefNum > 0; - - if ( *volumeEjected ) + if ( pb.volumeParam.ioVDrvInfo != 0 ) { - /* If ejected, the drive number is ioVDRefNum */ - driveNumber = pb.volumeParam.ioVDRefNum; + /* the volume is online and not ejected */ + *volumeOnline = true; + *volumeEjected = false; + + /* Get the drive number */ + driveNumber = pb.volumeParam.ioVDrvInfo; } else { - /* If offline, the drive number is the negative of ioVDRefNum */ - driveNumber = (short)-pb.volumeParam.ioVDRefNum; - } - } - - { - DrvQElPtr drvQElem; - - /* Find the drive queue element by searching the drive queue */ - drvQElem = (DrvQElPtr)(GetDrvQHdr()->qHead); - while ( (drvQElem != NULL) && (drvQElem->dQDrive != driveNumber) ) - { - drvQElem = (DrvQElPtr)drvQElem->qLink; + /* the volume's is either offline or ejected */ + /* in either case, the volume is NOT online */ + *volumeOnline = false; + + /* Is it ejected? */ + *volumeEjected = pb.volumeParam.ioVDRefNum > 0; + + if ( *volumeEjected ) + { + /* If ejected, the drive number is ioVDRefNum */ + driveNumber = pb.volumeParam.ioVDRefNum; + } + else + { + /* If offline, the drive number is the negative of ioVDRefNum */ + driveNumber = (short)-pb.volumeParam.ioVDRefNum; + } } - if ( drvQElem != NULL ) { - /* - ** Each drive queue element is preceded by 4 flag bytes. - ** Byte 1 (the second flag byte) has bits that tell us if a - ** drive is ejectable and if its driver wants an eject call. - ** See Inside Macintosh: Files, page 2-85. - */ + DrvQElPtr drvQElem; + + /* Find the drive queue element by searching the drive queue */ + drvQElem = (DrvQElPtr)(GetDrvQHdr()->qHead); + while ( (drvQElem != NULL) && (drvQElem->dQDrive != driveNumber) ) + { + drvQElem = (DrvQElPtr)drvQElem->qLink; + } + + if ( drvQElem != NULL ) { - Ptr flagBytePtr; - - /* point to byte 1 of the flag bytes */ - flagBytePtr = (Ptr)drvQElem; - flagBytePtr -= 3; - - /* - ** The drive is ejectable if flag byte 1 does not contain - ** 0x08 (nonejectable) or 0x48 (nonejectable, but wants eject call). - */ - - *driveEjectable = (*flagBytePtr != 0x08) && (*flagBytePtr != 0x48); - /* - ** The driver wants an eject call if flag byte 1 does not contain - ** 0x08 (nonejectable). This may seem like a minor point, but some - ** disk drivers use the Eject request to flush their caches to disk - ** and you wouldn't want to skip that step after unmounting a volume. + ** Each drive queue element is preceded by 4 flag bytes. + ** Byte 1 (the second flag byte) has bits that tell us if a + ** drive is ejectable and if its driver wants an eject call. + ** See Inside Macintosh: Files, page 2-85. */ - - *driverWantsEject = (*flagBytePtr != 0x08); + { + Ptr flagBytePtr; + + /* point to byte 1 of the flag bytes */ + flagBytePtr = (Ptr)drvQElem; + flagBytePtr -= 3; + + /* + ** The drive is ejectable if flag byte 1 does not contain + ** 0x08 (nonejectable) or 0x48 (nonejectable, but wants eject call). + */ + + *driveEjectable = (*flagBytePtr != 0x08) && (*flagBytePtr != 0x48); + + /* + ** The driver wants an eject call if flag byte 1 does not contain + ** 0x08 (nonejectable). This may seem like a minor point, but some + ** disk drivers use the Eject request to flush their caches to disk + ** and you wouldn't want to skip that step after unmounting a volume. + */ + + *driverWantsEject = (*flagBytePtr != 0x08); + } + } + else + { + /* Didn't find the drive (this should never happen) */ + *driveEjectable = false; + *driverWantsEject = false; } - } - else - { - /* Didn't find the drive (this should never happen) */ - *driveEjectable = false; - *driverWantsEject = false; } } + + return ( error ); + } + + /*****************************************************************************/ + +#endif // } !TARGET_API_MAC_CARBON + +/*****************************************************************************/ + +pascal OSErr GetVolFileSystemID(ConstStr255Param pathname, + short vRefNum, + short *fileSystemID) +{ + HParamBlockRec pb; + OSErr error; + + error = GetVolumeInfoNoName(pathname,vRefNum, &pb); + if ( error == noErr ) + { + *fileSystemID = pb.volumeParam.ioVFSID; } return ( error ); } -#endif + /*****************************************************************************/ -#if !TARGET_CARBON +// +// Note: Under Carbon there are no drive numbers, so you cannot call +// Eject with a drive number after unmounting a volume. +// When a Carbon application calls UnmountVol, CarbonLib will make +// sure ejectable media is ejected (leaving ejectable media in the +// disk drive makes no sense to Carbon applications). +// pascal OSErr UnmountAndEject(ConstStr255Param pathname, short vRefNum) { HParamBlockRec pb; - short driveNum; - Boolean ejected, wantsEject; - DrvQElPtr drvQElem; OSErr error; error = GetVolumeInfoNoName(pathname, vRefNum, &pb); if ( error == noErr ) { + +#if !TARGET_API_MAC_CARBON + + short driveNum; + Boolean ejected, wantsEject; + DrvQElPtr drvQElem; + if ( pb.volumeParam.ioVDrvInfo != 0 ) { /* the volume is online and not ejected */ @@ -974,10 +1317,15 @@ pascal OSErr UnmountAndEject(ConstStr255Param pathname, wantsEject = false; } +#endif // !TARGET_API_MAC_CARBON + /* unmount the volume */ pb.volumeParam.ioNamePtr = NULL; /* ioVRefNum is already filled in from PBHGetVInfo */ error = PBUnmountVol((ParmBlkPtr)&pb); + +#if !TARGET_API_MAC_CARBON + if ( error == noErr ) { if ( wantsEject && !ejected ) @@ -987,11 +1335,13 @@ pascal OSErr UnmountAndEject(ConstStr255Param pathname, error = PBEject((ParmBlkPtr)&pb); } } + +#endif // !TARGET_API_MAC_CARBON + } return ( error ); } -#endif /*****************************************************************************/ @@ -1051,12 +1401,13 @@ pascal OSErr SetDefault(short newVRefNum, /*****************************************************************************/ -#if !TARGET_CARBON - pascal OSErr RestoreDefault(short oldVRefNum, long oldDirID) { OSErr error; + +#if !TARGET_API_MAC_CARBON + short defaultVRefNum; long defaultDirID; long defaultProcID; @@ -1073,14 +1424,21 @@ pascal OSErr RestoreDefault(short oldVRefNum, } else { + +#endif // !TARGET_API_MAC_CARBON + /* oldVRefNum was a real vRefNum - use HSetVol */ error = HSetVol(NULL, oldVRefNum, oldDirID); + +#if !TARGET_API_MAC_CARBON + } } +#endif // !TARGET_API_MAC_CARBON return ( error ); } -#endif + /*****************************************************************************/ pascal OSErr GetDInfo(short vRefNum, @@ -1094,7 +1452,7 @@ pascal OSErr GetDInfo(short vRefNum, error = GetCatInfoNoName(vRefNum, dirID, name, &pb); if ( error == noErr ) { - if ( (pb.dirInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (pb.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* it's a directory, return the DInfo */ *fndrInfo = pb.dirInfo.ioDrUsrWds; @@ -1145,7 +1503,7 @@ pascal OSErr SetDInfo(short vRefNum, error = PBGetCatInfoSync(&pb); if ( error == noErr ) { - if ( (pb.dirInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (pb.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* it's a directory, set the DInfo */ if ( pb.dirInfo.ioNamePtr == tempName ) @@ -1191,7 +1549,7 @@ pascal OSErr GetDirectoryID(short vRefNum, error = GetCatInfoNoName(vRefNum, dirID, name, &pb); if ( error == noErr ) { - *isDirectory = (pb.hFileInfo.ioFlAttrib & ioDirMask) != 0; + *isDirectory = (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0; if ( *isDirectory ) { *theDirID = pb.dirInfo.ioDrDirID; @@ -1259,7 +1617,7 @@ pascal OSErr GetIOACUser(short vRefNum, error = GetCatInfoNoName(vRefNum, dirID, name, &pb); if ( error == noErr ) { - if ( (pb.hFileInfo.ioFlAttrib & ioDirMask) == 0 ) + if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) == 0 ) { /* oops, a file was passed */ error = dirNFErr; @@ -1322,7 +1680,7 @@ pascal OSErr GetParentID(short vRefNum, ** object is a directory and there are multiple separators at ** the end of the name parameter. */ - if ( (pb.hFileInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* Its a directory */ @@ -1495,7 +1853,7 @@ pascal OSErr GetObjectLocation(short vRefNum, */ /* Is it a directory or a file? */ - *isDirectory = (pb.hFileInfo.ioFlAttrib & ioDirMask) != 0; + *isDirectory = (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0; if ( *isDirectory ) { /* @@ -1644,7 +2002,7 @@ pascal OSErr GetDirItems(short vRefNum, items->vRefNum = pb.hFileInfo.ioVRefNum; /* return item's vRefNum */ ++*itemIndex; /* prepare to get next item in directory */ - if ( (pb.hFileInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { if ( getDirectories ) { @@ -1698,7 +2056,7 @@ static void DeleteLevel(long dirToDelete, { savedDir = dirToDelete; /* We have an item. Is it a file or directory? */ - if ( (theGlobals->myPB.ciPB.dirInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (theGlobals->myPB.ciPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* it's a directory */ savedDir = theGlobals->myPB.ciPB.dirInfo.ioDrDirID; /* save dirID of directory instead */ @@ -1798,7 +2156,7 @@ pascal OSErr CheckObjectLock(short vRefNum, if ( error == noErr ) { /* check locked bit */ - if ( (pb.hFileInfo.ioFlAttrib & 0x01) != 0 ) + if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribLockedMask) != 0 ) { error = fLckdErr; } @@ -1923,7 +2281,7 @@ pascal OSErr ChangeCreatorType(short vRefNum, error = PBGetCatInfoSync(&pb); if ( error == noErr ) { - if ( (pb.hFileInfo.ioFlAttrib & ioDirMask) == 0 ) /* if file */ + if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) == 0 ) /* if file */ { parID = pb.hFileInfo.ioFlParID; /* save parent dirID for BumpDate call */ @@ -2249,7 +2607,7 @@ pascal OSErr CopyFileMgrAttributes(short srcVRefNum, error = PBGetCatInfoSync(&pb.ciPB); if ( error == noErr ) { - objectIsDirectory = ( (pb.ciPB.hFileInfo.ioFlAttrib & ioDirMask) != 0 ); + objectIsDirectory = ( (pb.ciPB.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ); pb.ciPB.hFileInfo.ioVRefNum = dstVRefNum; pb.ciPB.hFileInfo.ioDirID = dstDirID; if ( (dstName != NULL) && (dstName[0] == 0) ) @@ -2261,9 +2619,9 @@ pascal OSErr CopyFileMgrAttributes(short srcVRefNum, pb.ciPB.hFileInfo.ioNamePtr = (StringPtr)dstName; } /* don't copy the hasBeenInited bit */ - pb.ciPB.hFileInfo.ioFlFndrInfo.fdFlags = ( pb.ciPB.hFileInfo.ioFlFndrInfo.fdFlags & 0xfeff ); + pb.ciPB.hFileInfo.ioFlFndrInfo.fdFlags = ( pb.ciPB.hFileInfo.ioFlFndrInfo.fdFlags & ~kHasBeenInited ); error = PBSetCatInfoSync(&pb.ciPB); - if ( (error == noErr) && (copyLockBit) && ((pb.ciPB.hFileInfo.ioFlAttrib & 0x01) != 0) ) + if ( (error == noErr) && (copyLockBit) && ((pb.ciPB.hFileInfo.ioFlAttrib & kioFlAttribLockedMask) != 0) ) { pb.hPB.fileParam.ioFVersNum = 0; error = PBHSetFLockSync(&pb.hPB); @@ -2310,7 +2668,7 @@ pascal OSErr HOpenAware(short vRefNum, /* this preflighting is needed because Foreign File Access based file systems don't */ /* return the correct error result to the OpenDeny call */ error = HGetVolParms(fileName, vRefNum, &volParmsInfo, &infoSize); - if ( (error == noErr) && hasOpenDeny(volParmsInfo) ) + if ( (error == noErr) && hasOpenDeny(&volParmsInfo) ) { /* if volume supports OpenDeny, use it and return */ pb.accessParam.ioDenyModes = denyModes; @@ -2391,10 +2749,10 @@ pascal OSErr HOpenRFAware(short vRefNum, /* this preflighting is needed because Foreign File Access based file systems don't */ /* return the correct error result to the OpenRFDeny call */ error = HGetVolParms(fileName, vRefNum, &volParmsInfo, &infoSize); - if ( (error == noErr) && hasOpenDeny(volParmsInfo) ) + if ( (error == noErr) && hasOpenDeny(&volParmsInfo) ) { /* if volume supports OpenRFDeny, use it and return */ - if ( hasOpenDeny(volParmsInfo) ) + if ( hasOpenDeny(&volParmsInfo) ) { pb.accessParam.ioDenyModes = denyModes; error = PBHOpenRFDenySync(&pb); @@ -2460,7 +2818,7 @@ pascal OSErr FSReadNoCache(short refNum, pb.ioParam.ioRefNum = refNum; pb.ioParam.ioBuffer = (Ptr)buffPtr; pb.ioParam.ioReqCount = *count; - pb.ioParam.ioPosMode = fsAtMark + 0x0020; /* fsAtMark + noCacheBit */ + pb.ioParam.ioPosMode = fsAtMark + noCacheMask; /* fsAtMark + noCacheMask */ pb.ioParam.ioPosOffset = 0; error = PBReadSync(&pb); *count = pb.ioParam.ioActCount; /* always return count */ @@ -2479,7 +2837,7 @@ pascal OSErr FSWriteNoCache(short refNum, pb.ioParam.ioRefNum = refNum; pb.ioParam.ioBuffer = (Ptr)buffPtr; pb.ioParam.ioReqCount = *count; - pb.ioParam.ioPosMode = fsAtMark + 0x0020; /* fsAtMark + noCacheBit */ + pb.ioParam.ioPosMode = fsAtMark + noCacheMask; /* fsAtMark + noCacheMask */ pb.ioParam.ioPosOffset = 0; error = PBWriteSync(&pb); *count = pb.ioParam.ioActCount; /* always return count */ @@ -2685,7 +3043,7 @@ pascal OSErr CopyFork(short srcRefNum, /* set up fields that won't change in the loop */ srcPB.ioParam.ioBuffer = (Ptr)copyBufferPtr; - srcPB.ioParam.ioPosMode = fsAtMark + 0x0020;/* fsAtMark + noCacheBit */ + srcPB.ioParam.ioPosMode = fsAtMark + noCacheMask;/* fsAtMark + noCacheMask */ /* If copyBufferSize is greater than 512 bytes, make it a multiple of 512 bytes */ /* This will make writes on local volumes faster */ if ( (copyBufferSize >= 512) && ((copyBufferSize & 0x1ff) != 0) ) @@ -2697,7 +3055,7 @@ pascal OSErr CopyFork(short srcRefNum, srcPB.ioParam.ioReqCount = copyBufferSize; } dstPB.ioParam.ioBuffer = (Ptr)copyBufferPtr; - dstPB.ioParam.ioPosMode = fsAtMark + 0x0020;/* fsAtMark + noCacheBit */ + dstPB.ioParam.ioPosMode = fsAtMark + noCacheMask;/* fsAtMark + noCacheMask */ while ( (srcError == noErr) && (dstError == noErr) ) { @@ -2766,9 +3124,9 @@ pascal OSErr CopyDirectoryAccess(short srcVRefNum, /* See if destination supports directory access control */ tempLong = sizeof(infoBuffer); error = HGetVolParms(dstName, dstVRefNum, &infoBuffer, &tempLong); - if ( (error == noErr) && hasAccessCntl(infoBuffer) ) + if ( (error == noErr) && hasAccessCntl(&infoBuffer) ) { - if ( hasAccessCntl(infoBuffer) ) + if ( hasAccessCntl(&infoBuffer) ) { dstServerAdr = infoBuffer.vMServerAdr; @@ -2777,7 +3135,7 @@ pascal OSErr CopyDirectoryAccess(short srcVRefNum, error = HGetVolParms(srcName, srcVRefNum, &infoBuffer, &tempLong); if ( error == noErr ) { - if ( hasAccessCntl(infoBuffer) && (dstServerAdr == infoBuffer.vMServerAdr) ) + if ( hasAccessCntl(&infoBuffer) && (dstServerAdr == infoBuffer.vMServerAdr) ) { /* both volumes support directory access control and they are */ /* on same server, so copy the access information */ @@ -2838,7 +3196,7 @@ pascal OSErr HMoveRenameCompat(short vRefNum, /* Get volume attributes */ infoSize = sizeof(GetVolParmsInfoBuffer); error = HGetVolParms((StringPtr)srcName, vRefNum, &volParmsInfo, &infoSize); - if ( (error == noErr) && hasMoveRename(volParmsInfo) ) + if ( (error == noErr) && hasMoveRename(&volParmsInfo) ) { /* If volume supports move and rename, so use it and return */ error = HMoveRename(vRefNum, srcDirID, srcName, dstDirID, dstpathName, copyName); diff --git a/src/mac/morefile/MoreFilesExtras.h b/src/mac/morefile/MoreFilesExtras.h new file mode 100644 index 0000000000..285dfa7977 --- /dev/null +++ b/src/mac/morefile/MoreFilesExtras.h @@ -0,0 +1,3597 @@ +/* + File: MoreFilesExtras.h + + Contains: A collection of useful high-level File Manager routines. + + 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 __MOREFILESEXTRAS__ +#define __MOREFILESEXTRAS__ + +#ifndef __MACTYPES__ +#include +#endif + +#ifndef __FILES__ +#include +#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 + +/*****************************************************************************/ + +/* +** Bit masks and macros to get common information out of ioACUser returned +** by PBGetCatInfo (remember to clear ioACUser before calling PBGetCatInfo +** since some file systems don't bother to set this field). +** +** Use the GetDirAccessRestrictions or FSpGetDirAccessRestrictions +** functions to retrieve the ioACUser access restrictions byte for +** a folder. +** +** Note: The access restriction byte returned by PBGetCatInfo is the +** 2's complement of the user's privileges byte returned in +** ioACAccess by PBHGetDirAccess. +*/ + +enum { + /* mask for just the access restriction bits */ + acUserAccessMask = (kioACUserNoSeeFolderMask + kioACUserNoSeeFilesMask + kioACUserNoMakeChangesMask), /* common access privilege settings */ + acUserFull = 0x00, /* no access restiction bits on */ + acUserNone = acUserAccessMask, /* all access restiction bits on */ + acUserDropBox = kioACUserNoSeeFolderMask + kioACUserNoSeeFilesMask, /* make changes, but not see files or folders */ + acUserBulletinBoard = kioACUserNoMakeChangesMask /* see files and folders, but not make changes */ +}; + + +/*****************************************************************************/ + +/* +** Deny mode permissions for use with the HOpenAware, HOpenRFAware, +** FSpOpenAware, and FSpOpenRFAware functions. +** Note: Common settings are the ones with comments. +*/ + +enum { + dmNone = 0x0000, + dmNoneDenyRd = fsRdDenyPerm, + dmNoneDenyWr = fsWrDenyPerm, + dmNoneDenyRdWr = (fsRdDenyPerm + fsWrDenyPerm), + dmRd = fsRdPerm, /* Single writer, multiple readers; the readers */ + dmRdDenyRd = (fsRdPerm + fsRdDenyPerm), + dmRdDenyWr = (fsRdPerm + fsWrDenyPerm), /* Browsing - equivalent to fsRdPerm */ + dmRdDenyRdWr = (fsRdPerm + fsRdDenyPerm + fsWrDenyPerm), + dmWr = fsWrPerm, + dmWrDenyRd = (fsWrPerm + fsRdDenyPerm), + dmWrDenyWr = (fsWrPerm + fsWrDenyPerm), + dmWrDenyRdWr = (fsWrPerm + fsRdDenyPerm + fsWrDenyPerm), + dmRdWr = fsRdWrPerm, /* Shared access - equivalent to fsRdWrShPerm */ + dmRdWrDenyRd = (fsRdWrPerm + fsRdDenyPerm), + dmRdWrDenyWr = (fsRdWrPerm + fsWrDenyPerm), /* Single writer, multiple readers; the writer */ + dmRdWrDenyRdWr = (fsRdWrPerm + fsRdDenyPerm + fsWrDenyPerm) /* Exclusive access - equivalent to fsRdWrPerm */ +}; + + +/*****************************************************************************/ + +/* +** For those times where you need to use more than one kind of File Manager parameter +** block but don't feel like wasting stack space, here's a parameter block you can reuse. +*/ + + +union UniversalFMPB { + ParamBlockRec PB; + CInfoPBRec ciPB; + DTPBRec dtPB; + HParamBlockRec hPB; + CMovePBRec cmPB; + WDPBRec wdPB; + FCBPBRec fcbPB; + XVolumeParam xPB; +}; +typedef union UniversalFMPB UniversalFMPB; +typedef UniversalFMPB * UniversalFMPBPtr; +typedef UniversalFMPBPtr * UniversalFMPBHandle; + +/* +** Used by GetUGEntries to return user or group lists +*/ + +struct UGEntry { + short objType; /* object type: -1 = group; 0 = user */ + long objID; /* the user or group ID */ + Str31 name; /* the user or group name */ +}; +typedef struct UGEntry UGEntry; +typedef UGEntry * UGEntryPtr; +typedef UGEntryPtr * UGEntryHandle; + +/* +** I use the following records instead of the AFPVolMountInfo and AFPXVolMountInfo structures in Files.h +*/ +typedef unsigned char Str8[9]; + +struct MyAFPVolMountInfo { + short length; /* length of this record */ + VolumeType media; /* type of media, always AppleShareMediaType */ + short flags; /* 0 = normal mount; set bit 0 to inhibit greeting messages */ + char nbpInterval; /* NBP interval parameter; 7 is a good choice */ + char nbpCount; /* NBP count parameter; 5 is a good choice */ + short uamType; /* User Authentication Method */ + short zoneNameOffset; /* offset from start of record to zoneName */ + short serverNameOffset; /* offset from start of record to serverName */ + short volNameOffset; /* offset from start of record to volName */ + short userNameOffset; /* offset from start of record to userName */ + short userPasswordOffset; /* offset from start of record to userPassword */ + short volPasswordOffset; /* offset from start of record to volPassword */ + Str32 zoneName; /* server's AppleTalk zone name */ + char filler1; /* to word align volPassword */ + Str32 serverName; /* server name */ + char filler2; /* to word align volPassword */ + Str27 volName; /* volume name */ + Str31 userName; /* user name (zero length Pascal string for guest) */ + Str8 userPassword; /* user password (zero length Pascal string if no user password) */ + char filler3; /* to word align volPassword */ + Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */ + char filler4; /* to end record on word boundry */ +}; +typedef struct MyAFPVolMountInfo MyAFPVolMountInfo; +typedef MyAFPVolMountInfo * MyAFPVolMountInfoPtr; +typedef MyAFPVolMountInfoPtr * MyAFPVolMountInfoHandle; + +struct MyAFPXVolMountInfo { + short length; /* length of this record */ + VolumeType media; /* type of media, always AppleShareMediaType */ + short flags; /* bits for no messages, no reconnect, etc */ + char nbpInterval; /* NBP interval parameter; 7 is a good choice */ + char nbpCount; /* NBP count parameter; 5 is a good choice */ + short uamType; /* User Authentication Method */ + short zoneNameOffset; /* offset from start of record to zoneName */ + short serverNameOffset; /* offset from start of record to serverName */ + short volNameOffset; /* offset from start of record to volName */ + short userNameOffset; /* offset from start of record to userName */ + short userPasswordOffset; /* offset from start of record to userPassword */ + short volPasswordOffset; /* offset from start of record to volPassword */ + short extendedFlags; /* extended flags word */ + short uamNameOffset; /* offset to a pascal UAM name string */ + short alternateAddressOffset; /* offset to Alternate Addresses in tagged format */ + Str32 zoneName; /* server's AppleTalk zone name */ + char filler1; /* to word align volPassword */ + Str32 serverName; /* server name */ + char filler2; /* to word align volPassword */ + Str27 volName; /* volume name */ + Str31 userName; /* user name (zero length Pascal string for guest) */ + Str8 userPassword; /* user password (zero length Pascal string if no user password) */ + char filler3; /* to word align volPassword */ + Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */ + char filler4; /* to word align uamNameOffset */ + Str32 uamName; /* UAM name */ + char filler5; /* to word align alternateAddress */ + char alternateAddress[1]; /* AFPAlternateAddress */ +}; +typedef struct MyAFPXVolMountInfo MyAFPXVolMountInfo; +typedef MyAFPXVolMountInfo * MyAFPXVolMountInfoPtr; +typedef MyAFPXVolMountInfoPtr * MyAFPXVolMountInfoHandle; + +/*****************************************************************************/ + +/* Functions to get information out of GetVolParmsInfoBuffer. */ + +/* version 1 field getters */ + +EXTERN_API( short ) +GetVolParmsInfoVersion(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( long ) +GetVolParmsInfoAttrib(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Handle ) +GetVolParmsInfoLocalHand(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( long ) +GetVolParmsInfoServerAdr(const GetVolParmsInfoBuffer * volParms); + + + +/* version 2 field getters (assume zero result if version < 2) */ + +EXTERN_API( long ) +GetVolParmsInfoVolumeGrade(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( long ) +GetVolParmsInfoForeignPrivID(const GetVolParmsInfoBuffer * volParms); + + + +/* version 3 field getters (assume zero result if version < 3) */ + +EXTERN_API( long ) +GetVolParmsInfoExtendedAttributes(const GetVolParmsInfoBuffer * volParms); + + + +/* attribute bits supported by all versions of GetVolParmsInfoBuffer */ + +EXTERN_API( Boolean ) +isNetworkVolume(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasLimitFCBs(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasLocalWList(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasNoMiniFndr(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasNoVNEdit(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasNoLclSync(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasTrshOffLine(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasNoSwitchTo(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasNoDeskItems(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasNoBootBlks(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasAccessCntl(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasNoSysDir(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasExtFSVol(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasOpenDeny(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasCopyFile(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasMoveRename(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasDesktopMgr(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasShortName(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasFolderLock(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasPersonalAccessPrivileges(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasUserGroupList(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasCatSearch(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasFileIDs(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasBTreeMgr(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +hasBlankAccessPrivileges(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +supportsAsyncRequests(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +supportsTrashVolumeCache(const GetVolParmsInfoBuffer * volParms); + + + +/* attribute bits supported by version 3 and greater versions of GetVolParmsInfoBuffer */ + +EXTERN_API( Boolean ) +volIsEjectable(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +volSupportsHFSPlusAPIs(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +volSupportsFSCatalogSearch(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +volSupportsFSExchangeObjects(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +volSupports2TBFiles(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +volSupportsLongNames(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +volSupportsMultiScriptNames(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +volSupportsNamedForks(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +volSupportsSubtreeIterators(const GetVolParmsInfoBuffer * volParms); + + +EXTERN_API( Boolean ) +volL2PCanMapFileBlocks(const GetVolParmsInfoBuffer * volParms); + + + +/*****************************************************************************/ + +/* Functions for testing ioACUser bits. */ + +EXTERN_API( Boolean ) +userIsOwner(SInt8 ioACUser); + + +EXTERN_API( Boolean ) +userHasFullAccess(SInt8 ioACUser); + + +EXTERN_API( Boolean ) +userHasDropBoxAccess(SInt8 ioACUser); + + +EXTERN_API( Boolean ) +userHasBulletinBoard(SInt8 ioACUser); + + +EXTERN_API( Boolean ) +userHasNoAccess(SInt8 ioACUser); + + + +/*****************************************************************************/ + +EXTERN_API( void ) +TruncPString( + StringPtr destination, + ConstStr255Param source, + short maxLength); + + +/* + The TruncPString function copies up to maxLength characters from + the source Pascal string to the destination Pascal string. TruncPString + ensures that the truncated string ends on a single-byte character, or on + the last byte of a multi-byte character. + + destination output: destination Pascal string. + source input: source Pascal string. + maxLength output: The maximum allowable length of the destination + string. +*/ + +/*****************************************************************************/ + +EXTERN_API( Ptr ) +GetTempBuffer( + long buffReqSize, + long * buffActSize); + + +/* + The GetTempBuffer function allocates a temporary buffer for file system + operations which is at least 1024 bytes (1K) and a multiple of + 1024 bytes. + + buffReqSize input: Size you'd like the buffer to be. + buffActSize output: Size of buffer allocated. + function result output: Pointer to memory allocated or nil if no memory + was available. The caller is responsible for + disposing of this buffer with DisposePtr. +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetVolumeInfoNoName( + ConstStr255Param pathname, + short vRefNum, + HParmBlkPtr pb); + + +/* + GetVolumeInfoNoName uses pathname and vRefNum to call PBHGetVInfoSync + in cases where the returned volume name is not needed by the caller. + The pathname and vRefNum parameters are not touched, and the pb + parameter is initialized by PBHGetVInfoSync except that ioNamePtr in + the parameter block is always returned as NULL (since it might point + to GetVolumeInfoNoName's local variable tempPathname). + + I noticed using this code in several places, so here it is once. + This reduces the code size of MoreFiles. + + pathName input: Pointer to a full pathname or nil. If you pass in a + partial pathname, it is ignored. A full pathname to a + volume must end with a colon character (:). + vRefNum input: Volume specification (volume reference number, working + directory number, drive number, or 0). + pb input: A pointer to HParamBlockRec. + output: The parameter block as filled in by PBHGetVInfoSync + except that ioNamePtr will always be NULL. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + paramErr -50 No default volume, or pb was NULL +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +XGetVolumeInfoNoName( + ConstStr255Param pathname, + short vRefNum, + XVolumeParamPtr pb); + + +/* + XGetVolumeInfoNoName uses pathname and vRefNum to call PBXGetVolInfoSync + in cases where the returned volume name is not needed by the caller. + The pathname and vRefNum parameters are not touched, and the pb + parameter is initialized by PBXGetVolInfoSync except that ioNamePtr in + the parameter block is always returned as NULL (since it might point + to XGetVolumeInfoNoName's local variable tempPathname). + + pathName input: Pointer to a full pathname or nil. If you pass in a + partial pathname, it is ignored. A full pathname to a + volume must end with a colon character (:). + vRefNum input: Volume specification (volume reference number, working + directory number, drive number, or 0). + pb input: A pointer to HParamBlockRec. + output: The parameter block as filled in by PBXGetVolInfoSync + except that ioNamePtr will always be NULL. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + paramErr -50 No default volume, or pb was NULL +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetCatInfoNoName( + short vRefNum, + long dirID, + ConstStr255Param name, + CInfoPBPtr pb); + + +/* + GetCatInfoNoName uses vRefNum, dirID and name to call PBGetCatInfoSync + in cases where the returned object is not needed by the caller. + The vRefNum, dirID and name parameters are not touched, and the pb + parameter is initialized by PBGetCatInfoSync except that ioNamePtr in + the parameter block is always returned as NULL (since it might point + to GetCatInfoNoName's local variable tempName). + + I noticed using this code in several places, so here it is once. + This reduces the code size of MoreFiles. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + pb input: A pointer to CInfoPBRec. + output: The parameter block as filled in by + PBGetCatInfoSync except that ioNamePtr will + always be NULL. + + 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 + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DetermineVRefNum( + ConstStr255Param pathname, + short vRefNum, + short * realVRefNum); + + +/* + The DetermineVRefNum function determines the volume reference number of + a volume from a pathname, a volume specification, or a combination + of the two. + WARNING: Volume names on the Macintosh are *not* unique -- Multiple + mounted volumes can have the same name. For this reason, the use of a + volume name or full pathname to identify a specific volume may not + produce the results you expect. If more than one volume has the same + name and a volume name or full pathname is used, the File Manager + currently uses the first volume it finds with a matching name in the + volume queue. + + pathName input: Pointer to a full pathname or nil. If you pass in a + partial pathname, it is ignored. A full pathname to a + volume must end with a colon character (:). + vRefNum input: Volume specification (volume reference number, working + directory number, drive number, or 0). + realVRefNum output: The real volume reference number. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + paramErr -50 No default volume +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HGetVInfo( + short volReference, + StringPtr volName, + short * vRefNum, + unsigned long * freeBytes, + unsigned long * totalBytes); + + +/* + The HGetVInfo function returns the name, volume reference number, + available space (in bytes), and total space (in bytes) for the + specified volume. You can specify the volume by providing its drive + number, volume reference number, or 0 for the default volume. + This routine is compatible with volumes up to 4 gigabytes. + + volReference input: The drive number, volume reference number, + or 0 for the default volume. + volName input: A pointer to a buffer (minimum Str27) where + the volume name is to be returned or must + be nil. + output: The volume name. + vRefNum output: The volume reference number. + freeBytes output: The number of free bytes on the volume. + freeBytes is an unsigned long value. + totalBytes output: The total number of bytes on the volume. + totalBytes is an unsigned long value. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + paramErr -50 No default volume + + __________ + + Also see: XGetVInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +XGetVInfo( + short volReference, + StringPtr volName, + short * vRefNum, + UInt64 * freeBytes, + UInt64 * totalBytes); + + +/* + The XGetVInfo function returns the name, volume reference number, + available space (in bytes), and total space (in bytes) for the + specified volume. You can specify the volume by providing its drive + number, volume reference number, or 0 for the default volume. + This routine is compatible with volumes up to 2 terabytes. + + volReference input: The drive number, volume reference number, + or 0 for the default volume. + volName input: A pointer to a buffer (minimum Str27) where + the volume name is to be returned or must + be nil. + output: The volume name. + vRefNum output: The volume reference number. + freeBytes output: The number of free bytes on the volume. + freeBytes is an UnsignedWide value. + totalBytes output: The total number of bytes on the volume. + totalBytes is an UnsignedWide value. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + paramErr -50 No default volume + + __________ + + Also see: HGetVInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +CheckVolLock( + ConstStr255Param pathname, + short vRefNum); + + +/* + The CheckVolLock function determines if a volume is locked - either by + hardware or by software. If CheckVolLock returns noErr, then the volume + is not locked. + + pathName input: Pointer to a full pathname or nil. If you pass in a + partial pathname, it is ignored. A full pathname to a + volume must end with a colon character (:). + vRefNum input: Volume specification (volume reference number, working + directory number, drive number, or 0). + + Result Codes + noErr 0 No error - volume not locked + nsvErr -35 No such volume + wPrErr -44 Volume locked by hardware + vLckdErr -46 Volume locked by software + paramErr -50 No default volume +*/ + +/*****************************************************************************/ +/* +** The following routines call Mac OS routines that are not supported by +** Carbon: +** +** GetDriverName +** FindDrive +** GetDiskBlocks +** GetVolState +*/ + +#if !TARGET_API_MAC_CARBON // { + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetDriverName( + short driverRefNum, + Str255 driverName); + + +/* + The GetDriverName function returns a device driver's name. + + driverRefNum input: The driver reference number. + driverName output: The driver's name. + + Result Codes + noErr 0 No error + badUnitErr -21 Bad driver reference number +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FindDrive( + ConstStr255Param pathname, + short vRefNum, + DrvQElPtr * driveQElementPtr); + + +/* + The FindDrive function returns a pointer to a mounted volume's + drive queue element. + + pathName input: Pointer to a full pathname or nil. If you + pass in a partial pathname, it is ignored. + A full pathname to a volume must end with + a colon character (:). + vRefNum input: Volume specification (volume reference + number, working directory number, drive + number, or 0). + driveQElementPtr output: Pointer to a volume's drive queue element + in the drive queue. DO NOT change the + DrvQEl. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + paramErr -50 No default volume + nsDrvErr -56 No such drive +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetDiskBlocks( + ConstStr255Param pathname, + short vRefNum, + unsigned long * numBlocks); + + +/* + The GetDiskBlocks function returns the number of physical disk + blocks on a disk drive. NOTE: This is not the same as volume + allocation blocks! + + pathName input: Pointer to a full pathname or nil. If you + pass in a partial pathname, it is ignored. + A full pathname to a volume must end with + a colon character (:). + vRefNum input: Volume specification (volume reference + number, working directory number, drive + number, or 0). + numBlocks output: The number of physical disk blocks on the disk drive. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + paramErr -50 No default volume, driver reference + number is zero, ReturnFormatList + returned zero blocks, DriveStatus + returned an unknown value, or + driveQElementPtr->qType is unknown + nsDrvErr -56 No such drive + statusErr Ð18 Driver does not respond to this + status request + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies + a nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetVolState( + ConstStr255Param pathname, + short vRefNum, + Boolean * volumeOnline, + Boolean * volumeEjected, + Boolean * driveEjectable, + Boolean * driverWantsEject); + + +/* + The GetVolState function determines if a volume is online or offline, + if an offline volume is ejected, and if the volume's driver is + ejectable or wants eject calls. + + pathName input: Pointer to a full pathname or nil. + vRefNum input: Volume specification (volume reference number, + working directory number, drive number, or 0). + volumeOnline output: True if the volume is online; + False if the volume is offline. + volumeEjected output: True if the volume is ejected (ejected + volumes are always offline); False if the + volume is not ejected. + driveEjectable output: True if the volume's drive is ejectable; + False if the volume's drive is not ejectable. + driverWantsEject output: True if the volume's driver wants an Eject + request after unmount (even if the drive + is not ejectable); False if the volume's + driver does not need an eject request. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + paramErr -50 No default volume, or pb was NULL +*/ + +/*****************************************************************************/ + +#endif // } !TARGET_API_MAC_CARBON + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetVolFileSystemID( + ConstStr255Param pathname, + short vRefNum, + short * fileSystemID); + + +/* + The GetVolFileSystemID function returned the file system ID of + a mounted volume. The file system ID identifies the file system + that handles requests to a particular volume. Here's a partial list + of file system ID numbers (only Apple's file systems are listed): + FSID File System + ----- ----------------------------------------------------- + $0000 Macintosh HFS or MFS + $0100 ProDOS File System + $0101 PowerTalk Mail Enclosures + $4147 ISO 9660 File Access (through Foreign File Access) + $4242 High Sierra File Access (through Foreign File Access) + $464D QuickTake File System (through Foreign File Access) + $4953 Macintosh PC Exchange (MS-DOS) + $4A48 Audio CD Access (through Foreign File Access) + $4D4B Apple Photo Access (through Foreign File Access) + + See the Technical Note "FL 35 - Determining Which File System + Is Active" and the "Guide to the File System Manager" for more + information. + + pathName input: Pointer to a full pathname or nil. If you pass + in a partial pathname, it is ignored. A full + pathname to a volume must contain at least + one colon character (:) and must not start with + a colon character. + vRefNum input: Volume specification (volume reference number, + working directory number, drive number, or 0). + fileSystemID output: The volume's file system ID. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + paramErr -50 No default volume, or pb was NULL +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +UnmountAndEject( + ConstStr255Param pathname, + short vRefNum); + + +/* + The UnmountAndEject function unmounts and ejects a volume. The volume + is ejected only if it is ejectable and not already ejected. + + pathName input: Pointer to a full pathname or nil. If you pass in a + partial pathname, it is ignored. A full pathname to a + volume must end with a colon character (:). + vRefNum input: Volume specification (volume reference number, working + directory number, drive number, or 0). + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad volume name + fBsyErr -47 One or more files are open + paramErr -50 No default volume + nsDrvErr -56 No such drive + extFSErr -58 External file system error - no file + system claimed this call. +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +OnLine( + FSSpecPtr volumes, + short reqVolCount, + short * actVolCount, + short * volIndex); + + +/* + The OnLine function returns the list of volumes currently mounted in + an array of FSSpec records. + + A noErr result indicates that the volumes array was filled + (actVolCount == reqVolCount) and there may be additional volumes + mounted. A nsvErr result indicates that the end of the volume list + was found and actVolCount volumes were actually found this time. + + volumes input: Pointer to array of FSSpec where the volume list + is returned. + reqVolCount input: Maximum number of volumes to return (the number of + elements in the volumes array). + actVolCount output: The number of volumes actually returned. + volIndex input: The current volume index position. Set to 1 to + start with the first volume. + output: The volume index position to get the next volume. + Pass this value the next time you call OnLine to + start where you left off. + + Result Codes + noErr 0 No error, but there are more volumes + to list + nsvErr -35 No more volumes to be listed + paramErr -50 volIndex was <= 0 +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +SetDefault( + short newVRefNum, + long newDirID, + short * oldVRefNum, + long * oldDirID); + + +/* + The SetDefault function sets the default volume and directory to the + volume specified by newVRefNum and the directory specified by newDirID. + The current default volume reference number and directory ID are + returned in oldVRefNum and oldDir and must be used to restore the + default volume and directory to their previous state *as soon as + possible* with the RestoreDefault function. These two functions are + designed to be used as a wrapper around Standard I/O routines where + the location of the file is implied to be the default volume and + directory. In other words, this is how you should use these functions: + + error = SetDefault(newVRefNum, newDirID, &oldVRefNum, &oldDirID); + if ( error == noErr ) + { + // call the Stdio functions like remove, rename, tmpfile, + // fopen, freopen, etc. or non-ANSI extensions like + // fdopen,fsetfileinfo, -- create, open, unlink, etc. here! + + error = RestoreDefault(oldVRefNum, oldDirID); + } + + By using these functions as a wrapper, you won't need to open a working + directory (because SetDefault and RestoreDefault use HSetVol) and you + won't have to worry about the effects of using HSetVol (documented in + Technical Note "FL 11 - PBHSetVol is Dangerous" and in the + Inside Macintosh: Files book in the description of the HSetVol and + PBHSetVol functions) because the default volume/directory is restored + before giving up control to code that might be affected by HSetVol. + + newVRefNum input: Volume specification (volume reference number, + working directory number, drive number, or 0) of + the new default volume. + newDirID input: Directory ID of the new default directory. + oldVRefNum output: The volume specification to save for use with + RestoreDefault. + oldDirID output: The directory ID to save for use with + RestoreDefault. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + bdNamErr -37 Bad volume name + fnfErr -43 Directory not found + paramErr -50 No default volume + afpAccessDenied -5000 User does not have access to the directory + + __________ + + Also see: RestoreDefault +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +RestoreDefault( + short oldVRefNum, + long oldDirID); + + +/* + The RestoreDefault function restores the default volume and directory + to the volume specified by oldVRefNum and the directory specified by + oldDirID. The oldVRefNum and oldDirID parameters were previously + obtained from the SetDefault function. These two functions are designed + to be used as a wrapper around Standard C I/O routines where the + location of the file is implied to be the default volume and directory. + In other words, this is how you should use these functions: + + error = SetDefault(newVRefNum, newDirID, &oldVRefNum, &oldDirID); + if ( error == noErr ) + { + // call the Stdio functions like remove, rename, tmpfile, + // fopen, freopen, etc. or non-ANSI extensions like + // fdopen,fsetfileinfo, -- create, open, unlink, etc. here! + + error = RestoreDefault(oldVRefNum, oldDirID); + } + + By using these functions as a wrapper, you won't need to open a working + directory (because SetDefault and RestoreDefault use HSetVol) and you + won't have to worry about the effects of using HSetVol (documented in + Technical Note "FL 11 - PBHSetVol is Dangerous" and in the + Inside Macintosh: Files book in the description of the HSetVol and + PBHSetVol functions) because the default volume/directory is restored + before giving up control to code that might be affected by HSetVol. + + oldVRefNum input: The volume specification to restore. + oldDirID input: The directory ID to restore. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + bdNamErr -37 Bad volume name + fnfErr -43 Directory not found + paramErr -50 No default volume + rfNumErr -51 Bad working directory reference number + afpAccessDenied -5000 User does not have access to the directory + + __________ + + Also see: SetDefault +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetDInfo( + short vRefNum, + long dirID, + ConstStr255Param name, + DInfo * fndrInfo); + + +/* + The GetDInfo function gets the finder information for a directory. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + fndrInfo output: If the object is a directory, then its DInfo. + + 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 + dirNFErr -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, FSpGetFInfoCompat +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpGetDInfo( + const FSSpec * spec, + DInfo * fndrInfo); + + +/* + The FSpGetDInfo function gets the finder information for a directory. + + spec input: An FSSpec record specifying the directory. + fndrInfo output: If the object is a directory, then its DInfo. + + 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 + dirNFErr -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: FSpGetFInfoCompat, GetDInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +SetDInfo( + short vRefNum, + long dirID, + ConstStr255Param name, + const DInfo * fndrInfo); + + +/* + The SetDInfo function sets the finder information for a directory. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + fndrInfo input: The DInfo. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -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: FSpSetDInfo, FSpSetFInfoCompat +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpSetDInfo( + const FSSpec * spec, + const DInfo * fndrInfo); + + +/* + The FSpSetDInfo function sets the finder information for a directory. + + spec input: An FSSpec record specifying the directory. + fndrInfo input: The DInfo. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -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: FSpSetFInfoCompat, SetDInfo +*/ + +/*****************************************************************************/ + +#if OLDROUTINENAMES + #define GetDirID(vRefNum, dirID, name, theDirID, isDirectory) GetDirectoryID(vRefNum, dirID, name, theDirID, isDirectory) +#endif +EXTERN_API( OSErr ) +GetDirectoryID( + short vRefNum, + long dirID, + ConstStr255Param name, + long * theDirID, + Boolean * isDirectory); + + +/* + The GetDirectoryID function gets the directory ID number of the + directory specified. If a file is specified, then the parent + directory of the file is returned and isDirectory is false. If + a directory is specified, then that directory's ID number is + returned and isDirectory is true. + WARNING: Volume names on the Macintosh are *not* unique -- Multiple + mounted volumes can have the same name. For this reason, the use of a + volume name or full pathname to identify a specific volume may not + produce the results you expect. If more than one volume has the same + name and a volume name or full pathname is used, the File Manager + currently uses the first volume it finds with a matching name in the + volume queue. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + theDirID output: If the object is a file, then its parent directory + ID. If the object is a directory, then its ID. + isDirectory output: True if object is a directory; false if + object is a file. + + 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 + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname +*/ + +/*****************************************************************************/ + +#if OLDROUTINENAMES + #define DirIDFromFSSpec(spec, theDirID, isDirectory) FSpGetDirectoryID(spec, theDirID, isDirectory) +#endif +EXTERN_API( OSErr ) +FSpGetDirectoryID( + const FSSpec * spec, + long * theDirID, + Boolean * isDirectory); + + +/* + The FSpGetDirectoryID function gets the directory ID number of the + directory specified by spec. If spec is to a file, then the parent + directory of the file is returned and isDirectory is false. If + spec is to a directory, then that directory's ID number is + returned and isDirectory is true. + + spec input: An FSSpec record specifying the directory. + theDirID output: The directory ID. + isDirectory output: True if object is a directory; false if + object is a file. + + 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 + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetDirName( + short vRefNum, + long dirID, + Str31 name); + + +/* + The GetDirName function gets the name of a directory from its + directory ID. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name output: Points to a Str31 where the directory name is to be + returned. + + 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 or + name parameter was NULL + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetIOACUser( + short vRefNum, + long dirID, + ConstStr255Param name, + SInt8 * ioACUser); + + +/* + GetIOACUser returns a directory's access restrictions byte. + Use the masks and macro defined in MoreFilesExtras to check for + specific access priviledges. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + ioACUser output: The access restriction byte + + 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 + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpGetIOACUser( + const FSSpec * spec, + SInt8 * ioACUser); + + +/* + FSpGetIOACUser returns a directory's access restrictions byte. + Use the masks and macro defined in MoreFilesExtras to check for + specific access priviledges. + + spec input: An FSSpec record specifying the directory. + ioACUser output: The access restriction byte + + 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 + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetParentID( + short vRefNum, + long dirID, + ConstStr255Param name, + long * parID); + + +/* + The GetParentID function gets the parent directory ID number of the + specified object. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + parID output: The parent directory ID of the specified object. + + 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 + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetFilenameFromPathname( + ConstStr255Param pathname, + Str255 filename); + + +/* + The GetFilenameFromPathname function gets the file (or directory) name + from the end of a full or partial pathname. Returns notAFileErr if the + pathname is nil, the pathname is empty, or the pathname cannot refer to + a filename (with a noErr result, the pathname could still refer to a + directory). + + pathname input: A full or partial pathname. + filename output: The file (or directory) name. + + Result Codes + noErr 0 No error + notAFileErr -1302 The pathname is nil, the pathname + is empty, or the pathname cannot refer + to a filename + + __________ + + See also: GetObjectLocation. +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetObjectLocation( + short vRefNum, + long dirID, + ConstStr255Param pathname, + short * realVRefNum, + long * realParID, + Str255 realName, + Boolean * isDirectory); + + +/* + The GetObjectLocation function gets a file system object's location - + that is, its real volume reference number, real parent directory ID, + and name. While we're at it, determine if the object is a file or directory. + If GetObjectLocation returns fnfErr, then the location information + returned is valid, but it describes an object that doesn't exist. + You can use the location information for another operation, such as + creating a file or directory. + + vRefNum input: Volume specification. + dirID input: Directory ID. + pathname input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + realVRefNum output: The real volume reference number. + realParID output: The parent directory ID of the specified object. + realName output: The name of the specified object (the case of the + object name may not be the same as the object's + catalog entry on disk - since the Macintosh file + system is not case sensitive, it shouldn't matter). + isDirectory output: True if object is a directory; false if object + is a file. + + 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 + dirNFErr -120 Directory not found or incomplete pathname + notAFileErr -1302 The pathname is nil, the pathname + is empty, or the pathname cannot refer + to a filename + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSMakeFSSpecCompat +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetDirItems( + short vRefNum, + long dirID, + ConstStr255Param name, + Boolean getFiles, + Boolean getDirectories, + FSSpecPtr items, + short reqItemCount, + short * actItemCount, + short * itemIndex); + + +/* + The GetDirItems function returns a list of items in the specified + directory in an array of FSSpec records. File, subdirectories, or + both can be returned in the list. + + A noErr result indicates that the items array was filled + (actItemCount == reqItemCount) and there may be additional items + left in the directory. A fnfErr result indicates that the end of + the directory list was found and actItemCount items were actually + found this time. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID + specifies a directory that's the object. + getFiles input: Pass true to have files added to the items list. + getDirectories input: Pass true to have directories added to the + items list. + items input: Pointer to array of FSSpec where the item list + is returned. + reqItemCount input: Maximum number of items to return (the number + of elements in the items array). + actItemCount output: The number of items actually returned. + itemIndex input: The current item index position. Set to 1 to + start with the first item in the directory. + output: The item index position to get the next item. + Pass this value the next time you call + GetDirItems to start where you left off. + + Result Codes + noErr 0 No error, but there are more items + to list + nsvErr -35 No such volume + ioErr -36 I/O error + bdNamErr -37 Bad filename + fnfErr -43 File not found, there are no more items + to be listed. + paramErr -50 No default volume or itemIndex was <= 0 + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DeleteDirectoryContents( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The DeleteDirectoryContents function deletes the contents of a directory. + All files and subdirectories in the specified directory are deleted. + If a locked file or directory is encountered, it is unlocked and then + deleted. If any unexpected errors are encountered, + DeleteDirectoryContents quits and returns to the caller. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to directory name, or nil when dirID specifies + a directory that's the object. + + 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 + paramErr -50 No default volume + dirNFErr -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: DeleteDirectory +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +DeleteDirectory( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The DeleteDirectory function deletes a directory and its contents. + All files and subdirectories in the specified directory are deleted. + If a locked file or directory is encountered, it is unlocked and then + deleted. After deleting the directories contents, the directory is + deleted. If any unexpected errors are encountered, DeleteDirectory + quits and returns to the caller. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to directory name, or nil when dirID specifies + a directory that's the object. + + 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 + paramErr -50 No default volume + dirNFErr -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: DeleteDirectoryContents +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +CheckObjectLock( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The CheckObjectLock function determines if a file or directory is locked. + If CheckObjectLock returns noErr, then the file or directory + is not locked. If CheckObjectLock returns fLckdErr, the it is locked. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + paramErr -50 No default volume + dirNFErr -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: FSpCheckObjectLock +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpCheckObjectLock(const FSSpec * spec); + + +/* + The FSpCheckObjectLock function determines if a file or directory is locked. + If FSpCheckObjectLock returns noErr, then the file or directory + is not locked. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + paramErr -50 No default volume + dirNFErr -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: CheckObjectLock +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetFileSize( + short vRefNum, + long dirID, + ConstStr255Param fileName, + long * dataSize, + long * rsrcSize); + + +/* + The GetFileSize function returns the logical size of a file's + data and resource fork. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: The name of the file. + dataSize output: The number of bytes in the file's data fork. + rsrcSize output: The number of bytes in 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 + 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 + + __________ + + See also: FSpGetFileSize +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpGetFileSize( + const FSSpec * spec, + long * dataSize, + long * rsrcSize); + + +/* + The FSpGetFileSize function returns the logical size of a file's + data and resource fork. + + spec input: An FSSpec record specifying the file. + dataSize output: The number of bytes in the file's data fork. + rsrcSize output: The number of bytes in 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 + 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 + + __________ + + See also: GetFileSize +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +BumpDate( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The BumpDate function changes the modification date of a file or + directory to the current date/time. If the modification date is already + equal to the current date/time, then add one second to the + modification date. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpBumpDate +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpBumpDate(const FSSpec * spec); + + +/* + The FSpBumpDate function changes the modification date of a file or + directory to the current date/time. If the modification date is already + equal to the current date/time, then add one second to the + modification date. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: BumpDate +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +ChangeCreatorType( + short vRefNum, + long dirID, + ConstStr255Param name, + OSType creator, + OSType fileType); + + +/* + The ChangeCreatorType function changes the creator or file type of a file. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: The name of the file. + creator input: The new creator type or 0x00000000 to leave + the creator type alone. + fileType input: The new file type or 0x00000000 to leave the + file type alone. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + notAFileErr -1302 Name was not a file + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpChangeCreatorType +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpChangeCreatorType( + const FSSpec * spec, + OSType creator, + OSType fileType); + + +/* + The FSpChangeCreatorType function changes the creator or file type of a file. + + spec input: An FSSpec record specifying the file. + creator input: The new creator type or 0x00000000 to leave + the creator type alone. + fileType input: The new file type or 0x00000000 to leave the + file type alone. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + notAFileErr -1302 Name was not a file + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: ChangeCreatorType +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +ChangeFDFlags( + short vRefNum, + long dirID, + ConstStr255Param name, + Boolean setBits, + unsigned short flagBits); + + +/* + The ChangeFDFlags function sets or clears Finder Flag bits in the + fdFlags field of a file or directory's FInfo record. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + setBits input: If true, then set the bits specified in flagBits. + If false, then clear the bits specified in flagBits. + flagBits input: The flagBits parameter specifies which Finder Flag + bits to set or clear. If a bit in flagBits is set, + then the same bit in fdFlags is either set or + cleared depending on the state of the setBits + parameter. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpChangeFDFlags +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpChangeFDFlags( + const FSSpec * spec, + Boolean setBits, + unsigned short flagBits); + + +/* + The FSpChangeFDFlags function sets or clears Finder Flag bits in the + fdFlags field of a file or directory's FInfo record. + + spec input: An FSSpec record specifying the object. + setBits input: If true, then set the bits specified in flagBits. + If false, then clear the bits specified in flagBits. + flagBits input: The flagBits parameter specifies which Finder Flag + bits to set or clear. If a bit in flagBits is set, + then the same bit in fdFlags is either set or + cleared depending on the state of the setBits + parameter. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: ChangeFDFlags +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +SetIsInvisible( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The SetIsInvisible function sets the invisible bit in the fdFlags + word of the specified file or directory's finder information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpSetIsInvisible, ClearIsInvisible, FSpClearIsInvisible +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpSetIsInvisible(const FSSpec * spec); + + +/* + The FSpSetIsInvisible function sets the invisible bit in the fdFlags + word of the specified file or directory's finder information. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetIsInvisible, ClearIsInvisible, FSpClearIsInvisible +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +ClearIsInvisible( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The ClearIsInvisible function clears the invisible bit in the fdFlags + word of the specified file or directory's finder information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetIsInvisible, FSpSetIsInvisible, FSpClearIsInvisible +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpClearIsInvisible(const FSSpec * spec); + + +/* + The FSpClearIsInvisible function clears the invisible bit in the fdFlags + word of the specified file or directory's finder information. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetIsInvisible, FSpSetIsInvisible, ClearIsInvisible +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +SetNameLocked( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The SetNameLocked function sets the nameLocked bit in the fdFlags word + of the specified file or directory's finder information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpSetNameLocked, ClearNameLocked, FSpClearNameLocked +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpSetNameLocked(const FSSpec * spec); + + +/* + The FSpSetNameLocked function sets the nameLocked bit in the fdFlags word + of the specified file or directory's finder information. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetNameLocked, ClearNameLocked, FSpClearNameLocked +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +ClearNameLocked( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The ClearNameLocked function clears the nameLocked bit in the fdFlags + word of the specified file or directory's finder information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetNameLocked, FSpSetNameLocked, FSpClearNameLocked +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpClearNameLocked(const FSSpec * spec); + + +/* + The FSpClearNameLocked function clears the nameLocked bit in the fdFlags + word of the specified file or directory's finder information. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetNameLocked, FSpSetNameLocked, ClearNameLocked +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +SetIsStationery( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The SetIsStationery function sets the isStationery bit in the + fdFlags word of the specified file or directory's finder information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpSetIsStationery, ClearIsStationery, FSpClearIsStationery +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpSetIsStationery(const FSSpec * spec); + + +/* + The FSpSetIsStationery function sets the isStationery bit in the + fdFlags word of the specified file or directory's finder information. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetIsStationery, ClearIsStationery, FSpClearIsStationery +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +ClearIsStationery( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The ClearIsStationery function clears the isStationery bit in the + fdFlags word of the specified file or directory's finder information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetIsStationery, FSpSetIsStationery, FSpClearIsStationery +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpClearIsStationery(const FSSpec * spec); + + +/* + The FSpClearIsStationery function clears the isStationery bit in the + fdFlags word of the specified file or directory's finder information. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetIsStationery, FSpSetIsStationery, ClearIsStationery +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +SetHasCustomIcon( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The SetHasCustomIcon function sets the hasCustomIcon bit in the + fdFlags word of the specified file or directory's finder information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpSetHasCustomIcon, ClearHasCustomIcon, FSpClearHasCustomIcon +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpSetHasCustomIcon(const FSSpec * spec); + + +/* + The FSpSetHasCustomIcon function sets the hasCustomIcon bit in the + fdFlags word of the specified file or directory's finder information. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetHasCustomIcon, ClearHasCustomIcon, FSpClearHasCustomIcon +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +ClearHasCustomIcon( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The ClearHasCustomIcon function clears the hasCustomIcon bit in the + fdFlags word of the specified file or directory's finder information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetHasCustomIcon, FSpSetHasCustomIcon, FSpClearHasCustomIcon +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpClearHasCustomIcon(const FSSpec * spec); + + +/* + The FSpClearHasCustomIcon function clears the hasCustomIcon bit in the + fdFlags word of the specified file or directory's finder information. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: SetHasCustomIcon, FSpSetHasCustomIcon, ClearHasCustomIcon +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +ClearHasBeenInited( + short vRefNum, + long dirID, + ConstStr255Param name); + + +/* + The ClearHasBeenInited function clears the hasBeenInited bit in the + fdFlags word of the specified file or directory's finder information. + + vRefNum input: Volume specification. + dirID input: Directory ID. + name input: Pointer to object name, or nil when dirID specifies + a directory that's the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpClearHasBeenInited +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpClearHasBeenInited(const FSSpec * spec); + + +/* + The FSpClearHasBeenInited function clears the hasBeenInited bit in the + fdFlags word of the specified file or directory's finder information. + + spec input: An FSSpec record specifying the object. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: ClearHasBeenInited +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +CopyFileMgrAttributes( + short srcVRefNum, + long srcDirID, + ConstStr255Param srcName, + short dstVRefNum, + long dstDirID, + ConstStr255Param dstName, + Boolean copyLockBit); + + +/* + The CopyFileMgrAttributes function copies all File Manager attributes + from the source file or directory to the destination file or directory. + If copyLockBit is true, then set the locked state of the destination + to match the source. + + srcVRefNum input: Source volume specification. + srcDirID input: Source directory ID. + srcName input: Pointer to source object name, or nil when + srcDirID specifies a directory that's the object. + dstVRefNum input: Destination volume specification. + dstDirID input: Destination directory ID. + dstName input: Pointer to destination object name, or nil when + dstDirID specifies a directory that's the object. + copyLockBit input: If true, set the locked state of the destination + to match the source. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: FSpCopyFileMgrAttributes +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpCopyFileMgrAttributes( + const FSSpec * srcSpec, + const FSSpec * dstSpec, + Boolean copyLockBit); + + +/* + The FSpCopyFileMgrAttributes function copies all File Manager attributes + from the source file or directory to the destination file or directory. + If copyLockBit is true, then set the locked state of the destination + to match the source. + + srcSpec input: An FSSpec record specifying the source object. + dstSpec input: An FSSpec record specifying the destination object. + copyLockBit input: If true, set the locked state of the destination + to match the source. + + 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 + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + paramErr -50 No default volume + dirNFErr -120 Directory not found or incomplete pathname + afpAccessDenied -5000 User does not have the correct access + afpObjectTypeErr -5025 Directory not found or incomplete pathname + + __________ + + See also: CopyFileMgrAttributes +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HOpenAware( + short vRefNum, + long dirID, + ConstStr255Param fileName, + short denyModes, + short * refNum); + + +/* + The HOpenAware function opens the data fork of a file using deny mode + permissions instead the normal File Manager permissions. If OpenDeny + is not available, then HOpenAware translates the deny modes to the + closest File Manager permissions and tries to open the file with + OpenDF first, and then Open if OpenDF isn't available. By using + HOpenAware with deny mode permissions, a program can be "AppleShare + aware" and fall back on the standard File Manager open calls + automatically. + + vRefNum input: Volume specification. + dirID input: Directory ID. + fileName input: The name of the file. + denyModes input: The deny modes access under which to open the file. + refNum output: The file reference number of the opened file. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + tmfoErr -42 Too many files open + fnfErr -43 File not found + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + opWrErr -49 File already open for writing + paramErr -50 No default volume + permErr -54 File is already open and cannot be opened using specified deny modes + afpAccessDenied -5000 User does not have the correct access to the file + afpDenyConflict -5006 Requested access permission not possible + + __________ + + See also: FSpOpenAware, HOpenRFAware, FSpOpenRFAware +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpOpenAware( + const FSSpec * spec, + short denyModes, + short * refNum); + + +/* + The FSpOpenAware function opens the data fork of a file using deny mode + permissions instead the normal File Manager permissions. If OpenDeny + is not available, then FSpOpenAware translates the deny modes to the + closest File Manager permissions and tries to open the file with + OpenDF first, and then Open if OpenDF isn't available. By using + FSpOpenAware with deny mode permissions, a program can be "AppleShare + aware" and fall back on the standard File Manager open calls + automatically. + + spec input: An FSSpec record specifying the file. + denyModes input: The deny modes access under which to open the file. + refNum output: The file reference number of the opened file. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + tmfoErr -42 Too many files open + fnfErr -43 File not found + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + opWrErr -49 File already open for writing + paramErr -50 No default volume + permErr -54 File is already open and cannot be opened using specified deny modes + afpAccessDenied -5000 User does not have the correct access to the file + afpDenyConflict -5006 Requested access permission not possible + + __________ + + See also: HOpenAware, HOpenRFAware, FSpOpenRFAware +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HOpenRFAware( + short vRefNum, + long dirID, + ConstStr255Param fileName, + short denyModes, + short * refNum); + + +/* + The HOpenRFAware function opens the resource fork of a file using deny + mode permissions instead the normal File Manager permissions. If + OpenRFDeny is not available, then HOpenRFAware translates the deny + modes to the closest File Manager permissions and tries to open the + file with OpenRF. By using HOpenRFAware with deny mode permissions, + a program can be "AppleShare aware" and fall back on the standard + File Manager open calls automatically. + + vRefNum input: Volume specification. + dirID input: Directory ID. + fileName input: The name of the file. + denyModes input: The deny modes access under which to open the file. + refNum output: The file reference number of the opened file. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + tmfoErr -42 Too many files open + fnfErr -43 File not found + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + opWrErr -49 File already open for writing + paramErr -50 No default volume + permErr -54 File is already open and cannot be opened using specified deny modes + afpAccessDenied -5000 User does not have the correct access to the file + afpDenyConflict -5006 Requested access permission not possible + + __________ + + See also: HOpenAware, FSpOpenAware, FSpOpenRFAware +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpOpenRFAware( + const FSSpec * spec, + short denyModes, + short * refNum); + + +/* + The FSpOpenRFAware function opens the resource fork of a file using deny + mode permissions instead the normal File Manager permissions. If + OpenRFDeny is not available, then FSpOpenRFAware translates the deny + modes to the closest File Manager permissions and tries to open the + file with OpenRF. By using FSpOpenRFAware with deny mode permissions, + a program can be "AppleShare aware" and fall back on the standard + File Manager open calls automatically. + + spec input: An FSSpec record specifying the file. + denyModes input: The deny modes access under which to open the file. + refNum output: The file reference number of the opened file. + + Result Codes + noErr 0 No error + nsvErr -35 No such volume + tmfoErr -42 Too many files open + fnfErr -43 File not found + wPrErr -44 Volume locked by hardware + fLckdErr -45 File is locked + vLckdErr -46 Volume is locked or read-only + opWrErr -49 File already open for writing + paramErr -50 No default volume + permErr -54 File is already open and cannot be opened using specified deny modes + afpAccessDenied -5000 User does not have the correct access to the file + afpDenyConflict -5006 Requested access permission not possible + + __________ + + See also: HOpenAware, FSpOpenAware, HOpenRFAware +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSReadNoCache( + short refNum, + long * count, + void * buffPtr); + + +/* + The FSReadNoCache function reads any number of bytes from an open file + while asking the file system to bypass its cache mechanism. + + refNum input: The file reference number of an open file. + count input: The number of bytes to read. + output: The number of bytes actually read. + buffPtr input: A pointer to the data buffer into which the bytes are + to be read. + + Result Codes + noErr 0 No error + readErr Ð19 Driver does not respond to read requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + ioErr Ð36 Data does not match in read-verify mode + fnOpnErr -38 File not open + rfNumErr -51 Bad reference number + afpAccessDenied -5000 User does not have the correct access to + the file + + __________ + + See also: FSWriteNoCache +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSWriteNoCache( + short refNum, + long * count, + const void * buffPtr); + + +/* + The FSReadNoCache function writes any number of bytes to an open file + while asking the file system to bypass its cache mechanism. + + refNum input: The file reference number of an open file. + count input: The number of bytes to write to the file. + output: The number of bytes actually written. + buffPtr input: A pointer to the data buffer from which the bytes are + to be written. + + Result Codes + noErr 0 No error + writErr Ð20 Driver does not respond to write requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + dskFulErr -34 Disk full + ioErr Ð36 Data does not match in read-verify mode + fnOpnErr -38 File not open + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock + rfNumErr -51 Bad reference number + wrPermErr -61 Read/write permission doesnÕt + allow writing + afpAccessDenied -5000 User does not have the correct access to + the file + + __________ + + See also: FSReadNoCache +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSWriteVerify( + short refNum, + long * count, + const void * buffPtr); + + +/* + The FSWriteVerify function writes any number of bytes to an open file + and then verifies that the data was actually written to the device. + + refNum input: The file reference number of an open file. + count input: The number of bytes to write to the file. + output: The number of bytes actually written and verified. + buffPtr input: A pointer to the data buffer from which the bytes are + to be written. + + Result Codes + noErr 0 No error + readErr Ð19 Driver does not respond to read requests + writErr Ð20 Driver does not respond to write requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + dskFulErr -34 Disk full + ioErr Ð36 Data does not match in read-verify mode + fnOpnErr -38 File not open + eofErr -39 Logical end-of-file reached + posErr -40 Attempt to position mark before start + of file + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock + rfNumErr -51 Bad reference number + gfpErr -52 Error during GetFPos + wrPermErr -61 Read/write permission doesnÕt + allow writing + memFullErr -108 Not enough room in heap zone to allocate + verify buffer + afpAccessDenied -5000 User does not have the correct access to + the file +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +CopyFork( + short srcRefNum, + short dstRefNum, + void * copyBufferPtr, + long copyBufferSize); + + +/* + The CopyFork function copies all data from the source fork to the + destination fork of open file forks and makes sure the destination EOF + is equal to the source EOF. + + srcRefNum input: The source file reference number. + dstRefNum input: The destination file reference number. + copyBufferPtr input: Pointer to buffer to use during copy. The + buffer should be at least 512-bytes minimum. + The larger the buffer, the faster the copy. + copyBufferSize input: The size of the copy buffer. + + Result Codes + noErr 0 No error + readErr Ð19 Driver does not respond to read requests + writErr Ð20 Driver does not respond to write requests + badUnitErr Ð21 Driver reference number does not + match unit table + unitEmptyErr Ð22 Driver reference number specifies a + nil handle in unit table + abortErr Ð27 Request aborted by KillIO + notOpenErr Ð28 Driver not open + dskFulErr -34 Disk full + ioErr Ð36 Data does not match in read-verify mode + fnOpnErr -38 File not open + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Software volume lock + rfNumErr -51 Bad reference number + wrPermErr -61 Read/write permission doesnÕt + allow writing + afpAccessDenied -5000 User does not have the correct access to + the file +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetFileLocation( + short refNum, + short * vRefNum, + long * dirID, + StringPtr fileName); + + +/* + The GetFileLocation function gets the location (volume reference number, + directory ID, and fileName) of an open file. + + refNum input: The file reference number of an open file. + vRefNum output: The volume reference number. + dirID output: The parent directory ID. + fileName input: Points to a buffer (minimum Str63) where the + filename is to be returned or must be nil. + output: The filename. + + Result Codes + noErr 0 No error + nsvErr -35 Specified volume doesnÕt exist + fnOpnErr -38 File not open + rfNumErr -51 Reference number specifies nonexistent + access path + + __________ + + See also: FSpGetFileLocation +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpGetFileLocation( + short refNum, + FSSpec * spec); + + +/* + The FSpGetFileLocation function gets the location of an open file in + an FSSpec record. + + refNum input: The file reference number of an open file. + spec output: FSSpec record containing the file name and location. + + Result Codes + noErr 0 No error + nsvErr -35 Specified volume doesnÕt exist + fnOpnErr -38 File not open + rfNumErr -51 Reference number specifies nonexistent + access path + + __________ + + See also: GetFileLocation +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +CopyDirectoryAccess( + short srcVRefNum, + long srcDirID, + ConstStr255Param srcName, + short dstVRefNum, + long dstDirID, + ConstStr255Param dstName); + + +/* + The CopyDirectoryAccess function copies the AFP directory access + privileges from one directory to another. Both directories must be on + the same file server, but not necessarily on the same server volume. + + srcVRefNum input: Source volume specification. + srcDirID input: Source directory ID. + srcName input: Pointer to source directory name, or nil when + srcDirID specifies the directory. + dstVRefNum input: Destination volume specification. + dstDirID input: Destination directory ID. + dstName input: Pointer to destination directory name, or nil when + dstDirID specifies the directory. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + fnfErr -43 Directory not found + vLckdErr -46 Volume is locked or read-only + paramErr -50 Volume doesn't support this function + afpAccessDenied -5000 User does not have the correct access + to the directory + afpObjectTypeErr -5025 Object is a file, not a directory + + __________ + + See also: FSpCopyDirectoryAccess +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpCopyDirectoryAccess( + const FSSpec * srcSpec, + const FSSpec * dstSpec); + + +/* + The FSpCopyDirectoryAccess function copies the AFP directory access + privileges from one directory to another. Both directories must be on + the same file server, but not necessarily on the same server volume. + + srcSpec input: An FSSpec record specifying the source directory. + dstSpec input: An FSSpec record specifying the destination directory. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + fnfErr -43 Directory not found + vLckdErr -46 Volume is locked or read-only + paramErr -50 Volume doesn't support this function + afpAccessDenied -5000 User does not have the correct access + to the directory + afpObjectTypeErr -5025 Object is a file, not a directory + + __________ + + See also: CopyDirectoryAccess +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +HMoveRenameCompat( + short vRefNum, + long srcDirID, + ConstStr255Param srcName, + long dstDirID, + ConstStr255Param dstpathName, + ConstStr255Param copyName); + + +/* + The HMoveRenameCompat function moves a file or directory and optionally + renames it. The source and destination locations must be on the same + volume. This routine works even if the volume doesn't support MoveRename. + + vRefNum input: Volume specification. + srcDirID input: Source directory ID. + srcName input: The source object name. + dstDirID input: Destination directory ID. + dstName input: Pointer to destination directory name, or + nil when dstDirID specifies a directory. + copyName input: Points to the new name if the object is to be + renamed or nil if the object isn't to be renamed. + + Result Codes + noErr 0 No error + dirFulErr -33 File directory full + dskFulErr -34 Disk is full + nsvErr -35 Volume not found + ioErr -36 I/O error + bdNamErr -37 Bad filename or attempt to move into + a file + fnfErr -43 Source file or directory not found + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + fBsyErr -47 File busy, directory not empty, or + working directory control block open + dupFNErr -48 Destination already exists + paramErr -50 Volume doesn't support this function, + no default volume, or source and + volOfflinErr -53 Volume is offline + fsRnErr -59 Problem during rename + dirNFErr -120 Directory not found or incomplete pathname + badMovErr -122 Attempted to move directory into + offspring + wrgVolTypErr -123 Not an HFS volume (it's a MFS volume) + notAFileErr -1302 The pathname is nil, the pathname + is empty, or the pathname cannot refer + to a filename + diffVolErr -1303 Files on different volumes + afpAccessDenied -5000 The user does not have the right to + move the file or directory + afpObjectTypeErr -5025 Directory not found or incomplete pathname + afpSameObjectErr -5038 Source and destination files are the same + + __________ + + See also: FSpMoveRenameCompat +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +FSpMoveRenameCompat( + const FSSpec * srcSpec, + const FSSpec * dstSpec, + ConstStr255Param copyName); + + +/* + The FSpMoveRenameCompat function moves a file or directory and optionally + renames it. The source and destination locations must be on the same + volume. This routine works even if the volume doesn't support MoveRename. + + srcSpec input: An FSSpec record specifying the source object. + dstSpec input: An FSSpec record specifying the destination + directory. + copyName input: Points to the new name if the object is to be + renamed or nil if the object isn't to be renamed. + + Result Codes + noErr 0 No error + dirFulErr -33 File directory full + dskFulErr -34 Disk is full + nsvErr -35 Volume not found + ioErr -36 I/O error + bdNamErr -37 Bad filename or attempt to move into + a file + fnfErr -43 Source file or directory not found + wPrErr -44 Hardware volume lock + fLckdErr -45 File is locked + vLckdErr -46 Destination volume is read-only + fBsyErr -47 File busy, directory not empty, or + working directory control block open + dupFNErr -48 Destination already exists + paramErr -50 Volume doesn't support this function, + no default volume, or source and + volOfflinErr -53 Volume is offline + fsRnErr -59 Problem during rename + dirNFErr -120 Directory not found or incomplete pathname + badMovErr -122 Attempted to move directory into + offspring + wrgVolTypErr -123 Not an HFS volume (it's a MFS volume) + notAFileErr -1302 The pathname is nil, the pathname + is empty, or the pathname cannot refer + to a filename + diffVolErr -1303 Files on different volumes + afpAccessDenied -5000 The user does not have the right to + move the file or directory + afpObjectTypeErr -5025 Directory not found or incomplete pathname + afpSameObjectErr -5038 Source and destination files are the same + + __________ + + See also: HMoveRenameCompat +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +BuildAFPVolMountInfo( + short flags, + char nbpInterval, + char nbpCount, + short uamType, + Str32 zoneName, + Str31 serverName, + Str27 volName, + Str31 userName, + Str8 userPassword, + Str8 volPassword, + AFPVolMountInfoPtr * afpInfoPtr); + + +/* + The BuildAFPVolMountInfo function allocates and initializes the fields + of an AFPVolMountInfo record before using that record to call + the VolumeMount function. + + flags input: The AFP mounting flags. 0 = normal mount; + set bit 0 to inhibit greeting messages. + nbpInterval input: The interval used for VolumeMount's + NBP Lookup call. 7 is a good choice. + nbpCount input: The retry count used for VolumeMount's + NBP Lookup call. 5 is a good choice. + uamType input: The user authentication method to use. + zoneName input: The AppleTalk zone name of the server. + serverName input: The AFP server name. + volName input: The AFP volume name. + userName input: The user name (zero length Pascal string for + guest). + userPassWord input: The user password (zero length Pascal string + if no user password) + volPassWord input: The volume password (zero length Pascal string + if no volume password) + afpInfoPtr output: A pointer to the newly created and initialized + AFPVolMountInfo record. If the function fails to + create an AFPVolMountInfo record, it sets + afpInfoPtr to NULL and the function result is + memFullErr. Your program is responsible + for disposing of this pointer when it is finished + with it. + + Result Codes + noErr 0 No error + memFullErr -108 memory full error + + __________ + + Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, + RetrieveAFPVolMountInfo, BuildAFPXVolMountInfo, + RetrieveAFPXVolMountInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +RetrieveAFPVolMountInfo( + AFPVolMountInfoPtr afpInfoPtr, + short * flags, + short * uamType, + StringPtr zoneName, + StringPtr serverName, + StringPtr volName, + StringPtr userName); + + +/* + The RetrieveAFPVolMountInfo function retrieves the AFP mounting + information returned in an AFPVolMountInfo record by the + GetVolMountInfo function. + + afpInfoPtr input: Pointer to AFPVolMountInfo record that contains + the AFP mounting information. + flags output: The AFP mounting flags. + uamType output: The user authentication method used. + zoneName output: The AppleTalk zone name of the server. + serverName output: The AFP server name. + volName output: The AFP volume name. + userName output: The user name (zero length Pascal string for + guest). + + Result Codes + noErr 0 No error + paramErr -50 media field in AFP mounting information + was not AppleShareMediaType + + __________ + + Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, + BuildAFPVolMountInfo, BuildAFPXVolMountInfo, + RetrieveAFPXVolMountInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +BuildAFPXVolMountInfo( + short flags, + char nbpInterval, + char nbpCount, + short uamType, + Str32 zoneName, + Str31 serverName, + Str27 volName, + Str31 userName, + Str8 userPassword, + Str8 volPassword, + Str32 uamName, + unsigned long alternateAddressLength, + void * alternateAddress, + AFPXVolMountInfoPtr * afpXInfoPtr); + + +/* + The BuildAFPXVolMountInfo function allocates and initializes the fields + of an AFPXVolMountInfo record before using that record to call + the VolumeMount function. + + flags input: The AFP mounting flags. + nbpInterval input: The interval used for VolumeMount's + NBP Lookup call. 7 is a good choice. + nbpCount input: The retry count used for VolumeMount's + NBP Lookup call. 5 is a good choice. + uamType input: The user authentication method to use. + zoneName input: The AppleTalk zone name of the server. + serverName input: The AFP server name. + volName input: The AFP volume name. + userName input: The user name (zero length Pascal string + for guest). + userPassWord input: The user password (zero length Pascal + string if no user password) + volPassWord input: The volume password (zero length Pascal + string if no volume password) + uamName input: The User Authentication Method name. + alternateAddressLength input: Length of alternateAddress data. + alternateAddress input The AFPAlternateAddress (variable length) + afpXInfoPtr output: A pointer to the newly created and + initialized AFPVolMountInfo record. + If the function fails to create an + AFPVolMountInfo record, it sets + afpInfoPtr to NULL and the function + result is memFullErr. Your program is + responsible for disposing of this pointer + when it is finished with it. + + Result Codes + noErr 0 No error + memFullErr -108 memory full error + + __________ + + Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, + BuildAFPVolMountInfo, RetrieveAFPVolMountInfo, + RetrieveAFPXVolMountInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +RetrieveAFPXVolMountInfo( + AFPXVolMountInfoPtr afpXInfoPtr, + short * flags, + short * uamType, + StringPtr zoneName, + StringPtr serverName, + StringPtr volName, + StringPtr userName, + StringPtr uamName, + unsigned long * alternateAddressLength, + AFPAlternateAddress ** alternateAddress); + + +/* + The RetrieveAFPXVolMountInfo function retrieves the AFP mounting + information returned in an AFPXVolMountInfo record by the + GetVolMountInfo function. + + afpXInfoPtr input: Pointer to AFPXVolMountInfo record that + contains the AFP mounting information. + flags output: The AFP mounting flags. + uamType output: The user authentication method used. + zoneName output: The AppleTalk zone name of the server. + serverName output: The AFP server name. + volName output: The AFP volume name. + userName output: The user name (zero length Pascal + string for guest). + uamName output: The User Authentication Method name. + alternateAddressLength output: Length of alternateAddress data returned. + alternateAddress: output: A pointer to the newly created and + AFPAlternateAddress record (a variable + length record). If the function fails to + create an AFPAlternateAddress record, + it sets alternateAddress to NULL and the + function result is memFullErr. Your + program is responsible for disposing of + this pointer when it is finished with it. + + Result Codes + noErr 0 No error + paramErr -50 media field in AFP mounting information + was not AppleShareMediaType + memFullErr -108 memory full error + + __________ + + Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount, + BuildAFPVolMountInfo, RetrieveAFXVolMountInfo, + BuildAFPXVolMountInfo +*/ + +/*****************************************************************************/ + +EXTERN_API( OSErr ) +GetUGEntries( + short objType, + UGEntryPtr entries, + long reqEntryCount, + long * actEntryCount, + long * objID); + + +/* + The GetUGEntries functions retrieves a list of user or group entries + from the local file server. + + objType input: The object type: -1 = group; 0 = user + UGEntries input: Pointer to array of UGEntry records where the list + is returned. + reqEntryCount input: The number of elements in the UGEntries array. + actEntryCount output: The number of entries returned. + objID input: The current index position. Set to 0 to start with + the first entry. + output: The index position to get the next entry. Pass this + value the next time you call GetUGEntries to start + where you left off. + + Result Codes + noErr 0 No error + fnfErr -43 No more users or groups + paramErr -50 Function not supported; or, ioObjID is + negative + + __________ + + Also see: GetUGEntry +*/ + +/*****************************************************************************/ + + + +#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 /* __MOREFILESEXTRAS__ */ + diff --git a/src/mac/morefile/Optim.h b/src/mac/morefile/Optim.h deleted file mode 100644 index ff5a1d5d57..0000000000 --- a/src/mac/morefile/Optim.h +++ /dev/null @@ -1,120 +0,0 @@ -/* -** Apple Macintosh Developer Technical Support -** -** DirectoryCopy: #defines that let you make MoreFiles code more efficient. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: Optimization.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. -** -** The Optimization changes to MoreFiles source and header files, along with -** this file and OptimizationEnd.h, let you optimize the code produced -** by MoreFiles in several ways. -** -** 1 -- MoreFiles contains extra code so that many routines can run under -** Mac OS systems back to System 6. If your program requires a specific -** version of Mac OS and your program checks for that version before -** calling MoreFiles routines, then you can remove a lot of compatibility -** code by defining one of the following to 1: -** -** __MACOSSEVENFIVEONEORLATER // assume Mac OS 7.5.1 or later -** __MACOSSEVENFIVEORLATER // assume Mac OS 7.5 or later -** __MACOSSEVENORLATER // assume Mac OS 7.0 or later -** -** By default, all compatibility code is ON. -** -** 2 -- You may disable Pascal calling conventions in all MoreFiles routines -** except for system callbacks that require Pascal calling conventions. -** This will make C programs both smaller and faster. -** Just define __WANTPASCALELIMINATION to be 1 to turn this optimization on -** when building MoreFiles for use from C programs (you'll need to keep -** Pascal calling conventions when linking MoreFiles routines with Pascal -** programs). -** -** 3 -- If Metrowerks compiler is used, "#pragma internal on" may help produce -** better code. However, this option can also cause problems if you're -** trying to build MoreFiles as a shared library, so it is by default not used. -** Just define __USEPRAGMAINTERNAL to be 1 to turn this optimization on. -** -** Original changes supplied by Fabrizio Oddone -** -** File: Optimization.h -*/ - -#if TARGET_CARBON - - #define __MACOSSEVENFIVEONEORLATER 1 - - #define __MACOSSEVENORLATER 1 - - #ifndef __WANTPASCALELIMINATION - #define __WANTPASCALELIMINATION 0 - #endif - - #if __WANTPASCALELIMINATION - #define pascal - #endif - - - #ifndef __USEPRAGMAINTERNAL - #define __USEPRAGMAINTERNAL 0 - #endif - - #if __USEPRAGMAINTERNAL - #if defined(__MWERKS__) - #pragma internal on - #endif - #endif -#else - - // we have a basic requirements of 7.5.3 Rev 2 or 7.6 - - #define __MACOSSEVENFIVEONEORLATER 1 - - #ifndef __MACOSSEVENFIVEONEORLATER - #define __MACOSSEVENFIVEONEORLATER 0 - #endif - - #ifndef __MACOSSEVENFIVEORLATER - #define __MACOSSEVENFIVEORLATER __MACOSSEVENFIVEONEORLATER - #endif - - #ifndef __MACOSSEVENORLATER - #if GENERATINGCFM - #define __MACOSSEVENORLATER 1 - #else - #define __MACOSSEVENORLATER __MACOSSEVENFIVEORLATER - #endif - #endif - - - #ifndef __WANTPASCALELIMINATION - #define __WANTPASCALELIMINATION 0 - #endif - - #if __WANTPASCALELIMINATION - #define pascal - #endif - - - #ifndef __USEPRAGMAINTERNAL - #define __USEPRAGMAINTERNAL 0 - #endif - - #if __USEPRAGMAINTERNAL - #if defined(__MWERKS__) - #pragma internal on - #endif - #endif -#endif diff --git a/src/mac/morefile/OptimEnd.h b/src/mac/morefile/OptimEnd.h deleted file mode 100644 index 5cab00a593..0000000000 --- a/src/mac/morefile/OptimEnd.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -** Apple Macintosh Developer Technical Support -** -** DirectoryCopy: #defines that let you make MoreFiles code more efficient. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: OptimizationEnd.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. -** -** The Optimization changes to MoreFiles source and header files, along with -** this file and Optimization.h, let you optimize the code produced by MoreFiles -** in several ways. -** -** Original changes supplied by Fabrizio Oddone -*/ - - -#if __USEPRAGMAINTERNAL - #if defined(__MWERKS__) - #pragma internal reset - #endif -#endif - - -#if __WANTPASCALELIMINATION - #ifndef __COMPILINGMOREFILES - #undef pascal - #endif -#endif diff --git a/src/mac/morefile/Optimization.h b/src/mac/morefile/Optimization.h new file mode 100644 index 0000000000..d2673f9304 --- /dev/null +++ b/src/mac/morefile/Optimization.h @@ -0,0 +1,109 @@ +/* + File: Optimization.h + + Contains: Defines that let you make MoreFiles code more efficient. + + Version: MoreFiles + + Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <1> 2/7/01 JL first checked in +*/ + +/* + The Optimization changes to MoreFiles source and header files, along with + this file and OptimizationEnd.h, let you optimize the code produced + by MoreFiles in several ways. + + 1 -- MoreFiles contains extra code so that many routines can run under + Mac OS systems back to System 6. If your program requires a specific + version of Mac OS and your program checks for that version before + calling MoreFiles routines, then you can remove a lot of compatibility + code by defining one of the following to 1: + + __MACOSSEVENFIVEONEORLATER // assume Mac OS 7.5.1 or later + __MACOSSEVENFIVEORLATER // assume Mac OS 7.5 or later + __MACOSSEVENORLATER // assume Mac OS 7.0 or later + + If you're compiling 68K code, the default is to include all compatibility code. + If you're compiling PowerPC code (TARGET_RT_MAC_CFM), the default is __MACOSSEVENORLATER + If you're compiling for Carbon code (TARGET_API_MAC_CARBON), the default is __MACOSSEVENFIVEONEORLATER + + 2 -- You may disable Pascal calling conventions in all MoreFiles routines + except for system callbacks that require Pascal calling conventions. + This will make 68K C programs both smaller and faster. + (PowerPC compilers ignore pascal calling conventions.) + Just define __WANTPASCALELIMINATION to be 1 to turn this optimization on + when building MoreFiles for use from C programs (you'll need to keep + Pascal calling conventions when linking MoreFiles routines with Pascal + programs). + + 3 -- If Metrowerks compiler is used, "#pragma internal on" may help produce + better code. However, this option can also cause problems if you're + trying to build MoreFiles as a shared library, so it is by default not used. + Just define __USEPRAGMAINTERNAL to be 1 to turn this optimization on. + + Original changes supplied by Fabrizio Oddone +*/ + +#include + +// if we're compiling for Carbon, then we're running on Mac OS 8.1 or later +#ifndef __MACOSSEVENFIVEONEORLATER + #define __MACOSSEVENFIVEONEORLATER TARGET_API_MAC_CARBON +#endif + +#ifndef __MACOSSEVENFIVEORLATER + #define __MACOSSEVENFIVEORLATER __MACOSSEVENFIVEONEORLATER +#endif + +#ifndef __MACOSSEVENORLATER + #if TARGET_RT_MAC_CFM + #define __MACOSSEVENORLATER 1 + #else + #define __MACOSSEVENORLATER __MACOSSEVENFIVEORLATER + #endif +#endif + + +#ifndef __WANTPASCALELIMINATION + #define __WANTPASCALELIMINATION 0 +#endif + +#if __WANTPASCALELIMINATION + #define pascal +#endif + + +#ifndef __USEPRAGMAINTERNAL + #define __USEPRAGMAINTERNAL 0 +#endif + +#if __USEPRAGMAINTERNAL + #if defined(__MWERKS__) + #pragma internal on + #endif +#endif diff --git a/src/mac/morefile/OptimizationEnd.h b/src/mac/morefile/OptimizationEnd.h new file mode 100644 index 0000000000..10ed02507f --- /dev/null +++ b/src/mac/morefile/OptimizationEnd.h @@ -0,0 +1,56 @@ +/* + File: OptimizationEnd.h + + Contains: Defines that let you make MoreFiles code more efficient. + + Version: MoreFiles + + Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Apple Macintosh Developer Technical Support + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <1> 2/7/01 JL first checked in +*/ + +/* + The Optimization changes to MoreFiles source and header files, along with + this file and Optimization.h, let you optimize the code produced by MoreFiles + in several ways. + + Original changes supplied by Fabrizio Oddone +*/ + + +#if __USEPRAGMAINTERNAL + #if defined(__MWERKS__) + #pragma internal reset + #endif +#endif + + +#if __WANTPASCALELIMINATION + #ifndef __COMPILINGMOREFILES + #undef pascal + #endif +#endif diff --git a/src/mac/morefile/Search.cpp b/src/mac/morefile/Search.c similarity index 93% rename from src/mac/morefile/Search.cpp rename to src/mac/morefile/Search.c index bdcfd9ff1a..6f7953b830 100644 --- a/src/mac/morefile/Search.cpp +++ b/src/mac/morefile/Search.c @@ -1,36 +1,55 @@ /* -** Apple Macintosh Developer Technical Support -** -** IndexedSearch and the PBCatSearch compatibility function. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: Search.c -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: Search.c + + Contains: IndexedSearch and the PBCatSearch compatibility function. + + Version: MoreFiles + + Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved. + + 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. + + File Ownership: + + DRI: Jim Luther + + Other Contact: Apple Macintosh Developer Technical Support + + + Technology: DTS Sample Code + + Writers: + + (JL) Jim Luther + + Change History (most recent first): + + <2> 2/7/01 JL Added standard header. Updated names of includes. Updated + various routines to use new calling convention of the + MoreFilesExtras accessor functions. Added TARGET_API_MAC_CARBON + conditional checks around TimeOutTask. + <1> 12/06/99 JL MoreFiles 1.5. */ -#include +#include #include #include -#include -#include +#include +#include #include #include #define __COMPILINGMOREFILES -#include "MoreFile.h" -#include "MoreExtr.h" +#include "MoreFiles.h" +#include "MoreFilesExtras.h" + #include "Search.h" /*****************************************************************************/ @@ -66,7 +85,7 @@ typedef LevelRec *LevelRecPtr, **LevelRecHandle; ** SearchPositionRec is my version of a CatPositionRec. It holds the ** information I need to resuming searching. */ -#if PRAGMA_ALIGN_SUPPORTED +#if PRAGMA_STRUCT_ALIGN #pragma options align=mac68k #endif struct SearchPositionRec @@ -76,7 +95,7 @@ struct SearchPositionRec unsigned short stackDepth; /* Current depth on searchStack. */ short priv[11]; /* For future use... */ }; -#if PRAGMA_ALIGN_SUPPORTED +#if PRAGMA_STRUCT_ALIGN #pragma options align=reset #endif typedef struct SearchPositionRec SearchPositionRec; @@ -86,7 +105,7 @@ typedef SearchPositionRec *SearchPositionRecPtr; /* ** ExtendedTMTask is a TMTask record extended to hold the timer flag. */ -#if PRAGMA_ALIGN_SUPPORTED +#if PRAGMA_STRUCT_ALIGN #pragma options align=mac68k #endif struct ExtendedTMTask @@ -95,7 +114,7 @@ struct ExtendedTMTask Boolean stopSearch; /* the Time Mgr task will set stopSearch to */ /* true when the timer expires */ }; -#if PRAGMA_ALIGN_SUPPORTED +#if PRAGMA_STRUCT_ALIGN #pragma options align=reset #endif typedef struct ExtendedTMTask ExtendedTMTask; @@ -135,7 +154,7 @@ static void CheckForMatches(CInfoPBPtr cPB, #undef pascal #endif -#if GENERATINGCFM +#if TARGET_RT_MAC_CFM || TARGET_API_MAC_CARBON static pascal void TimeOutTask(TMTaskPtr tmTaskPtr); @@ -205,7 +224,7 @@ static OSErr CheckStack(unsigned short stackDepth, /* Time to grow stack */ SetHandleSize((Handle)searchStack, *searchStackSize + (kAdditionalLevelRecs * sizeof(LevelRec))); result = MemError(); /* should be noErr */ - *searchStackSize = InlineGetHandleSize((Handle)searchStack); + *searchStackSize = GetHandleSize((Handle)searchStack); } else { @@ -277,16 +296,16 @@ static OSErr VerifyUserPB(CSParamPtr userPB, { /* The only attributes you can search on are the directory flag */ /* and the locked flag. */ - if ( (searchInfo2->hFileInfo.ioFlAttrib & ~(ioDirMask | 0x01)) != 0 ) + if ( (searchInfo2->hFileInfo.ioFlAttrib & ~(kioFlAttribDirMask | kioFlAttribLockedMask)) != 0 ) { goto ParamErrExit; } /* interested in the directory bit? */ - if ( (searchInfo2->hFileInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (searchInfo2->hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* yes, so do they want just directories or just files? */ - if ( (searchInfo1->hFileInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (searchInfo1->hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { *includeDirs = true; } @@ -313,7 +332,7 @@ static OSErr VerifyUserPB(CSParamPtr userPB, /* then the locked attribute cannot be requested. */ if ( *includeDirs && ((userPB->ioSearchBits & fsSBFlAttrib) != 0) && - ((searchInfo2->hFileInfo.ioFlAttrib & 0x01) != 0) ) + ((searchInfo2->hFileInfo.ioFlAttrib & kioFlAttribLockedMask) != 0) ) { goto ParamErrExit; } @@ -462,7 +481,7 @@ static void CheckForMatches(CInfoPBPtr cPB, /* Into the if statements that go on forever... */ - if ( (cPB->hFileInfo.ioFlAttrib & ioDirMask) == 0 ) + if ( (cPB->hFileInfo.ioFlAttrib & kioFlAttribDirMask) == 0 ) { if (!includeFiles) { @@ -678,7 +697,7 @@ Failed: #undef pascal #endif -#if GENERATINGCFM +#if TARGET_RT_MAC_CFM || TARGET_API_MAC_CARBON static pascal void TimeOutTask(TMTaskPtr tmTaskPtr) { @@ -761,7 +780,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb, if ( pb->ioSearchTime != 0 ) { /* Start timer */ - timerTask.theTask.tmAddr = NewTimerProc(TimeOutTask); + timerTask.theTask.tmAddr = NewTimerUPP(TimeOutTask); InsTime((QElemPtr)&(timerTask.theTask)); PrimeTime((QElemPtr)&(timerTask.theTask), pb->ioSearchTime); } @@ -800,7 +819,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb, /* Make sure searchStack really exists */ if ( searchStack != NULL ) { - searchStackSize = InlineGetHandleSize((Handle)searchStack); + searchStackSize = GetHandleSize((Handle)searchStack); /* See if the search is a new search or a resumed search. */ if ( catPosition->initialize == 0 ) @@ -897,7 +916,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb, CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs); ++index; - if ( (cPB.dirInfo.ioFlAttrib & ioDirMask) != 0 ) + if ( (cPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 ) { /* It's a directory */ @@ -1007,7 +1026,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb, { /* Stop Time Manager task here if it was installed */ RmvTime((QElemPtr)&(timerTask.theTask)); - DisposeRoutineDescriptor(timerTask.theTask.tmAddr); + DisposeTimerUPP(timerTask.theTask.tmAddr); } return ( result ); @@ -1017,19 +1036,22 @@ pascal OSErr IndexedSearch(CSParamPtr pb, pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock) { - static Boolean fullExtFSDispatchingtested = false; - static Boolean hasFullExtFSDispatching = false; OSErr result; Boolean supportsCatSearch; - long response; GetVolParmsInfoBuffer volParmsInfo; long infoSize; +#if !__MACOSSEVENORLATER + static Boolean fullExtFSDispatchingtested = false; + static Boolean hasFullExtFSDispatching = false; + long response; +#endif result = noErr; +#if !__MACOSSEVENORLATER /* See if File Manager will pass CatSearch requests to external file systems */ /* we'll store the results in a static variable so we don't have to call Gestalt */ - /* everytime we're called. */ + /* everytime we're called. (System 7.0 and later always do this) */ if ( !fullExtFSDispatchingtested ) { fullExtFSDispatchingtested = true; @@ -1038,18 +1060,21 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock) hasFullExtFSDispatching = ((response & (1L << gestaltFullExtFSDispatching)) != 0); } } +#endif /* CatSearch is a per volume attribute, so we have to check each time we're */ /* called to see if it is available on the volume specified. */ supportsCatSearch = false; +#if !__MACOSSEVENORLATER if ( hasFullExtFSDispatching ) +#endif { infoSize = sizeof(GetVolParmsInfoBuffer); result = HGetVolParms(paramBlock->ioNamePtr, paramBlock->ioVRefNum, &volParmsInfo, &infoSize); if ( result == noErr ) { - supportsCatSearch = hasCatSearch(volParmsInfo); + supportsCatSearch = hasCatSearch(&volParmsInfo); } } @@ -1125,7 +1150,7 @@ pascal OSErr NameFileSearch(ConstStr255Param volName, /* only match files (not directories) */ searchInfo1.hFileInfo.ioFlAttrib = 0x00; - searchInfo2.hFileInfo.ioFlAttrib = ioDirMask; + searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask; error = PBCatSearchSyncCompat((CSParamPtr)&pb); @@ -1204,7 +1229,7 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, /* only match files (not directories) */ searchInfo1.hFileInfo.ioFlAttrib = 0x00; - searchInfo2.hFileInfo.ioFlAttrib = ioDirMask; + searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask; /* search for creator; if creator = 0x00000000, ignore creator */ searchInfo1.hFileInfo.ioFlFndrInfo.fdCreator = creator; diff --git a/src/mac/morefile/Search.h b/src/mac/morefile/Search.h index fe79c120fd..3fee03dea8 100644 --- a/src/mac/morefile/Search.h +++ b/src/mac/morefile/Search.h @@ -1,246 +1,304 @@ /* -** Apple Macintosh Developer Technical Support -** -** IndexedSearch and the PBCatSearch compatibility function. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: Search.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. + File: Search.h + + Contains: IndexedSearch and the PBCatSearch compatibility function. + + 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 __SEARCH__ #define __SEARCH__ -#include +#ifndef __MACTYPES__ +#include +#endif + +#ifndef __FILES__ #include +#endif + +#include "Optimization.h" + -#include "Optim.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 + /*****************************************************************************/ -pascal OSErr IndexedSearch(CSParamPtr pb, - long dirID); -/* ¦ Search in and below a directory. - The IndexedSearch function performs an indexed search in and below the - specified directory using the same parameters (in pb) as is passed to - PBCatSearch. See Inside Macintosh: Files for a description of the - parameter block. - - pb input: A CSParamPtr record specifying the volume to search - and the search criteria. - output: Fields in the parameter block are returned indicating - the number of matches found, the matches, and if the - search ended with noErr, the CatPosition record that - lets you resume a search where the last search left - off. - dirID input: The directory to search. If fsRtDirID is passed, - the entire volume is searched. - - Note: If you use a high-level debugger and use ioSearchTime to limit - the length of time to run the search, you'll want to step over - calls to IndexedSearch because it installs a Time Manager task. - Most high-level debuggers don't deal gracefully with interrupt - driven code. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - eofErr -39 End of catalog found (this is normal!) - paramErr -50 Parameter block has invalid parameters - (see source for VerifyUserPB) or - invalid catPosition record was passed - extFSErr -58 External file system error - no file - system claimed this call. - memFullErr -108 Memory could not be allocated in heap - catChangedErr -1304 Catalog has changed and catalog position - record may be invalid - - __________ - - See also: PBCatSearch, PBCatSearchSyncCompat +EXTERN_API( OSErr ) +IndexedSearch( + CSParamPtr pb, + long dirID); + + +/* + The IndexedSearch function performs an indexed search in and below the + specified directory using the same parameters (in pb) as is passed to + PBCatSearch. See Inside Macintosh: Files for a description of the + parameter block. + + pb input: A CSParamPtr record specifying the volume to search + and the search criteria. + output: Fields in the parameter block are returned indicating + the number of matches found, the matches, and if the + search ended with noErr, the CatPosition record that + lets you resume a search where the last search left + off. + dirID input: The directory to search. If fsRtDirID is passed, + the entire volume is searched. + + Note: If you use a high-level debugger and use ioSearchTime to limit + the length of time to run the search, you'll want to step over + calls to IndexedSearch because it installs a Time Manager task. + Most high-level debuggers don't deal gracefully with interrupt + driven code. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + eofErr -39 End of catalog found (this is normal!) + paramErr -50 Parameter block has invalid parameters + (see source for VerifyUserPB) or + invalid catPosition record was passed + extFSErr -58 External file system error - no file + system claimed this call. + memFullErr -108 Memory could not be allocated in heap + catChangedErr -1304 Catalog has changed and catalog position + record may be invalid + + __________ + + See also: PBCatSearch, PBCatSearchSyncCompat */ /*****************************************************************************/ -pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock); -/* ¦ Search a volume using PBCatSearch or IndexedSearch. - The PBCatSearchSyncCompat function uses PBCatSearch (if available) or - IndexedSearch (if PBCatSearch is not available) to search a volume - using a set of search criteria that you specify. It builds a list of all - files or directories that meet your specifications. - - pb input: A CSParamPtr record specifying the volume to search - and the search criteria. - output: Fields in the parameter block are returned indicating - the number of matches found, the matches, and if the - search ended with noErr, the CatPosition record that - lets you resume a search where the last search left - off. - - Note: If you use a high-level debugger and use ioSearchTime to limit - the length of time to run the search, you'll want to step over - calls to PBCatSearchSyncCompat because it calls IndexedSearch - which installs a Time Manager task. Most high-level debuggers - don't deal gracefully with interrupt driven code. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - eofErr -39 End of catalog found (this is normal!) - paramErr -50 Parameter block has invalid parameters - (see source for VerifyUserPB) or - invalid catPosition record was passed - extFSErr -58 External file system error - no file - system claimed this call. - memFullErr -108 Memory could not be allocated in heap - catChangedErr -1304 Catalog has changed and catalog position - record may be invalid - afpCatalogChanged -5037 Catalog has changed and search cannot - be resumed - - __________ - - See also: PBCatSearch, IndexedSearch +EXTERN_API( OSErr ) +PBCatSearchSyncCompat(CSParamPtr paramBlock); + + +/* + The PBCatSearchSyncCompat function uses PBCatSearch (if available) or + IndexedSearch (if PBCatSearch is not available) to search a volume + using a set of search criteria that you specify. It builds a list of all + files or directories that meet your specifications. + + pb input: A CSParamPtr record specifying the volume to search + and the search criteria. + output: Fields in the parameter block are returned indicating + the number of matches found, the matches, and if the + search ended with noErr, the CatPosition record that + lets you resume a search where the last search left + off. + + Note: If you use a high-level debugger and use ioSearchTime to limit + the length of time to run the search, you'll want to step over + calls to PBCatSearchSyncCompat because it calls IndexedSearch + which installs a Time Manager task. Most high-level debuggers + don't deal gracefully with interrupt driven code. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + eofErr -39 End of catalog found (this is normal!) + paramErr -50 Parameter block has invalid parameters + (see source for VerifyUserPB) or + invalid catPosition record was passed + extFSErr -58 External file system error - no file + system claimed this call. + memFullErr -108 Memory could not be allocated in heap + catChangedErr -1304 Catalog has changed and catalog position + record may be invalid + afpCatalogChanged -5037 Catalog has changed and search cannot + be resumed + + __________ + + See also: PBCatSearch, IndexedSearch */ /*****************************************************************************/ -pascal OSErr NameFileSearch(ConstStr255Param volName, - short vRefNum, - ConstStr255Param fileName, - FSSpecPtr matches, - long reqMatchCount, - long *actMatchCount, - Boolean newSearch, - Boolean partial); -/* ¦ Search for files by file name with PBCatSearch. - The NameFileSearch function searches for files with a specific file - name on a volume that supports PBCatSearch. - Note: A result of catChangedErr means the catalog has changed between - searches, but the search can be continued with the possiblity that you - may miss some matches or get duplicate matches. For all other results - (except for noErr), the search cannot be continued. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - fileName input: The name of the file to search for. - matches input: Pointer to array of FSSpec where the match list is - returned. - reqMatchCount input: Maximum number of matches to return (the number of - elements in the matches array). - actMatchCount output: The number of matches actually returned. - newSearch input: If true, start a new search. If false and if - vRefNum is the same as the last call to - NameFileSearch, then start searching at the - position where the last search left off. - partial input: If the partial parameter is false, then only files - that exactly match fileName will be found. If the - partial parameter is true, then all file names that - contain fileName will be found. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - eofErr -39 End of catalog found (this is normal!) - paramErr -50 Parameter block has invalid parameters - (see source for VerifyUserPB) or - invalid catPosition record was passed - extFSErr -58 External file system error - no file - system claimed this call. - memFullErr -108 Memory could not be allocated in heap - catChangedErr -1304 Catalog has changed and catalog position - record may be invalid - afpCatalogChanged -5037 Catalog has changed and search cannot - be resumed - - __________ - - Also see: CreatorTypeFileSearch +EXTERN_API( OSErr ) +NameFileSearch( + ConstStr255Param volName, + short vRefNum, + ConstStr255Param fileName, + FSSpecPtr matches, + long reqMatchCount, + long * actMatchCount, + Boolean newSearch, + Boolean partial); + + +/* + The NameFileSearch function searches for files with a specific file + name on a volume that supports PBCatSearch. + Note: A result of catChangedErr means the catalog has changed between + searches, but the search can be continued with the possiblity that you + may miss some matches or get duplicate matches. For all other results + (except for noErr), the search cannot be continued. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + fileName input: The name of the file to search for. + matches input: Pointer to array of FSSpec where the match list is + returned. + reqMatchCount input: Maximum number of matches to return (the number of + elements in the matches array). + actMatchCount output: The number of matches actually returned. + newSearch input: If true, start a new search. If false and if + vRefNum is the same as the last call to + NameFileSearch, then start searching at the + position where the last search left off. + partial input: If the partial parameter is false, then only files + that exactly match fileName will be found. If the + partial parameter is true, then all file names that + contain fileName will be found. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + eofErr -39 End of catalog found (this is normal!) + paramErr -50 Parameter block has invalid parameters + (see source for VerifyUserPB) or + invalid catPosition record was passed + extFSErr -58 External file system error - no file + system claimed this call. + memFullErr -108 Memory could not be allocated in heap + catChangedErr -1304 Catalog has changed and catalog position + record may be invalid + afpCatalogChanged -5037 Catalog has changed and search cannot + be resumed + + __________ + + Also see: CreatorTypeFileSearch */ /*****************************************************************************/ -pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, - short vRefNum, - OSType creator, - OSType fileType, - FSSpecPtr matches, - long reqMatchCount, - long *actMatchCount, - Boolean newSearch); -/* ¦ Search for files by creator/fileType with PBCatSearch. - The CreatorTypeFileSearch function searches for files with a specific - creator or fileType on a volume that supports PBCatSearch. - Note: A result of catChangedErr means the catalog has changed between - searches, but the search can be continued with the possiblity that you - may miss some matches or get duplicate matches. For all other results - (except for noErr), the search cannot be continued. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - creator input: The creator type of the file to search for. - To ignore the creator type, pass 0x00000000 in - this field. - fileType input: The file type of the file to search for. - To ignore the file type, pass 0x00000000 in - this field. - matches input: Pointer to array of FSSpec where the match list is - returned. - reqMatchCount input: Maximum number of matches to return (the number of - elements in the matches array). - actMatchCount output: The number of matches actually returned. - newSearch input: If true, start a new search. If false and if - vRefNum is the same as the last call to - CreatorTypeFileSearch, then start searching at the - position where the last search left off. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - eofErr -39 End of catalog found (this is normal!) - paramErr -50 Parameter block has invalid parameters - (see source for VerifyUserPB) or - invalid catPosition record was passed - extFSErr -58 External file system error - no file - system claimed this call. - memFullErr -108 Memory could not be allocated in heap - catChangedErr -1304 Catalog has changed and catalog position - record may be invalid - afpCatalogChanged -5037 Catalog has changed and search cannot - be resumed - - __________ - - Also see: NameFileSearch +EXTERN_API( OSErr ) +CreatorTypeFileSearch( + ConstStr255Param volName, + short vRefNum, + OSType creator, + OSType fileType, + FSSpecPtr matches, + long reqMatchCount, + long * actMatchCount, + Boolean newSearch); + + +/* + The CreatorTypeFileSearch function searches for files with a specific + creator or fileType on a volume that supports PBCatSearch. + Note: A result of catChangedErr means the catalog has changed between + searches, but the search can be continued with the possiblity that you + may miss some matches or get duplicate matches. For all other results + (except for noErr), the search cannot be continued. + + volName input: A pointer to the name of a mounted volume + or nil. + vRefNum input: Volume specification. + creator input: The creator type of the file to search for. + To ignore the creator type, pass 0x00000000 in + this field. + fileType input: The file type of the file to search for. + To ignore the file type, pass 0x00000000 in + this field. + matches input: Pointer to array of FSSpec where the match list is + returned. + reqMatchCount input: Maximum number of matches to return (the number of + elements in the matches array). + actMatchCount output: The number of matches actually returned. + newSearch input: If true, start a new search. If false and if + vRefNum is the same as the last call to + CreatorTypeFileSearch, then start searching at the + position where the last search left off. + + Result Codes + noErr 0 No error + nsvErr -35 Volume not found + ioErr -36 I/O error + eofErr -39 End of catalog found (this is normal!) + paramErr -50 Parameter block has invalid parameters + (see source for VerifyUserPB) or + invalid catPosition record was passed + extFSErr -58 External file system error - no file + system claimed this call. + memFullErr -108 Memory could not be allocated in heap + catChangedErr -1304 Catalog has changed and catalog position + record may be invalid + afpCatalogChanged -5037 Catalog has changed and search cannot + be resumed + + __________ + + Also see: NameFileSearch */ /*****************************************************************************/ +#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 -#include "OptimEnd.h" +#endif /* __SEARCH__ */ -#endif /* __SEARCH__ */ diff --git a/src/mac/morefile/mfsearch.cpp b/src/mac/morefile/mfsearch.cpp deleted file mode 100644 index 6aed9b934d..0000000000 --- a/src/mac/morefile/mfsearch.cpp +++ /dev/null @@ -1,1313 +0,0 @@ -/* -** Apple Macintosh Developer Technical Support -** -** IndexedSearch and the PBCatSearch compatibility function. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: Search.c -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#define __COMPILINGMOREFILES - -#include "morefile.h" -#include "moreextr.h" -#include "mfsearch.h" - -/*****************************************************************************/ - -enum -{ - /* Number of LevelRecs to add each time the searchStack is grown */ - /* 20 levels is probably more than reasonable for most volumes. */ - /* If more are needed, they are allocated 20 levels at a time. */ - kAdditionalLevelRecs = 20 -}; - -/*****************************************************************************/ - -/* -** LevelRecs are used to store the directory ID and index whenever -** IndexedSearch needs to either scan a sub-directory, or return control -** to the caller because the call has timed out or the number of -** matches requested has been found. LevelRecs are stored in an array -** used as a stack. -*/ -struct LevelRec -{ - long dirModDate; /* for detecting most (but not all) catalog changes */ - long dirID; - short index; -}; -typedef struct LevelRec LevelRec; -typedef LevelRec *LevelRecPtr, **LevelRecHandle; - - -/* -** SearchPositionRec is my version of a CatPositionRec. It holds the -** information I need to resuming searching. -*/ -#if PRAGMA_STRUCT_ALIGN - #pragma options align=mac68k -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(push, 2) -#elif PRAGMA_STRUCT_PACK - #pragma pack(2) -#endif -struct SearchPositionRec -{ - long initialize; /* Goofy checksum of volume information used to make */ - /* sure we're resuming a search on the same volume. */ - unsigned short stackDepth; /* Current depth on searchStack. */ - short priv[11]; /* For future use... */ -}; -#if PRAGMA_STRUCT_ALIGN - #pragma options align=reset -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(pop) -#elif PRAGMA_STRUCT_PACK - #pragma pack() -#endif -typedef struct SearchPositionRec SearchPositionRec; -typedef SearchPositionRec *SearchPositionRecPtr; - - -/* -** ExtendedTMTask is a TMTask record extended to hold the timer flag. -*/ -#if PRAGMA_STRUCT_ALIGN - #pragma options align=mac68k -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(push, 2) -#elif PRAGMA_STRUCT_PACK - #pragma pack(2) -#endif -struct ExtendedTMTask -{ - TMTask theTask; - Boolean stopSearch; /* the Time Mgr task will set stopSearch to */ - /* true when the timer expires */ -}; -#if PRAGMA_STRUCT_ALIGN - #pragma options align=reset -#elif PRAGMA_STRUCT_PACKPUSH - #pragma pack(pop) -#elif PRAGMA_STRUCT_PACK - #pragma pack() -#endif -typedef struct ExtendedTMTask ExtendedTMTask; -typedef ExtendedTMTask *ExtendedTMTaskPtr; - -/*****************************************************************************/ - -static OSErr CheckVol(ConstStr255Param pathname, - short vRefNum, - short *realVRefNum, - long *volID); - -static OSErr CheckStack(unsigned short stackDepth, - LevelRecHandle searchStack, - Size *searchStackSize); - -static OSErr VerifyUserPB(CSParamPtr userPB, - Boolean *includeFiles, - Boolean *includeDirs, - Boolean *includeNames); - -static Boolean IsSubString(ConstStr255Param aStringPtr, - ConstStr255Param subStringPtr); - -static Boolean CompareMasked(const long *data1, - const long *data2, - const long *mask, - short longsToCompare); - -static void CheckForMatches(CInfoPBPtr cPB, - CSParamPtr userPB, - const Str63 matchName, - Boolean includeFiles, - Boolean includeDirs); - -#if __WANTPASCALELIMINATION -#undef pascal -#endif - -#if TARGET_CARBON -static pascal void TimeOutTask(TMTaskPtr tmTaskPtr); - -#else -#if GENERATINGCFM - -static pascal void TimeOutTask(TMTaskPtr tmTaskPtr); - -#else - -static pascal TMTaskPtr GetTMTaskPtr(void); - -static void TimeOutTask(void); - -#endif -#endif - -#if __WANTPASCALELIMINATION -#define pascal -#endif - -static long GetDirModDate(short vRefNum, - long dirID); - -/*****************************************************************************/ - -/* -** CheckVol gets the volume's real vRefNum and builds a volID. The volID -** is used to help insure that calls to resume searching with IndexedSearch -** are to the same volume as the last call to IndexedSearch. -*/ -static OSErr CheckVol(ConstStr255Param pathname, - short vRefNum, - short *realVRefNum, - long *volID) -{ - HParamBlockRec pb; - OSErr error; - - error = GetVolumeInfoNoName(pathname, vRefNum, &pb); - if ( error == noErr ) - { - /* Return the real vRefNum */ - *realVRefNum = pb.volumeParam.ioVRefNum; - - /* Add together a bunch of things that aren't supposed to change on */ - /* a mounted volume that's being searched and that should come up with */ - /* a fairly unique number */ - *volID = pb.volumeParam.ioVCrDate + - pb.volumeParam.ioVRefNum + - pb.volumeParam.ioVNmAlBlks + - pb.volumeParam.ioVAlBlkSiz + - pb.volumeParam.ioVFSID; - } - return ( error ); -} - -/*****************************************************************************/ - -/* -** CheckStack checks the size of the search stack (array) to see if there's -** room to push another LevelRec. If not, CheckStack grows the stack by -** another kAdditionalLevelRecs elements. -*/ -static OSErr CheckStack(unsigned short stackDepth, - LevelRecHandle searchStack, - Size *searchStackSize) -{ - OSErr result; - - if ( (*searchStackSize / sizeof(LevelRec)) == (stackDepth + 1) ) - { - /* Time to grow stack */ - SetHandleSize((Handle)searchStack, *searchStackSize + (kAdditionalLevelRecs * sizeof(LevelRec))); - result = MemError(); /* should be noErr */ -#if TARGET_CARBON - *searchStackSize = GetHandleSize((Handle)searchStack); -#else - *searchStackSize = InlineGetHandleSize((Handle)searchStack); -#endif - } - else - { - result = noErr; - } - - return ( result ); -} - -/*****************************************************************************/ - -/* -** VerifyUserPB makes sure the parameter block passed to IndexedSearch has -** valid parameters. By making this check once, we don't have to worry about -** things like NULL pointers, strings being too long, etc. -** VerifyUserPB also determines if the search includes files and/or -** directories, and determines if a full or partial name search was requested. -*/ -static OSErr VerifyUserPB(CSParamPtr userPB, - Boolean *includeFiles, - Boolean *includeDirs, - Boolean *includeNames) -{ - CInfoPBPtr searchInfo1; - CInfoPBPtr searchInfo2; - - searchInfo1 = userPB->ioSearchInfo1; - searchInfo2 = userPB->ioSearchInfo2; - - /* ioMatchPtr cannot be NULL */ - if ( userPB->ioMatchPtr == NULL ) - { - goto ParamErrExit; - } - - /* ioSearchInfo1 cannot be NULL */ - if ( searchInfo1 == NULL ) - { - goto ParamErrExit; - } - - /* If any bits except partialName, fullName, or negate are set, then */ - /* ioSearchInfo2 cannot be NULL because information in ioSearchInfo2 is required */ - if ( ((userPB->ioSearchBits & ~(fsSBPartialName | fsSBFullName | fsSBNegate)) != 0) && - ( searchInfo2 == NULL )) - { - goto ParamErrExit; - } - - *includeFiles = false; - *includeDirs = false; - *includeNames = false; - - if ( (userPB->ioSearchBits & (fsSBPartialName | fsSBFullName)) != 0 ) - { - /* If any kind of name matching is requested, then ioNamePtr in */ - /* ioSearchInfo1 cannot be NULL or a zero-length string */ - if ( (searchInfo1->hFileInfo.ioNamePtr == NULL) || - (searchInfo1->hFileInfo.ioNamePtr[0] == 0) || - (searchInfo1->hFileInfo.ioNamePtr[0] > (sizeof(Str63) - 1)) ) - { - goto ParamErrExit; - } - - *includeNames = true; - } - - if ( (userPB->ioSearchBits & fsSBFlAttrib) != 0 ) - { - /* The only attributes you can search on are the directory flag */ - /* and the locked flag. */ - if ( (searchInfo2->hFileInfo.ioFlAttrib & ~(ioDirMask | 0x01)) != 0 ) - { - goto ParamErrExit; - } - - /* interested in the directory bit? */ - if ( (searchInfo2->hFileInfo.ioFlAttrib & ioDirMask) != 0 ) - { - /* yes, so do they want just directories or just files? */ - if ( (searchInfo1->hFileInfo.ioFlAttrib & ioDirMask) != 0 ) - { - *includeDirs = true; - } - else - { - *includeFiles = true; - } - } - else - { - /* no interest in directory bit - get both files and directories */ - *includeDirs = true; - *includeFiles = true; - } - } - else - { - /* no attribute checking - get both files and directories */ - *includeDirs = true; - *includeFiles = true; - } - - /* If directories are included in the search, */ - /* then the locked attribute cannot be requested. */ - if ( *includeDirs && - ((userPB->ioSearchBits & fsSBFlAttrib) != 0) && - ((searchInfo2->hFileInfo.ioFlAttrib & 0x01) != 0) ) - { - goto ParamErrExit; - } - - /* If files are included in the search, then there cannot be */ - /* a search on the number of files. */ - if ( *includeFiles && - ((userPB->ioSearchBits & fsSBDrNmFls) != 0) ) - { - goto ParamErrExit; - } - - /* If directories are included in the search, then there cannot */ - /* be a search on file lengths. */ - if ( *includeDirs && - ((userPB->ioSearchBits & (fsSBFlLgLen | fsSBFlPyLen | fsSBFlRLgLen | fsSBFlRPyLen)) != 0) ) - { - goto ParamErrExit; - } - - return ( noErr ); - -ParamErrExit: - return ( paramErr ); -} - -/*****************************************************************************/ - -/* -** IsSubString checks to see if a string is a substring of another string. -** Both input strings have already been converted to all uppercase using -** UprString (the same non-international call the File Manager uses). -*/ -static Boolean IsSubString(ConstStr255Param aStringPtr, - ConstStr255Param subStringPtr) -{ - short strLength; /* length of string */ - short subStrLength; /* length of subString */ - Boolean found; /* result of test */ - short index; /* current index into string */ - - found = false; - strLength = aStringPtr[0]; - subStrLength = subStringPtr[0]; - - if ( subStrLength <= strLength) - { - register short count; /* search counter */ - register short strIndex; /* running index into string */ - register short subStrIndex; /* running index into subString */ - - /* start looking at first character */ - index = 1; - - /* continue looking until remaining string is shorter than substring */ - count = strLength - subStrLength + 1; - - do - { - strIndex = index; /* start string index at index */ - subStrIndex = 1; /* start subString index at 1 */ - - while ( !found && (aStringPtr[strIndex] == subStringPtr[subStrIndex]) ) - { - if ( subStrIndex == subStrLength ) - { - /* all characters in subString were found */ - found = true; - } - else - { - /* check next character of substring against next character of string */ - ++subStrIndex; - ++strIndex; - } - } - - if ( !found ) - { - /* start substring search again at next string character */ - ++index; - --count; - } - } while ( count != 0 && (!found) ); - } - - return ( found ); -} - -/*****************************************************************************/ - -/* -** CompareMasked does a bitwise comparison with mask on 1 or more longs. -** data1 and data2 are first exclusive-ORed together resulting with bits set -** where they are different. That value is then ANDed with the mask resulting -** with bits set if the test fails. true is returned if the tests pass. -*/ -static Boolean CompareMasked(const long *data1, - const long *data2, - const long *mask, - short longsToCompare) -{ - Boolean result = true; - - while ( (longsToCompare != 0) && (result == true) ) - { - /* (*data1 ^ *data2) = bits that are different, so... */ - /* ((*data1 ^ *data2) & *mask) = bits that are different that we're interested in */ - - if ( ((*data1 ^ *data2) & *mask) != 0 ) - result = false; - - ++data1; - ++data2; - ++mask; - --longsToCompare; - } - - return ( result ); -} - -/*****************************************************************************/ - -/* -** Check for matches compares the search criteria in userPB to the file -** system object in cPB. If there's a match, then the information in cPB is -** is added to the match array and the actual match count is incremented. -*/ -static void CheckForMatches(CInfoPBPtr cPB, - CSParamPtr userPB, - const Str63 matchName, - Boolean includeFiles, - Boolean includeDirs) -{ - long searchBits; - CInfoPBPtr searchInfo1; - CInfoPBPtr searchInfo2; - Str63 itemName; /* copy of object's name for partial name matching */ - Boolean foundMatch; - - foundMatch = false; /* default to no match */ - - searchBits = userPB->ioSearchBits; - searchInfo1 = userPB->ioSearchInfo1; - searchInfo2 = userPB->ioSearchInfo2; - - /* Into the if statements that go on forever... */ - - if ( (cPB->hFileInfo.ioFlAttrib & ioDirMask) == 0 ) - { - if (!includeFiles) - { - goto Failed; - } - } - else - { - if (!includeDirs) - { - goto Failed; - } - } - - if ( (searchBits & fsSBPartialName) != 0 ) - { - if ( (cPB->hFileInfo.ioNamePtr[0] > 0) && - (cPB->hFileInfo.ioNamePtr[0] <= (sizeof(Str63) - 1)) ) - { - /* Make uppercase copy of object name */ - BlockMoveData(cPB->hFileInfo.ioNamePtr, - itemName, - cPB->hFileInfo.ioNamePtr[0] + 1); - /* Use the same non-international call the File Manager uses */ - UpperString(itemName, true); - } - else - { - goto Failed; - } - - { - if ( !IsSubString(itemName, matchName) ) - { - goto Failed; - } - else if ( searchBits == fsSBPartialName ) - { - /* optimize for name matching only since it is most common way to search */ - goto Hit; - } - } - } - - if ( (searchBits & fsSBFullName) != 0 ) - { - /* Use the same non-international call the File Manager uses */ - if ( !EqualString(cPB->hFileInfo.ioNamePtr, matchName, false, true) ) - { - goto Failed; - } - else if ( searchBits == fsSBFullName ) - { - /* optimize for name matching only since it is most common way to search */ - goto Hit; - } - } - - if ( (searchBits & fsSBFlParID) != 0 ) - { - if ( ((unsigned long)(cPB->hFileInfo.ioFlParID) < (unsigned long)(searchInfo1->hFileInfo.ioFlParID)) || - ((unsigned long)(cPB->hFileInfo.ioFlParID) > (unsigned long)(searchInfo2->hFileInfo.ioFlParID)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlAttrib) != 0 ) - { - if ( ((cPB->hFileInfo.ioFlAttrib ^ searchInfo1->hFileInfo.ioFlAttrib) & - searchInfo2->hFileInfo.ioFlAttrib) != 0 ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBDrNmFls) != 0 ) - { - if ( ((unsigned long)(cPB->dirInfo.ioDrNmFls) < (unsigned long)(searchInfo1->dirInfo.ioDrNmFls)) || - ((unsigned long)(cPB->dirInfo.ioDrNmFls) > (unsigned long)(searchInfo2->dirInfo.ioDrNmFls)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlFndrInfo) != 0 ) /* fsSBFlFndrInfo is same as fsSBDrUsrWds */ - { - if ( !CompareMasked((long *)&(cPB->hFileInfo.ioFlFndrInfo), - (long *)&(searchInfo1->hFileInfo.ioFlFndrInfo), - (long *)&(searchInfo2->hFileInfo.ioFlFndrInfo), - sizeof(FInfo) / sizeof(long)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlXFndrInfo) != 0 ) /* fsSBFlXFndrInfo is same as fsSBDrFndrInfo */ - { - if ( !CompareMasked((long *)&(cPB->hFileInfo.ioFlXFndrInfo), - (long *)&(searchInfo1->hFileInfo.ioFlXFndrInfo), - (long *)&(searchInfo2->hFileInfo.ioFlXFndrInfo), - sizeof(FXInfo) / sizeof(long)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlLgLen) != 0 ) - { - if ( ((unsigned long)(cPB->hFileInfo.ioFlLgLen) < (unsigned long)(searchInfo1->hFileInfo.ioFlLgLen)) || - ((unsigned long)(cPB->hFileInfo.ioFlLgLen) > (unsigned long)(searchInfo2->hFileInfo.ioFlLgLen)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlPyLen) != 0 ) - { - if ( ((unsigned long)(cPB->hFileInfo.ioFlPyLen) < (unsigned long)(searchInfo1->hFileInfo.ioFlPyLen)) || - ((unsigned long)(cPB->hFileInfo.ioFlPyLen) > (unsigned long)(searchInfo2->hFileInfo.ioFlPyLen)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlRLgLen) != 0 ) - { - if ( ((unsigned long)(cPB->hFileInfo.ioFlRLgLen) < (unsigned long)(searchInfo1->hFileInfo.ioFlRLgLen)) || - ((unsigned long)(cPB->hFileInfo.ioFlRLgLen) > (unsigned long)(searchInfo2->hFileInfo.ioFlRLgLen)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlRPyLen) != 0 ) - { - if ( ((unsigned long)(cPB->hFileInfo.ioFlRPyLen) < (unsigned long)(searchInfo1->hFileInfo.ioFlRPyLen)) || - ((unsigned long)(cPB->hFileInfo.ioFlRPyLen) > (unsigned long)(searchInfo2->hFileInfo.ioFlRPyLen)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlCrDat) != 0 ) /* fsSBFlCrDat is same as fsSBDrCrDat */ - { - if ( ((unsigned long)(cPB->hFileInfo.ioFlCrDat) < (unsigned long)(searchInfo1->hFileInfo.ioFlCrDat)) || - ((unsigned long)(cPB->hFileInfo.ioFlCrDat) > (unsigned long)(searchInfo2->hFileInfo.ioFlCrDat)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlMdDat) != 0 ) /* fsSBFlMdDat is same as fsSBDrMdDat */ - { - if ( ((unsigned long)(cPB->hFileInfo.ioFlMdDat) < (unsigned long)(searchInfo1->hFileInfo.ioFlMdDat)) || - ((unsigned long)(cPB->hFileInfo.ioFlMdDat) > (unsigned long)(searchInfo2->hFileInfo.ioFlMdDat)) ) - { - goto Failed; - } - } - - if ( (searchBits & fsSBFlBkDat) != 0 ) /* fsSBFlBkDat is same as fsSBDrBkDat */ - { - if ( ((unsigned long)(cPB->hFileInfo.ioFlBkDat) < (unsigned long)(searchInfo1->hFileInfo.ioFlBkDat)) || - ((unsigned long)(cPB->hFileInfo.ioFlBkDat) > (unsigned long)(searchInfo2->hFileInfo.ioFlBkDat)) ) - { - goto Failed; - } - } - - /* Hey, we passed all of the tests! */ - -Hit: - foundMatch = true; - -/* foundMatch is false if code jumps to Failed */ -Failed: - /* Do we reverse our findings? */ - if ( (searchBits & fsSBNegate) != 0 ) - { - foundMatch = !foundMatch; /* matches are not, not matches are */ - } - - if ( foundMatch ) - { - - /* Move the match into the match buffer */ - userPB->ioMatchPtr[userPB->ioActMatchCount].vRefNum = cPB->hFileInfo.ioVRefNum; - userPB->ioMatchPtr[userPB->ioActMatchCount].parID = cPB->hFileInfo.ioFlParID; - if ( cPB->hFileInfo.ioNamePtr[0] > 63 ) - { - cPB->hFileInfo.ioNamePtr[0] = 63; - } - BlockMoveData(cPB->hFileInfo.ioNamePtr, - userPB->ioMatchPtr[userPB->ioActMatchCount].name, - cPB->hFileInfo.ioNamePtr[0] + 1); - - /* increment the actual count */ - ++(userPB->ioActMatchCount); - } -} - -/*****************************************************************************/ - -/* -** TimeOutTask is executed when the timer goes off. It simply sets the -** stopSearch field to true. After each object is found and possibly added -** to the matches buffer, stopSearch is checked to see if the search should -** continue. -*/ - -#if __WANTPASCALELIMINATION -#undef pascal -#endif -#if TARGET_CARBON -static pascal void TimeOutTask(TMTaskPtr tmTaskPtr) -{ - ((ExtendedTMTaskPtr)tmTaskPtr)->stopSearch = true; -} -#else -#if GENERATINGCFM - -static pascal void TimeOutTask(TMTaskPtr tmTaskPtr) -{ - ((ExtendedTMTaskPtr)tmTaskPtr)->stopSearch = true; -} - -#else - -static pascal TMTaskPtr GetTMTaskPtr(void) - ONEWORDINLINE(0x2e89); /* MOVE.L A1,(SP) */ - -static void TimeOutTask(void) -{ - ((ExtendedTMTaskPtr)GetTMTaskPtr())->stopSearch = true; -} -#endif -#endif - -#if __WANTPASCALELIMINATION -#define pascal -#endif - -/*****************************************************************************/ - -/* -** GetDirModDate returns the modification date of a directory. If there is -** an error getting the modification date, -1 is returned to indicate -** something went wrong. -*/ -static long GetDirModDate(short vRefNum, - long dirID) -{ - CInfoPBRec pb; - Str31 tempName; - long modDate; - - /* Protection against File Sharing problem */ - tempName[0] = 0; - pb.dirInfo.ioNamePtr = tempName; - pb.dirInfo.ioVRefNum = vRefNum; - pb.dirInfo.ioDrDirID = dirID; - pb.dirInfo.ioFDirIndex = -1; /* use ioDrDirID */ - - if ( PBGetCatInfoSync(&pb) == noErr ) - { - modDate = pb.dirInfo.ioDrMdDat; - } - else - { - modDate = -1; - } - - return ( modDate ); -} - -/*****************************************************************************/ - -pascal OSErr IndexedSearch(CSParamPtr pb, - long dirID) -{ - static LevelRecHandle searchStack = NULL; /* static handle to LevelRec stack */ - static Size searchStackSize = 0; /* size of static handle */ - SearchPositionRecPtr catPosition; - long modDate; - short index; - ExtendedTMTask timerTask; - OSErr result; - short realVRefNum; - Str63 itemName; - CInfoPBRec cPB; - long tempLong; - Boolean includeFiles; - Boolean includeDirs; - Boolean includeNames; - Str63 upperName; - - timerTask.stopSearch = false; /* don't stop yet! */ - - /* If request has a timeout, install a Time Manager task. */ - if ( pb->ioSearchTime != 0 ) - { - /* Start timer */ -#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) - timerTask.theTask.tmAddr = NewTimerUPP(TimeOutTask); -#else - timerTask.theTask.tmAddr = NewTimerProc(TimeOutTask); -#endif - InsTime((QElemPtr)&(timerTask.theTask)); - PrimeTime((QElemPtr)&(timerTask.theTask), pb->ioSearchTime); - } - - /* Check the parameter block passed for things that we don't want to assume */ - /* are OK later in the code. For example, make sure pointers to data structures */ - /* and buffers are not NULL. And while we're in there, see if the request */ - /* specified searching for files, directories, or both, and see if the search */ - /* was by full or partial name. */ - result = VerifyUserPB(pb, &includeFiles, &includeDirs, &includeNames); - if ( result == noErr ) - { - pb->ioActMatchCount = 0; /* no matches yet */ - - if ( includeNames ) - { - /* The search includes seach by full or partial name. */ - /* Make an upper case copy of the match string to pass to */ - /* CheckForMatches. */ - BlockMoveData(pb->ioSearchInfo1->hFileInfo.ioNamePtr, - upperName, - pb->ioSearchInfo1->hFileInfo.ioNamePtr[0] + 1); - /* Use the same non-international call the File Manager uses */ - UpperString(upperName, true); - } - - /* Prevent casting to my type throughout code */ - catPosition = (SearchPositionRecPtr)&pb->ioCatPosition; - - /* Create searchStack first time called */ - if ( searchStack == NULL ) - { - searchStack = (LevelRecHandle)NewHandle(kAdditionalLevelRecs * sizeof(LevelRec)); - } - - /* Make sure searchStack really exists */ - if ( searchStack != NULL ) - { -#if TARGET_CARBON - searchStackSize = GetHandleSize((Handle)searchStack); -#else - searchStackSize = InlineGetHandleSize((Handle)searchStack); -#endif - - /* See if the search is a new search or a resumed search. */ - if ( catPosition->initialize == 0 ) - { - /* New search. */ - - /* Get the real vRefNum and fill in catPosition->initialize. */ - result = CheckVol(pb->ioNamePtr, pb->ioVRefNum, &realVRefNum, &catPosition->initialize); - if ( result == noErr ) - { - /* clear searchStack */ - catPosition->stackDepth = 0; - - /* use dirID parameter passed and... */ - index = -1; /* start with the passed directory itself! */ - } - } - else - { - /* We're resuming a search. */ - - /* Get the real vRefNum and make sure catPosition->initialize is valid. */ - result = CheckVol(pb->ioNamePtr, pb->ioVRefNum, &realVRefNum, &tempLong); - if ( result == noErr ) - { - /* Make sure the resumed search is to the same volume! */ - if ( catPosition->initialize == tempLong ) - { - /* For resume, catPosition->stackDepth > 0 */ - if ( catPosition->stackDepth > 0 ) - { - /* Position catPosition->stackDepth to access last saved level */ - --(catPosition->stackDepth); - - /* Get the dirID and index for the next item */ - dirID = (*searchStack)[catPosition->stackDepth].dirID; - index = (*searchStack)[catPosition->stackDepth].index; - - /* Check the dir's mod date against the saved mode date on our "stack" */ - modDate = GetDirModDate(realVRefNum, dirID); - if ( modDate != (*searchStack)[catPosition->stackDepth].dirModDate ) - { - result = catChangedErr; - } - } - else - { - /* Invalid catPosition record was passed */ - result = paramErr; - } - } - else - { - /* The volume is not the same */ - result = catChangedErr; - } - } - } - - if ( result == noErr ) - { - /* ioNamePtr and ioVRefNum only need to be set up once. */ - cPB.hFileInfo.ioNamePtr = itemName; - cPB.hFileInfo.ioVRefNum = realVRefNum; - - /* - ** Here's the loop that: - ** Finds the next item on the volume. - ** If noErr, calls the code to check for matches and add matches - ** to the match buffer. - ** Sets up dirID and index for to find the next item on the volume. - ** - ** The looping ends when: - ** (a) an unexpected error is returned by PBGetCatInfo. All that - ** is expected is noErr and fnfErr (after the last item in a - ** directory is found). - ** (b) the caller specified a timeout and our Time Manager task - ** has fired. - ** (c) the number of matches requested by the caller has been found. - ** (d) the last item on the volume was found. - */ - do - { - /* get the next item */ - cPB.hFileInfo.ioFDirIndex = index; - cPB.hFileInfo.ioDirID = dirID; - result = PBGetCatInfoSync(&cPB); - if ( index != -1 ) - { - if ( result == noErr ) - { - /* We found something */ - - CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs); - - ++index; - if ( (cPB.dirInfo.ioFlAttrib & ioDirMask) != 0 ) - { - /* It's a directory */ - - result = CheckStack(catPosition->stackDepth, searchStack, &searchStackSize); - if ( result == noErr ) - { - /* Save the current state on the searchStack */ - /* when we come back, this is where we'll start */ - (*searchStack)[catPosition->stackDepth].dirID = dirID; - (*searchStack)[catPosition->stackDepth].index = index; - (*searchStack)[catPosition->stackDepth].dirModDate = GetDirModDate(realVRefNum, dirID); - - /* position catPosition->stackDepth for next saved level */ - ++(catPosition->stackDepth); - - /* The next item to get is the 1st item in the child directory */ - dirID = cPB.dirInfo.ioDrDirID; - index = 1; - } - } - /* else do nothing for files */ - } - else - { - /* End of directory found (or we had some error and that */ - /* means we have to drop out of this directory). */ - /* Restore last thing put on stack and */ - /* see if we need to continue or quit. */ - if ( catPosition->stackDepth > 0 ) - { - /* position catPosition->stackDepth to access last saved level */ - --(catPosition->stackDepth); - - dirID = (*searchStack)[catPosition->stackDepth].dirID; - index = (*searchStack)[catPosition->stackDepth].index; - - /* Check the dir's mod date against the saved mode date on our "stack" */ - modDate = GetDirModDate(realVRefNum, dirID); - if ( modDate != (*searchStack)[catPosition->stackDepth].dirModDate ) - { - result = catChangedErr; - } - else - { - /* Going back to ancestor directory. */ - /* Clear error so we can continue. */ - result = noErr; - } - } - else - { - /* We hit the bottom of the stack, so we'll let the */ - /* the eofErr drop us out of the loop. */ - result = eofErr; - } - } - } - else - { - /* Special case for index == -1; that means that we're starting */ - /* a new search and so the first item to check is the directory */ - /* passed to us. */ - if ( result == noErr ) - { - /* We found something */ - - CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs); - - /* Now, set the index to 1 and then we're ready to look inside */ - /* the passed directory. */ - index = 1; - } - } - } while ( (!timerTask.stopSearch) && /* timer hasn't fired */ - (result == noErr) && /* no unexpected errors */ - (pb->ioReqMatchCount > pb->ioActMatchCount) ); /* we haven't found our limit */ - - /* Did we drop out of the loop because of timeout or */ - /* ioReqMatchCount was found? */ - if ( result == noErr ) - { - result = CheckStack(catPosition->stackDepth, searchStack, &searchStackSize); - if ( result == noErr ) - { - /* Either there was a timeout or ioReqMatchCount was reached. */ - /* Save the dirID and index for the next time we're called. */ - - (*searchStack)[catPosition->stackDepth].dirID = dirID; - (*searchStack)[catPosition->stackDepth].index = index; - (*searchStack)[catPosition->stackDepth].dirModDate = GetDirModDate(realVRefNum, dirID); - - /* position catPosition->stackDepth for next saved level */ - - ++(catPosition->stackDepth); - } - } - } - } - else - { - /* searchStack Handle could not be allocated */ - result = memFullErr; - } - } - - if ( pb->ioSearchTime != 0 ) - { - /* Stop Time Manager task here if it was installed */ - RmvTime((QElemPtr)&(timerTask.theTask)); - DisposeTimerUPP(timerTask.theTask.tmAddr); - } - - return ( result ); -} - -/*****************************************************************************/ - -pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock) -{ - static Boolean fullExtFSDispatchingtested = false; - static Boolean hasFullExtFSDispatching = false; - OSErr result; - Boolean supportsCatSearch; - long response; - GetVolParmsInfoBuffer volParmsInfo; - long infoSize; - - result = noErr; - - /* See if File Manager will pass CatSearch requests to external file systems */ - /* we'll store the results in a static variable so we don't have to call Gestalt */ - /* everytime we're called. */ - if ( !fullExtFSDispatchingtested ) - { - fullExtFSDispatchingtested = true; - if ( Gestalt(gestaltFSAttr, &response) == noErr ) - { - hasFullExtFSDispatching = ((response & (1L << gestaltFullExtFSDispatching)) != 0); - } - } - - /* CatSearch is a per volume attribute, so we have to check each time we're */ - /* called to see if it is available on the volume specified. */ - supportsCatSearch = false; - if ( hasFullExtFSDispatching ) - { - infoSize = sizeof(GetVolParmsInfoBuffer); - result = HGetVolParms(paramBlock->ioNamePtr, paramBlock->ioVRefNum, - &volParmsInfo, &infoSize); - if ( result == noErr ) - { - supportsCatSearch = hasCatSearch(volParmsInfo); - } - } - - /* noErr or paramErr is OK here. */ - /* paramErr just means that GetVolParms isn't supported by this volume */ - if ( (result == noErr) || (result == paramErr) ) - { - if ( supportsCatSearch ) - { - /* Volume supports CatSearch so use it. */ - /* CatSearch is faster than an indexed search. */ - result = PBCatSearchSync(paramBlock); - } - else - { - /* Volume doesn't support CatSearch so */ - /* search using IndexedSearch from root directory. */ - result = IndexedSearch(paramBlock, fsRtDirID); - } - } - - return ( result ); -} - -/*****************************************************************************/ - -pascal OSErr NameFileSearch(ConstStr255Param volName, - short vRefNum, - ConstStr255Param fileName, - FSSpecPtr matches, - long reqMatchCount, - long *actMatchCount, - Boolean newSearch, - Boolean partial) -{ - CInfoPBRec searchInfo1, searchInfo2; - HParamBlockRec pb; - OSErr error; - static CatPositionRec catPosition; - static short lastVRefNum = 0; - - /* get the real volume reference number */ - error = DetermineVRefNum(volName, vRefNum, &vRefNum); - if ( error != noErr ) - return ( error ); - - pb.csParam.ioNamePtr = NULL; - pb.csParam.ioVRefNum = vRefNum; - pb.csParam.ioMatchPtr = matches; - pb.csParam.ioReqMatchCount = reqMatchCount; - if ( partial ) /* tell CatSearch what we're looking for: */ - { - pb.csParam.ioSearchBits = fsSBPartialName + fsSBFlAttrib; /* partial name file matches or */ - } - else - { - pb.csParam.ioSearchBits = fsSBFullName + fsSBFlAttrib; /* full name file matches */ - } - pb.csParam.ioSearchInfo1 = &searchInfo1; - pb.csParam.ioSearchInfo2 = &searchInfo2; - pb.csParam.ioSearchTime = 0; - if ( (newSearch) || /* If caller specified new search */ - (lastVRefNum != vRefNum) ) /* or if last search was to another volume, */ - { - catPosition.initialize = 0; /* then search from beginning of catalog */ - } - pb.csParam.ioCatPosition = catPosition; - pb.csParam.ioOptBuffer = GetTempBuffer(0x00004000, &pb.csParam.ioOptBufSize); - - /* search for fileName */ - searchInfo1.hFileInfo.ioNamePtr = (StringPtr)fileName; - searchInfo2.hFileInfo.ioNamePtr = NULL; - - /* only match files (not directories) */ - searchInfo1.hFileInfo.ioFlAttrib = 0x00; - searchInfo2.hFileInfo.ioFlAttrib = ioDirMask; - - error = PBCatSearchSyncCompat((CSParamPtr)&pb); - - if ( (error == noErr) || /* If no errors or the end of catalog was */ - (error == eofErr) ) /* found, then the call was successful so */ - { - *actMatchCount = pb.csParam.ioActMatchCount; /* return the match count */ - } - else - { - *actMatchCount = 0; /* else no matches found */ - } - - if ( (error == noErr) || /* If no errors */ - (error == catChangedErr) ) /* or there was a change in the catalog */ - { - catPosition = pb.csParam.ioCatPosition; - lastVRefNum = vRefNum; - /* we can probably start the next search where we stopped this time */ - } - else - { - catPosition.initialize = 0; - /* start the next search from beginning of catalog */ - } - - if ( pb.csParam.ioOptBuffer != NULL ) - { - DisposePtr(pb.csParam.ioOptBuffer); - } - - return ( error ); -} - -/*****************************************************************************/ - -pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, - short vRefNum, - OSType creator, - OSType fileType, - FSSpecPtr matches, - long reqMatchCount, - long *actMatchCount, - Boolean newSearch) -{ - CInfoPBRec searchInfo1, searchInfo2; - HParamBlockRec pb; - OSErr error; - static CatPositionRec catPosition; - static short lastVRefNum = 0; - - /* get the real volume reference number */ - error = DetermineVRefNum(volName, vRefNum, &vRefNum); - if ( error != noErr ) - return ( error ); - - pb.csParam.ioNamePtr = NULL; - pb.csParam.ioVRefNum = vRefNum; - pb.csParam.ioMatchPtr = matches; - pb.csParam.ioReqMatchCount = reqMatchCount; - pb.csParam.ioSearchBits = fsSBFlAttrib + fsSBFlFndrInfo; /* Looking for finder info file matches */ - pb.csParam.ioSearchInfo1 = &searchInfo1; - pb.csParam.ioSearchInfo2 = &searchInfo2; - pb.csParam.ioSearchTime = 0; - if ( (newSearch) || /* If caller specified new search */ - (lastVRefNum != vRefNum) ) /* or if last search was to another volume, */ - { - catPosition.initialize = 0; /* then search from beginning of catalog */ - } - pb.csParam.ioCatPosition = catPosition; - pb.csParam.ioOptBuffer = GetTempBuffer(0x00004000, &pb.csParam.ioOptBufSize); - - /* no fileName */ - searchInfo1.hFileInfo.ioNamePtr = NULL; - searchInfo2.hFileInfo.ioNamePtr = NULL; - - /* only match files (not directories) */ - searchInfo1.hFileInfo.ioFlAttrib = 0x00; - searchInfo2.hFileInfo.ioFlAttrib = ioDirMask; - - /* search for creator; if creator = 0x00000000, ignore creator */ - searchInfo1.hFileInfo.ioFlFndrInfo.fdCreator = creator; - if ( creator == (OSType)0x00000000 ) - { - searchInfo2.hFileInfo.ioFlFndrInfo.fdCreator = (OSType)0x00000000; - } - else - { - searchInfo2.hFileInfo.ioFlFndrInfo.fdCreator = (OSType)0xffffffff; - } - - /* search for fileType; if fileType = 0x00000000, ignore fileType */ - searchInfo1.hFileInfo.ioFlFndrInfo.fdType = fileType; - if ( fileType == (OSType)0x00000000 ) - { - searchInfo2.hFileInfo.ioFlFndrInfo.fdType = (OSType)0x00000000; - } - else - { - searchInfo2.hFileInfo.ioFlFndrInfo.fdType = (OSType)0xffffffff; - } - - /* zero all other FInfo fields */ - searchInfo1.hFileInfo.ioFlFndrInfo.fdFlags = 0; - searchInfo1.hFileInfo.ioFlFndrInfo.fdLocation.v = 0; - searchInfo1.hFileInfo.ioFlFndrInfo.fdLocation.h = 0; - searchInfo1.hFileInfo.ioFlFndrInfo.fdFldr = 0; - - searchInfo2.hFileInfo.ioFlFndrInfo.fdFlags = 0; - searchInfo2.hFileInfo.ioFlFndrInfo.fdLocation.v = 0; - searchInfo2.hFileInfo.ioFlFndrInfo.fdLocation.h = 0; - searchInfo2.hFileInfo.ioFlFndrInfo.fdFldr = 0; - - error = PBCatSearchSyncCompat((CSParamPtr)&pb); - - if ( (error == noErr) || /* If no errors or the end of catalog was */ - (error == eofErr) ) /* found, then the call was successful so */ - { - *actMatchCount = pb.csParam.ioActMatchCount; /* return the match count */ - } - else - { - *actMatchCount = 0; /* else no matches found */ - } - - if ( (error == noErr) || /* If no errors */ - (error == catChangedErr) ) /* or there was a change in the catalog */ - { - catPosition = pb.csParam.ioCatPosition; - lastVRefNum = vRefNum; - /* we can probably start the next search where we stopped this time */ - } - else - { - catPosition.initialize = 0; - /* start the next search from beginning of catalog */ - } - - if ( pb.csParam.ioOptBuffer != NULL ) - { - DisposePtr(pb.csParam.ioOptBuffer); - } - - return ( error ); -} - -/*****************************************************************************/ diff --git a/src/mac/morefile/mfsearch.h b/src/mac/morefile/mfsearch.h deleted file mode 100644 index 6bd1fdf261..0000000000 --- a/src/mac/morefile/mfsearch.h +++ /dev/null @@ -1,246 +0,0 @@ -/* -** Apple Macintosh Developer Technical Support -** -** IndexedSearch and the PBCatSearch compatibility function. -** -** by Jim Luther, Apple Developer Technical Support Emeritus -** -** File: Search.h -** -** Copyright © 1992-1998 Apple Computer, Inc. -** All rights reserved. -** -** 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 __SEARCH__ -#define __SEARCH__ - -#include -#include - -#include "optim.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************************/ - -pascal OSErr IndexedSearch(CSParamPtr pb, - long dirID); -/* ¦ Search in and below a directory. - The IndexedSearch function performs an indexed search in and below the - specified directory using the same parameters (in pb) as is passed to - PBCatSearch. See Inside Macintosh: Files for a description of the - parameter block. - - pb input: A CSParamPtr record specifying the volume to search - and the search criteria. - output: Fields in the parameter block are returned indicating - the number of matches found, the matches, and if the - search ended with noErr, the CatPosition record that - lets you resume a search where the last search left - off. - dirID input: The directory to search. If fsRtDirID is passed, - the entire volume is searched. - - Note: If you use a high-level debugger and use ioSearchTime to limit - the length of time to run the search, you'll want to step over - calls to IndexedSearch because it installs a Time Manager task. - Most high-level debuggers don't deal gracefully with interrupt - driven code. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - eofErr -39 End of catalog found (this is normal!) - paramErr -50 Parameter block has invalid parameters - (see source for VerifyUserPB) or - invalid catPosition record was passed - extFSErr -58 External file system error - no file - system claimed this call. - memFullErr -108 Memory could not be allocated in heap - catChangedErr -1304 Catalog has changed and catalog position - record may be invalid - - __________ - - See also: PBCatSearch, PBCatSearchSyncCompat -*/ - -/*****************************************************************************/ - -pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock); -/* ¦ Search a volume using PBCatSearch or IndexedSearch. - The PBCatSearchSyncCompat function uses PBCatSearch (if available) or - IndexedSearch (if PBCatSearch is not available) to search a volume - using a set of search criteria that you specify. It builds a list of all - files or directories that meet your specifications. - - pb input: A CSParamPtr record specifying the volume to search - and the search criteria. - output: Fields in the parameter block are returned indicating - the number of matches found, the matches, and if the - search ended with noErr, the CatPosition record that - lets you resume a search where the last search left - off. - - Note: If you use a high-level debugger and use ioSearchTime to limit - the length of time to run the search, you'll want to step over - calls to PBCatSearchSyncCompat because it calls IndexedSearch - which installs a Time Manager task. Most high-level debuggers - don't deal gracefully with interrupt driven code. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - eofErr -39 End of catalog found (this is normal!) - paramErr -50 Parameter block has invalid parameters - (see source for VerifyUserPB) or - invalid catPosition record was passed - extFSErr -58 External file system error - no file - system claimed this call. - memFullErr -108 Memory could not be allocated in heap - catChangedErr -1304 Catalog has changed and catalog position - record may be invalid - afpCatalogChanged -5037 Catalog has changed and search cannot - be resumed - - __________ - - See also: PBCatSearch, IndexedSearch -*/ - -/*****************************************************************************/ - -pascal OSErr NameFileSearch(ConstStr255Param volName, - short vRefNum, - ConstStr255Param fileName, - FSSpecPtr matches, - long reqMatchCount, - long *actMatchCount, - Boolean newSearch, - Boolean partial); -/* ¦ Search for files by file name with PBCatSearch. - The NameFileSearch function searches for files with a specific file - name on a volume that supports PBCatSearch. - Note: A result of catChangedErr means the catalog has changed between - searches, but the search can be continued with the possiblity that you - may miss some matches or get duplicate matches. For all other results - (except for noErr), the search cannot be continued. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - fileName input: The name of the file to search for. - matches input: Pointer to array of FSSpec where the match list is - returned. - reqMatchCount input: Maximum number of matches to return (the number of - elements in the matches array). - actMatchCount output: The number of matches actually returned. - newSearch input: If true, start a new search. If false and if - vRefNum is the same as the last call to - NameFileSearch, then start searching at the - position where the last search left off. - partial input: If the partial parameter is false, then only files - that exactly match fileName will be found. If the - partial parameter is true, then all file names that - contain fileName will be found. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - eofErr -39 End of catalog found (this is normal!) - paramErr -50 Parameter block has invalid parameters - (see source for VerifyUserPB) or - invalid catPosition record was passed - extFSErr -58 External file system error - no file - system claimed this call. - memFullErr -108 Memory could not be allocated in heap - catChangedErr -1304 Catalog has changed and catalog position - record may be invalid - afpCatalogChanged -5037 Catalog has changed and search cannot - be resumed - - __________ - - Also see: CreatorTypeFileSearch -*/ - -/*****************************************************************************/ - -pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName, - short vRefNum, - OSType creator, - OSType fileType, - FSSpecPtr matches, - long reqMatchCount, - long *actMatchCount, - Boolean newSearch); -/* ¦ Search for files by creator/fileType with PBCatSearch. - The CreatorTypeFileSearch function searches for files with a specific - creator or fileType on a volume that supports PBCatSearch. - Note: A result of catChangedErr means the catalog has changed between - searches, but the search can be continued with the possiblity that you - may miss some matches or get duplicate matches. For all other results - (except for noErr), the search cannot be continued. - - volName input: A pointer to the name of a mounted volume - or nil. - vRefNum input: Volume specification. - creator input: The creator type of the file to search for. - To ignore the creator type, pass 0x00000000 in - this field. - fileType input: The file type of the file to search for. - To ignore the file type, pass 0x00000000 in - this field. - matches input: Pointer to array of FSSpec where the match list is - returned. - reqMatchCount input: Maximum number of matches to return (the number of - elements in the matches array). - actMatchCount output: The number of matches actually returned. - newSearch input: If true, start a new search. If false and if - vRefNum is the same as the last call to - CreatorTypeFileSearch, then start searching at the - position where the last search left off. - - Result Codes - noErr 0 No error - nsvErr -35 Volume not found - ioErr -36 I/O error - eofErr -39 End of catalog found (this is normal!) - paramErr -50 Parameter block has invalid parameters - (see source for VerifyUserPB) or - invalid catPosition record was passed - extFSErr -58 External file system error - no file - system claimed this call. - memFullErr -108 Memory could not be allocated in heap - catChangedErr -1304 Catalog has changed and catalog position - record may be invalid - afpCatalogChanged -5037 Catalog has changed and search cannot - be resumed - - __________ - - Also see: NameFileSearch -*/ - -/*****************************************************************************/ - -#ifdef __cplusplus -} -#endif - -#include "optimend.h" - -#endif /* __SEARCH__ */ diff --git a/src/mac/utils.cpp b/src/mac/utils.cpp index f234da7456..e490ce4583 100644 --- a/src/mac/utils.cpp +++ b/src/mac/utils.cpp @@ -28,8 +28,8 @@ #include #ifndef __DARWIN__ -# include "morefile.h" -# include "moreextr.h" + #include "MoreFiles.h" + #include "MoreFilesExtras.h" #endif #ifndef __DARWIN__ -- 2.47.2