new version 1.5.2 for morefiles
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11937 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -41,10 +41,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
#include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "fullpath.h"
|
|
||||||
#include "fspcompa.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -35,11 +35,8 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
#include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "fullpath.h"
|
|
||||||
#include "fspcompa.h"
|
|
||||||
#include "PLStringFuncs.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern bool gUseNavServices ;
|
extern bool gUseNavServices ;
|
||||||
|
@@ -28,8 +28,8 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
# include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
# include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
|
@@ -41,10 +41,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
#include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "fullpath.h"
|
|
||||||
#include "fspcompa.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -35,11 +35,8 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
#include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "fullpath.h"
|
|
||||||
#include "fspcompa.h"
|
|
||||||
#include "PLStringFuncs.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern bool gUseNavServices ;
|
extern bool gUseNavServices ;
|
||||||
|
@@ -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 <20> 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 <Types.h>
|
|
||||||
#include <Files.h>
|
|
||||||
|
|
||||||
#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);
|
|
||||||
/* <09> 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);
|
|
||||||
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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 <09>19 Driver does not respond to read requests
|
|
||||||
writErr <09>20 Driver does not respond to write requests
|
|
||||||
badUnitErr <09>21 Driver reference number does not
|
|
||||||
match unit table
|
|
||||||
unitEmptyErr <09>22 Driver reference number specifies a
|
|
||||||
nil handle in unit table
|
|
||||||
abortErr <09>27 Request aborted by KillIO
|
|
||||||
notOpenErr <09>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);
|
|
||||||
/* <09> 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 <09>19 Driver does not respond to read requests
|
|
||||||
writErr <09>20 Driver does not respond to write requests
|
|
||||||
badUnitErr <09>21 Driver reference number does not
|
|
||||||
match unit table
|
|
||||||
unitEmptyErr <09>22 Driver reference number specifies a
|
|
||||||
nil handle in unit table
|
|
||||||
abortErr <09>27 Request aborted by KillIO
|
|
||||||
notOpenErr <09>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);
|
|
||||||
/* <09> 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 <09>19 Driver does not respond to read requests
|
|
||||||
writErr <09>20 Driver does not respond to write requests
|
|
||||||
badUnitErr <09>21 Driver reference number does not
|
|
||||||
match unit table
|
|
||||||
unitEmptyErr <09>22 Driver reference number specifies a
|
|
||||||
nil handle in unit table
|
|
||||||
abortErr <09>27 Request aborted by KillIO
|
|
||||||
notOpenErr <09>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);
|
|
||||||
/* <09> 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 <09>19 Driver does not respond to read requests
|
|
||||||
writErr <09>20 Driver does not respond to write requests
|
|
||||||
badUnitErr <09>21 Driver reference number does not
|
|
||||||
match unit table
|
|
||||||
unitEmptyErr <09>22 Driver reference number specifies a
|
|
||||||
nil handle in unit table
|
|
||||||
abortErr <09>27 Request aborted by KillIO
|
|
||||||
notOpenErr <09>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__ */
|
|
@@ -1,37 +1,53 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: DirectoryCopy.c
|
||||||
**
|
|
||||||
** DirectoryCopy: A robust, general purpose directory copy routine.
|
Contains: A robust, general purpose directory copy routine.
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
Version: MoreFiles
|
||||||
**
|
|
||||||
** File: DirectoryCopy.c
|
Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
**
|
|
||||||
** Copyright © 1992-1998 Apple Computer, Inc.
|
You may incorporate this sample code into your applications without
|
||||||
** All rights reserved.
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
**
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
** You may incorporate this sample code into your applications without
|
not permitted to do is to redistribute the source as "DSC Sample Code"
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
after having made changes. If you're going to re-distribute the source,
|
||||||
** responsibility for its operation is 100% yours. However, what you are
|
we require that you make it clear in the source that the code was
|
||||||
** not permitted to do is to redistribute the source as "DSC Sample Code"
|
descended from Apple Sample Code, but that you've made changes.
|
||||||
** 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
|
File Ownership:
|
||||||
** descended from Apple Sample Code, but that you've made changes.
|
|
||||||
|
DRI: Apple Macintosh Developer Technical Support
|
||||||
|
|
||||||
|
Other Contact: Apple Macintosh Developer Technical Support
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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 <Types.h>
|
#include <MacTypes.h>
|
||||||
#include <Errors.h>
|
#include <MacErrors.h>
|
||||||
#include <Memory.h>
|
#include <MacMemory.h>
|
||||||
#include <Files.h>
|
#include <Files.h>
|
||||||
#include <Script.h>
|
#include <Script.h>
|
||||||
|
#include <Math64.h>
|
||||||
|
|
||||||
#define __COMPILINGMOREFILES
|
#define __COMPILINGMOREFILES
|
||||||
|
|
||||||
#include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "moredesk.h"
|
#include "MoreDesktopMgr.h"
|
||||||
#include "filecopy.h"
|
#include "FileCopy.h"
|
||||||
#include "director.h"
|
#include "DirectoryCopy.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
@@ -53,13 +69,8 @@ enum
|
|||||||
** global information that might be needed at any time. */
|
** global information that might be needed at any time. */
|
||||||
|
|
||||||
#if PRAGMA_STRUCT_ALIGN
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=mac68k
|
#pragma options align=mac68k
|
||||||
#elif PRAGMA_STRUCT_PACKPUSH
|
|
||||||
#pragma pack(push, 2)
|
|
||||||
#elif PRAGMA_STRUCT_PACK
|
|
||||||
#pragma pack(2)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct EnumerateGlobals
|
struct EnumerateGlobals
|
||||||
{
|
{
|
||||||
Ptr copyBuffer; /* pointer to buffer used for file copy operations */
|
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 */
|
CInfoPBRec myCPB; /* the parameter block used for PBGetCatInfo calls */
|
||||||
};
|
};
|
||||||
#if PRAGMA_STRUCT_ALIGN
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=reset
|
#pragma options align=reset
|
||||||
#elif PRAGMA_STRUCT_PACKPUSH
|
|
||||||
#pragma pack(pop)
|
|
||||||
#elif PRAGMA_STRUCT_PACK
|
|
||||||
#pragma pack()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct EnumerateGlobals EnumerateGlobals;
|
typedef struct EnumerateGlobals EnumerateGlobals;
|
||||||
@@ -89,13 +96,8 @@ typedef EnumerateGlobals *EnumerateGlobalsPtr;
|
|||||||
** global information that might be needed at any time. */
|
** global information that might be needed at any time. */
|
||||||
|
|
||||||
#if PRAGMA_STRUCT_ALIGN
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=mac68k
|
#pragma options align=mac68k
|
||||||
#elif PRAGMA_STRUCT_PACKPUSH
|
|
||||||
#pragma pack(push, 2)
|
|
||||||
#elif PRAGMA_STRUCT_PACK
|
|
||||||
#pragma pack(2)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct PreflightGlobals
|
struct PreflightGlobals
|
||||||
{
|
{
|
||||||
OSErr result; /* temporary holder of results - saves 2 bytes of stack each level */
|
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 */
|
CopyFilterProcPtr copyFilterProc; /* pointer to filter function */
|
||||||
};
|
};
|
||||||
#if PRAGMA_STRUCT_ALIGN
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=reset
|
#pragma options align=reset
|
||||||
#elif PRAGMA_STRUCT_PACKPUSH
|
|
||||||
#pragma pack(pop)
|
|
||||||
#elif PRAGMA_STRUCT_PACK
|
|
||||||
#pragma pack()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct PreflightGlobals PreflightGlobals;
|
typedef struct PreflightGlobals PreflightGlobals;
|
||||||
@@ -157,7 +155,7 @@ static void GetLevelSize(long currentDirID,
|
|||||||
CallCopyFilterProc(theGlobals->copyFilterProc, &theGlobals->myCPB) ) /* filter if filter proc was supplied */
|
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 */
|
/* 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 */
|
/* we have a directory */
|
||||||
|
|
||||||
@@ -214,9 +212,6 @@ static void GetLevelSize(long currentDirID,
|
|||||||
} while ( theGlobals->result == noErr );
|
} while ( theGlobals->result == noErr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if !TARGET_CARBON
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static OSErr PreflightDirectoryCopySpace(short srcVRefNum,
|
static OSErr PreflightDirectoryCopySpace(short srcVRefNum,
|
||||||
@@ -234,8 +229,7 @@ static OSErr PreflightDirectoryCopySpace(short srcVRefNum,
|
|||||||
if ( error == noErr )
|
if ( error == noErr )
|
||||||
{
|
{
|
||||||
/* Convert freeBytes to free disk blocks (512-byte blocks) */
|
/* Convert freeBytes to free disk blocks (512-byte blocks) */
|
||||||
// dstFreeBlocks = (pb.ioVFreeBytes.hi << 23) + (pb.ioVFreeBytes.lo >> 9);
|
dstFreeBlocks = U32SetU(U64ShiftRight(pb.ioVFreeBytes, 9));
|
||||||
dstFreeBlocks = pb.ioVFreeBytes >> 9 ;
|
|
||||||
|
|
||||||
/* get allocation block size (always multiple of 512) and divide by 512
|
/* get allocation block size (always multiple of 512) and divide by 512
|
||||||
to get number of 512-byte blocks per allocation block */
|
to get number of 512-byte blocks per allocation block */
|
||||||
@@ -259,7 +253,7 @@ static OSErr PreflightDirectoryCopySpace(short srcVRefNum,
|
|||||||
|
|
||||||
return ( error );
|
return ( error );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void CopyLevel(long sourceDirID,
|
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 */
|
/* 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? */
|
/* 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 */
|
/* We have a directory */
|
||||||
|
|
||||||
@@ -425,6 +419,7 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum,
|
|||||||
short dstVRefNum,
|
short dstVRefNum,
|
||||||
long dstDirID,
|
long dstDirID,
|
||||||
ConstStr255Param dstName,
|
ConstStr255Param dstName,
|
||||||
|
ConstStr255Param copyName,
|
||||||
void *copyBufferPtr,
|
void *copyBufferPtr,
|
||||||
long copyBufferSize,
|
long copyBufferSize,
|
||||||
Boolean preflight,
|
Boolean preflight,
|
||||||
@@ -537,18 +532,26 @@ pascal OSErr FilteredDirectoryCopy(short srcVRefNum,
|
|||||||
error = GetDirName(dstVRefNum, fsRtDirID, oldDiskName);
|
error = GetDirName(dstVRefNum, fsRtDirID, oldDiskName);
|
||||||
if ( error == noErr )
|
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 */
|
/* Shorten the name if it's too long to be the volume name */
|
||||||
TruncPString(srcDirName, srcDirName, 27);
|
TruncPString(srcDirName, srcDirName, 27);
|
||||||
|
|
||||||
/* Rename the disk */
|
/* Rename the disk */
|
||||||
error = HRename(dstVRefNum, fsRtParID, oldDiskName, srcDirName);
|
error = HRename(dstVRefNum, fsRtParID, oldDiskName, srcDirName);
|
||||||
|
|
||||||
/* and copy to the root directory */
|
/* and copy to the root directory */
|
||||||
dstDirID = fsRtDirID;
|
dstDirID = fsRtDirID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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 )
|
if ( error != noErr )
|
||||||
{
|
{
|
||||||
@@ -629,6 +632,7 @@ pascal OSErr DirectoryCopy(short srcVRefNum,
|
|||||||
short dstVRefNum,
|
short dstVRefNum,
|
||||||
long dstDirID,
|
long dstDirID,
|
||||||
ConstStr255Param dstName,
|
ConstStr255Param dstName,
|
||||||
|
ConstStr255Param copyName,
|
||||||
void *copyBufferPtr,
|
void *copyBufferPtr,
|
||||||
long copyBufferSize,
|
long copyBufferSize,
|
||||||
Boolean preflight,
|
Boolean preflight,
|
||||||
@@ -636,6 +640,7 @@ pascal OSErr DirectoryCopy(short srcVRefNum,
|
|||||||
{
|
{
|
||||||
return ( FilteredDirectoryCopy(srcVRefNum, srcDirID, srcName,
|
return ( FilteredDirectoryCopy(srcVRefNum, srcDirID, srcName,
|
||||||
dstVRefNum, dstDirID, dstName,
|
dstVRefNum, dstDirID, dstName,
|
||||||
|
copyName,
|
||||||
copyBufferPtr, copyBufferSize, preflight,
|
copyBufferPtr, copyBufferSize, preflight,
|
||||||
copyErrHandler, NULL) );
|
copyErrHandler, NULL) );
|
||||||
}
|
}
|
||||||
@@ -644,6 +649,7 @@ pascal OSErr DirectoryCopy(short srcVRefNum,
|
|||||||
|
|
||||||
pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec,
|
pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec,
|
||||||
const FSSpec *dstSpec,
|
const FSSpec *dstSpec,
|
||||||
|
ConstStr255Param copyName,
|
||||||
void *copyBufferPtr,
|
void *copyBufferPtr,
|
||||||
long copyBufferSize,
|
long copyBufferSize,
|
||||||
Boolean preflight,
|
Boolean preflight,
|
||||||
@@ -652,6 +658,7 @@ pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec,
|
|||||||
{
|
{
|
||||||
return ( FilteredDirectoryCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
|
return ( FilteredDirectoryCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
|
||||||
dstSpec->vRefNum, dstSpec->parID, dstSpec->name,
|
dstSpec->vRefNum, dstSpec->parID, dstSpec->name,
|
||||||
|
copyName,
|
||||||
copyBufferPtr, copyBufferSize, preflight,
|
copyBufferPtr, copyBufferSize, preflight,
|
||||||
copyErrHandler, copyFilterProc) );
|
copyErrHandler, copyFilterProc) );
|
||||||
}
|
}
|
||||||
@@ -660,6 +667,7 @@ pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec,
|
|||||||
|
|
||||||
pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec,
|
pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec,
|
||||||
const FSSpec *dstSpec,
|
const FSSpec *dstSpec,
|
||||||
|
ConstStr255Param copyName,
|
||||||
void *copyBufferPtr,
|
void *copyBufferPtr,
|
||||||
long copyBufferSize,
|
long copyBufferSize,
|
||||||
Boolean preflight,
|
Boolean preflight,
|
||||||
@@ -667,6 +675,7 @@ pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec,
|
|||||||
{
|
{
|
||||||
return ( FilteredDirectoryCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
|
return ( FilteredDirectoryCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
|
||||||
dstSpec->vRefNum, dstSpec->parID, dstSpec->name,
|
dstSpec->vRefNum, dstSpec->parID, dstSpec->name,
|
||||||
|
copyName,
|
||||||
copyBufferPtr, copyBufferSize, preflight,
|
copyBufferPtr, copyBufferSize, preflight,
|
||||||
copyErrHandler, NULL) );
|
copyErrHandler, NULL) );
|
||||||
}
|
}
|
559
src/mac/morefile/DirectoryCopy.h
Normal file
559
src/mac/morefile/DirectoryCopy.h
Normal file
@@ -0,0 +1,559 @@
|
|||||||
|
/*
|
||||||
|
File: DirectoryCopy.h
|
||||||
|
|
||||||
|
Contains: A robust, general purpose directory copy routine.
|
||||||
|
|
||||||
|
Version: Technology: MoreFiles
|
||||||
|
Release: 1.5.2
|
||||||
|
|
||||||
|
Copyright: <20> 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 <MacTypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __FILES__
|
||||||
|
#include <Files.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Optimization.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if PRAGMA_ONCE
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_IMPORT
|
||||||
|
#pragma import on
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
|
#pragma options align=mac68k
|
||||||
|
#elif PRAGMA_STRUCT_PACKPUSH
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
#elif PRAGMA_STRUCT_PACK
|
||||||
|
#pragma pack(2)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
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 <20>19 Driver does not respond to read requests
|
||||||
|
writErr <20>20 Driver does not respond to write requests
|
||||||
|
badUnitErr <20>21 Driver reference number does not
|
||||||
|
match unit table
|
||||||
|
unitEmptyErr <20>22 Driver reference number specifies a
|
||||||
|
nil handle in unit table
|
||||||
|
abortErr <20>27 Request aborted by KillIO
|
||||||
|
notOpenErr <20>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 <20>19 Driver does not respond to read requests
|
||||||
|
writErr <20>20 Driver does not respond to write requests
|
||||||
|
badUnitErr <20>21 Driver reference number does not
|
||||||
|
match unit table
|
||||||
|
unitEmptyErr <20>22 Driver reference number specifies a
|
||||||
|
nil handle in unit table
|
||||||
|
abortErr <20>27 Request aborted by KillIO
|
||||||
|
notOpenErr <20>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 <20>19 Driver does not respond to read requests
|
||||||
|
writErr <20>20 Driver does not respond to write requests
|
||||||
|
badUnitErr <20>21 Driver reference number does not
|
||||||
|
match unit table
|
||||||
|
unitEmptyErr <20>22 Driver reference number specifies a
|
||||||
|
nil handle in unit table
|
||||||
|
abortErr <20>27 Request aborted by KillIO
|
||||||
|
notOpenErr <20>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 <20>19 Driver does not respond to read requests
|
||||||
|
writErr <20>20 Driver does not respond to write requests
|
||||||
|
badUnitErr <20>21 Driver reference number does not
|
||||||
|
match unit table
|
||||||
|
unitEmptyErr <20>22 Driver reference number specifies a
|
||||||
|
nil handle in unit table
|
||||||
|
abortErr <20>27 Request aborted by KillIO
|
||||||
|
notOpenErr <20>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__ */
|
||||||
|
|
@@ -1,488 +0,0 @@
|
|||||||
/*
|
|
||||||
** Apple Macintosh Developer Technical Support
|
|
||||||
**
|
|
||||||
** FSSpec compatibility functions.
|
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
|
||||||
**
|
|
||||||
** File: FSpCompat.h
|
|
||||||
**
|
|
||||||
** Copyright <20> 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 <Types.h>
|
|
||||||
#include <Files.h>
|
|
||||||
|
|
||||||
#include "optim.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
pascal OSErr FSMakeFSSpecCompat(short vRefNum,
|
|
||||||
long dirID,
|
|
||||||
ConstStr255Param fileName,
|
|
||||||
FSSpec *spec);
|
|
||||||
/* <09> 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<73>t exist
|
|
||||||
fnfErr -43 File or directory does not exist
|
|
||||||
(FSSpec is still valid)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
pascal OSErr FSpOpenDFCompat(const FSSpec *spec,
|
|
||||||
char permission,
|
|
||||||
short *refNum);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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 <09>35 No such volume
|
|
||||||
ioErr <09>36 I/O error
|
|
||||||
bdNamErr <09>37 Bad filename or volume name (perhaps zero
|
|
||||||
length)
|
|
||||||
eofErr <09>39 End of file
|
|
||||||
tmfoErr <09>42 Too many files open
|
|
||||||
fnfErr <09>43 File not found
|
|
||||||
opWrErr <09>49 File already open with write permission
|
|
||||||
permErr <09>54 Permissions error (on file open)
|
|
||||||
extFSErr <09>58 Volume belongs to an external file system
|
|
||||||
memFullErr <09>108 Not enough room in heap zone
|
|
||||||
dirNFErr <09>120 Directory not found
|
|
||||||
mapReadErr <09>199 Map inconsistent with operation
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
pascal void FSpCreateResFileCompat(const FSSpec *spec,
|
|
||||||
OSType creator,
|
|
||||||
OSType fileType,
|
|
||||||
ScriptCode scriptTag);
|
|
||||||
/* <09> 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 <09>33 Directory full
|
|
||||||
dskFulErr <09>34 Disk full
|
|
||||||
nsvErr <09>35 No such volume
|
|
||||||
ioErr <09>36 I/O error
|
|
||||||
bdNamErr <09>37 Bad filename or volume name (perhaps zero
|
|
||||||
length)
|
|
||||||
tmfoErr <09>42 Too many files open
|
|
||||||
wPrErrw <09>44 Disk is write-protected
|
|
||||||
fLckdErr <09>45 File is locked
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "optimend.h"
|
|
||||||
|
|
||||||
#endif /* __FSPCOMPAT__ */
|
|
||||||
|
|
@@ -1,22 +1,39 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: FSpCompat.c
|
||||||
**
|
|
||||||
** FSSpec compatibility functions.
|
Contains: FSSpec compatibility functions.
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
Version: MoreFiles
|
||||||
**
|
|
||||||
** File: FSpCompat.c
|
Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
**
|
|
||||||
** Copyright © 1992-1998 Apple Computer, Inc.
|
You may incorporate this sample code into your applications without
|
||||||
** All rights reserved.
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
**
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
** You may incorporate this sample code into your applications without
|
not permitted to do is to redistribute the source as "DSC Sample Code"
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
after having made changes. If you're going to re-distribute the source,
|
||||||
** responsibility for its operation is 100% yours. However, what you are
|
we require that you make it clear in the source that the code was
|
||||||
** not permitted to do is to redistribute the source as "DSC Sample Code"
|
descended from Apple Sample Code, but that you've made changes.
|
||||||
** 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
|
File Ownership:
|
||||||
** descended from Apple Sample Code, but that you've made changes.
|
|
||||||
|
DRI: Apple Macintosh Developer Technical Support
|
||||||
|
|
||||||
|
Other Contact: Apple Macintosh Developer Technical Support
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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
|
#define GENERATENODATA 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Types.h>
|
#include <MacTypes.h>
|
||||||
#include <Errors.h>
|
#include <MacErrors.h>
|
||||||
|
#include <Files.h>
|
||||||
#include <LowMem.h>
|
#include <LowMem.h>
|
||||||
#include <Gestalt.h>
|
#include <Gestalt.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
@@ -37,8 +55,8 @@
|
|||||||
|
|
||||||
#define __COMPILINGMOREFILES
|
#define __COMPILINGMOREFILES
|
||||||
|
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "fspcompa.h"
|
#include "FSpCompat.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
@@ -684,7 +702,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source,
|
|||||||
result2 = PBHGetVolParmsSync(&pb);
|
result2 = PBHGetVolParmsSync(&pb);
|
||||||
|
|
||||||
/* continue if volume has no fileID support (or no GetVolParms support) */
|
/* continue if volume has no fileID support (or no GetVolParms support) */
|
||||||
if ( (result2 == noErr) && hasFileIDs(volInfo) )
|
if ( (result2 == noErr) && hasFileIDs(&volInfo) )
|
||||||
{
|
{
|
||||||
goto errorExit3;
|
goto errorExit3;
|
||||||
}
|
}
|
||||||
@@ -701,7 +719,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source,
|
|||||||
{
|
{
|
||||||
goto errorExit3;
|
goto errorExit3;
|
||||||
}
|
}
|
||||||
if ( (catInfoSource.hFileInfo.ioFlAttrib & ioDirMask) != 0 )
|
if ( (catInfoSource.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
|
||||||
{
|
{
|
||||||
result = notAFileErr;
|
result = notAFileErr;
|
||||||
goto errorExit3;
|
goto errorExit3;
|
||||||
@@ -717,7 +735,7 @@ pascal OSErr FSpExchangeFilesCompat(const FSSpec *source,
|
|||||||
{
|
{
|
||||||
goto errorExit3;
|
goto errorExit3;
|
||||||
}
|
}
|
||||||
if ( (catInfoDest.hFileInfo.ioFlAttrib & ioDirMask) != 0 )
|
if ( (catInfoDest.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
|
||||||
{
|
{
|
||||||
result = notAFileErr;
|
result = notAFileErr;
|
||||||
goto errorExit3;
|
goto errorExit3;
|
586
src/mac/morefile/FSpCompat.h
Normal file
586
src/mac/morefile/FSpCompat.h
Normal file
@@ -0,0 +1,586 @@
|
|||||||
|
/*
|
||||||
|
File: FSpCompat.h
|
||||||
|
|
||||||
|
Contains: FSSpec compatibility functions.
|
||||||
|
|
||||||
|
Version: Technology: MoreFiles
|
||||||
|
Release: 1.5.2
|
||||||
|
|
||||||
|
Copyright: <20> 1992-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
|
|
||||||
|
Bugs?: For bug reports, consult the following page on
|
||||||
|
the World Wide Web:
|
||||||
|
|
||||||
|
http://developer.apple.com/bugreporter/
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
You may incorporate this sample code into your applications without
|
||||||
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
|
not permitted to do is to redistribute the source as "DSC Sample Code"
|
||||||
|
after having made changes. If you're going to re-distribute the source,
|
||||||
|
we require that you make it clear in the source that the code was
|
||||||
|
descended from Apple Sample Code, but that you've made changes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __FSPCOMPAT__
|
||||||
|
#define __FSPCOMPAT__
|
||||||
|
|
||||||
|
#ifndef __MACTYPES__
|
||||||
|
#include <MacTypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __FILES__
|
||||||
|
#include <Files.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Optimization.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if PRAGMA_ONCE
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_IMPORT
|
||||||
|
#pragma import on
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
|
#pragma options align=mac68k
|
||||||
|
#elif PRAGMA_STRUCT_PACKPUSH
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
#elif PRAGMA_STRUCT_PACK
|
||||||
|
#pragma pack(2)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
EXTERN_API( OSErr )
|
||||||
|
FSMakeFSSpecCompat(
|
||||||
|
short vRefNum,
|
||||||
|
long dirID,
|
||||||
|
ConstStr255Param fileName,
|
||||||
|
FSSpec * spec);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
The FSMakeFSSpecCompat function fills in the fields of an FSSpec record.
|
||||||
|
If the file system can't create the FSSpec, then the compatibility code
|
||||||
|
creates a FSSpec that is exactly like an FSSpec except that spec.name
|
||||||
|
for a file may not have the same capitalization as the file's catalog
|
||||||
|
entry on the disk volume. That is because fileName is parsed to get the
|
||||||
|
name instead of getting the name back from the file system. This works
|
||||||
|
fine with System 6 where FSMakeSpec isn't available.
|
||||||
|
|
||||||
|
vRefNum input: Volume specification.
|
||||||
|
dirID input: Directory ID.
|
||||||
|
fileName input: Pointer to object name, or nil when dirID specifies
|
||||||
|
a directory that's the object.
|
||||||
|
spec output: A file system specification to be filled in by
|
||||||
|
FSMakeFSSpecCompat.
|
||||||
|
|
||||||
|
Result Codes
|
||||||
|
noErr 0 No error
|
||||||
|
nsvErr -35 Volume doesn<73>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 <20>35 No such volume
|
||||||
|
ioErr <20>36 I/O error
|
||||||
|
bdNamErr <20>37 Bad filename or volume name (perhaps zero
|
||||||
|
length)
|
||||||
|
eofErr <20>39 End of file
|
||||||
|
tmfoErr <20>42 Too many files open
|
||||||
|
fnfErr <20>43 File not found
|
||||||
|
opWrErr <20>49 File already open with write permission
|
||||||
|
permErr <20>54 Permissions error (on file open)
|
||||||
|
extFSErr <20>58 Volume belongs to an external file system
|
||||||
|
memFullErr <20>108 Not enough room in heap zone
|
||||||
|
dirNFErr <20>120 Directory not found
|
||||||
|
mapReadErr <20>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 <20>33 Directory full
|
||||||
|
dskFulErr <20>34 Disk full
|
||||||
|
nsvErr <20>35 No such volume
|
||||||
|
ioErr <20>36 I/O error
|
||||||
|
bdNamErr <20>37 Bad filename or volume name (perhaps zero
|
||||||
|
length)
|
||||||
|
tmfoErr <20>42 Too many files open
|
||||||
|
wPrErrw <20>44 Disk is write-protected
|
||||||
|
fLckdErr <20>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__ */
|
||||||
|
|
@@ -1,36 +1,53 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: FileCopy.c
|
||||||
**
|
|
||||||
** FileCopy: A robust, general purpose file copy routine.
|
Contains: A robust, general purpose file copy routine.
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
Version: MoreFiles
|
||||||
**
|
|
||||||
** File: FileCopy.c
|
Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
**
|
|
||||||
** Copyright © 1992-1998 Apple Computer, Inc.
|
You may incorporate this sample code into your applications without
|
||||||
** All rights reserved.
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
**
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
** You may incorporate this sample code into your applications without
|
not permitted to do is to redistribute the source as "DSC Sample Code"
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
after having made changes. If you're going to re-distribute the source,
|
||||||
** responsibility for its operation is 100% yours. However, what you are
|
we require that you make it clear in the source that the code was
|
||||||
** not permitted to do is to redistribute the source as "DSC Sample Code"
|
descended from Apple Sample Code, but that you've made changes.
|
||||||
** 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
|
File Ownership:
|
||||||
** descended from Apple Sample Code, but that you've made changes.
|
|
||||||
|
DRI: Apple Macintosh Developer Technical Support
|
||||||
|
|
||||||
|
Other Contact: Apple Macintosh Developer Technical Support
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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 <Types.h>
|
#include <MacTypes.h>
|
||||||
#include <Errors.h>
|
#include <MacErrors.h>
|
||||||
#include <Memory.h>
|
#include <MacMemory.h>
|
||||||
#include <Files.h>
|
#include <Files.h>
|
||||||
#include <Math64.h>
|
#include <Math64.h>
|
||||||
|
|
||||||
#define __COMPILINGMOREFILES
|
#define __COMPILINGMOREFILES
|
||||||
|
|
||||||
#include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "moredesk.h"
|
#include "MoreDesktopMgr.h"
|
||||||
#include "filecopy.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 */
|
pb.dirInfo.ioACUser = 0; /* ioACUser used to be filler2, clear it before calling GetCatInfo */
|
||||||
error = GetCatInfoNoName(vRefNum, dirID, name, &pb);
|
error = GetCatInfoNoName(vRefNum, dirID, name, &pb);
|
||||||
*theDirID = pb.dirInfo.ioDrDirID;
|
*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) */
|
/* 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 );
|
return ( error );
|
||||||
}
|
}
|
||||||
@@ -161,8 +178,6 @@ static OSErr CheckForForks(short vRefNum,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#if !TARGET_CARBON
|
|
||||||
|
|
||||||
static OSErr PreflightFileCopySpace(short srcVRefNum,
|
static OSErr PreflightFileCopySpace(short srcVRefNum,
|
||||||
long srcDirID,
|
long srcDirID,
|
||||||
ConstStr255Param srcName,
|
ConstStr255Param srcName,
|
||||||
@@ -185,8 +200,7 @@ static OSErr PreflightFileCopySpace(short srcVRefNum,
|
|||||||
dstBlksPerAllocBlk = ((unsigned long)pb.xPB.ioVAlBlkSiz >> 9);
|
dstBlksPerAllocBlk = ((unsigned long)pb.xPB.ioVAlBlkSiz >> 9);
|
||||||
|
|
||||||
/* Convert freeBytes to free disk blocks (512-byte blocks) */
|
/* Convert freeBytes to free disk blocks (512-byte blocks) */
|
||||||
// dstFreeBlocks = (pb.xPB.ioVFreeBytes.hi << 23) + (pb.xPB.ioVFreeBytes.lo >> 9);
|
dstFreeBlocks = U32SetU(U64ShiftRight(pb.xPB.ioVFreeBytes, 9));
|
||||||
dstFreeBlocks = pb.xPB.ioVFreeBytes >> 9 ;
|
|
||||||
|
|
||||||
/* Now, get the size of the file's data resource forks */
|
/* Now, get the size of the file's data resource forks */
|
||||||
pb.hPB.fileParam.ioNamePtr = (StringPtr)srcName;
|
pb.hPB.fileParam.ioNamePtr = (StringPtr)srcName;
|
||||||
@@ -247,7 +261,7 @@ static OSErr PreflightFileCopySpace(short srcVRefNum,
|
|||||||
|
|
||||||
return ( error );
|
return ( error );
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
pascal OSErr FileCopy(short srcVRefNum,
|
pascal OSErr FileCopy(short srcVRefNum,
|
||||||
@@ -331,7 +345,7 @@ pascal OSErr FileCopy(short srcVRefNum,
|
|||||||
return ( err );
|
return ( err );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (err != paramErr) && hasCopyFile(infoBuffer) )
|
if ( (err != paramErr) && hasCopyFile(&infoBuffer) )
|
||||||
{
|
{
|
||||||
/* The source volume supports PBHCopyFile. */
|
/* The source volume supports PBHCopyFile. */
|
||||||
srcServerAdr = infoBuffer.vMServerAdr;
|
srcServerAdr = infoBuffer.vMServerAdr;
|
@@ -1,49 +1,81 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: FileCopy.h
|
||||||
**
|
|
||||||
** FileCopy: A robust, general purpose file copy routine.
|
Contains: A robust, general purpose file copy routine.
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
Version: Technology: MoreFiles
|
||||||
**
|
Release: 1.5.2
|
||||||
** File: FileCopy.h
|
|
||||||
**
|
Copyright: <20> 1992-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
** Copyright <20> 1992-1998 Apple Computer, Inc.
|
|
||||||
** All rights reserved.
|
Bugs?: For bug reports, consult the following page on
|
||||||
**
|
the World Wide Web:
|
||||||
** You may incorporate this sample code into your applications without
|
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
http://developer.apple.com/bugreporter/
|
||||||
** 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.
|
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__
|
#ifndef __FILECOPY__
|
||||||
#define __FILECOPY__
|
#define __FILECOPY__
|
||||||
|
|
||||||
#include <Types.h>
|
#ifndef __MACTYPES__
|
||||||
#include <Files.h>
|
#include <MacTypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "optim.h"
|
#ifndef __FILES__
|
||||||
|
#include <Files.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Optimization.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if PRAGMA_ONCE
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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,
|
EXTERN_API( OSErr )
|
||||||
|
FileCopy(
|
||||||
|
short srcVRefNum,
|
||||||
long srcDirID,
|
long srcDirID,
|
||||||
ConstStr255Param srcName,
|
ConstStr255Param srcName,
|
||||||
short dstVRefNum,
|
short dstVRefNum,
|
||||||
long dstDirID,
|
long dstDirID,
|
||||||
ConstStr255Param dstPathname,
|
ConstStr255Param dstPathname,
|
||||||
ConstStr255Param copyName,
|
ConstStr255Param copyName,
|
||||||
void *copyBufferPtr,
|
void * copyBufferPtr,
|
||||||
long copyBufferSize,
|
long copyBufferSize,
|
||||||
Boolean preflight);
|
Boolean preflight);
|
||||||
/* <09> Duplicate a file and optionally rename it.
|
|
||||||
|
|
||||||
|
/*
|
||||||
The FileCopy function duplicates a file and optionally renames it.
|
The FileCopy function duplicates a file and optionally renames it.
|
||||||
Since the PBHCopyFile routine is only available on some
|
Since the PBHCopyFile routine is only available on some
|
||||||
AFP server volumes under specific conditions, this routine
|
AFP server volumes under specific conditions, this routine
|
||||||
@@ -126,13 +158,17 @@ pascal OSErr FileCopy(short srcVRefNum,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
pascal OSErr FSpFileCopy(const FSSpec *srcSpec,
|
EXTERN_API( OSErr )
|
||||||
const FSSpec *dstSpec,
|
FSpFileCopy(
|
||||||
|
const FSSpec * srcSpec,
|
||||||
|
const FSSpec * dstSpec,
|
||||||
ConstStr255Param copyName,
|
ConstStr255Param copyName,
|
||||||
void *copyBufferPtr,
|
void * copyBufferPtr,
|
||||||
long copyBufferSize,
|
long copyBufferSize,
|
||||||
Boolean preflight);
|
Boolean preflight);
|
||||||
/* <09> Duplicate a file and optionally rename it.
|
|
||||||
|
|
||||||
|
/*
|
||||||
The FSpFileCopy function duplicates a file and optionally renames it.
|
The FSpFileCopy function duplicates a file and optionally renames it.
|
||||||
Since the PBHCopyFile routine is only available on some
|
Since the PBHCopyFile routine is only available on some
|
||||||
AFP server volumes under specific conditions, this routine
|
AFP server volumes under specific conditions, this routine
|
||||||
@@ -211,10 +247,25 @@ pascal OSErr FSpFileCopy(const FSSpec *srcSpec,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "optimend.h"
|
|
||||||
|
|
||||||
#endif /* __FILECOPY__ */
|
#endif /* __FILECOPY__ */
|
||||||
|
|
||||||
|
@@ -1,35 +1,50 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: FullPath.c
|
||||||
**
|
|
||||||
** Routines for dealing with full pathnames... if you really must.
|
Contains: Routines for dealing with full pathnames... if you really must.
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
Version: MoreFiles
|
||||||
**
|
|
||||||
** File: FullPath.c
|
Copyright: © 1995-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
**
|
|
||||||
** Copyright © 1995-1998 Apple Computer, Inc.
|
You may incorporate this sample code into your applications without
|
||||||
** All rights reserved.
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
**
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
** You may incorporate this sample code into your applications without
|
not permitted to do is to redistribute the source as "DSC Sample Code"
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
after having made changes. If you're going to re-distribute the source,
|
||||||
** responsibility for its operation is 100% yours. However, what you are
|
we require that you make it clear in the source that the code was
|
||||||
** not permitted to do is to redistribute the source as "DSC Sample Code"
|
descended from Apple Sample Code, but that you've made changes.
|
||||||
** 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
|
File Ownership:
|
||||||
** descended from Apple Sample Code, but that you've made changes.
|
|
||||||
|
DRI: Apple Macintosh Developer Technical Support
|
||||||
|
|
||||||
|
Other Contact: Apple Macintosh Developer Technical Support
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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 <Types.h>
|
#include <MacTypes.h>
|
||||||
#include <Errors.h>
|
#include <MacErrors.h>
|
||||||
#include <Memory.h>
|
#include <MacMemory.h>
|
||||||
#include <Files.h>
|
#include <Files.h>
|
||||||
#include <TextUtils.h>
|
#include <TextUtils.h>
|
||||||
#include <Aliases.h>
|
#include <Aliases.h>
|
||||||
|
|
||||||
#define __COMPILINGMOREFILES
|
#define __COMPILINGMOREFILES
|
||||||
|
|
||||||
#include "fspcompa.h"
|
#include "FSpCompat.h"
|
||||||
#include "fullpath.h"
|
#include "FullPath.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE:
|
IMPORTANT NOTE:
|
||||||
@@ -112,12 +127,23 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec,
|
|||||||
*fullPathLength = 0;
|
*fullPathLength = 0;
|
||||||
*fullPath = NULL;
|
*fullPath = NULL;
|
||||||
|
|
||||||
// Default to noErr
|
|
||||||
realResult = noErr;
|
|
||||||
|
|
||||||
|
/* Default to noErr */
|
||||||
|
realResult = result = noErr;
|
||||||
|
|
||||||
|
/* work around Nav Services "bug" (it returns invalid FSSpecs with empty names) */
|
||||||
|
if ( spec->name[0] == 0 )
|
||||||
|
{
|
||||||
|
result = FSMakeFSSpecCompat(spec->vRefNum, spec->parID, spec->name, &tempSpec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* Make a copy of the input FSSpec that can be modified */
|
/* Make a copy of the input FSSpec that can be modified */
|
||||||
BlockMoveData(spec, &tempSpec, sizeof(FSSpec));
|
BlockMoveData(spec, &tempSpec, sizeof(FSSpec));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( result == noErr )
|
||||||
|
{
|
||||||
if ( tempSpec.parID == fsRtParID )
|
if ( tempSpec.parID == fsRtParID )
|
||||||
{
|
{
|
||||||
/* The object is a volume */
|
/* The object is a volume */
|
||||||
@@ -144,7 +170,7 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec,
|
|||||||
if ( (result == noErr) || (result == fnfErr) )
|
if ( (result == noErr) || (result == fnfErr) )
|
||||||
{
|
{
|
||||||
/* if the object is a directory, append a colon so full pathname ends with colon */
|
/* if the object is a directory, append a colon so full pathname ends with colon */
|
||||||
if ( (result == noErr) && (pb.hFileInfo.ioFlAttrib & ioDirMask) != 0 )
|
if ( (result == noErr) && (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
|
||||||
{
|
{
|
||||||
++tempSpec.name[0];
|
++tempSpec.name[0];
|
||||||
tempSpec.name[tempSpec.name[0]] = ':';
|
tempSpec.name[tempSpec.name[0]] = ':';
|
||||||
@@ -177,14 +203,12 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( result == noErr )
|
if ( result == noErr )
|
||||||
{
|
{
|
||||||
/* Return the length */
|
/* Return the length */
|
||||||
#if TARGET_CARBON
|
|
||||||
*fullPathLength = GetHandleSize(*fullPath);
|
*fullPathLength = GetHandleSize(*fullPath);
|
||||||
#else
|
|
||||||
*fullPathLength = InlineGetHandleSize(*fullPath);
|
|
||||||
#endif
|
|
||||||
result = realResult; // return realResult in case it was fnfErr
|
result = realResult; // return realResult in case it was fnfErr
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -220,6 +244,14 @@ pascal OSErr FSpLocationFromFullPath(short fullPathLength,
|
|||||||
/* Let the Alias Manager resolve the alias. */
|
/* Let the Alias Manager resolve the alias. */
|
||||||
result = ResolveAlias(NULL, alias, spec, &wasChanged);
|
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 */
|
DisposeHandle((Handle)alias); /* Free up memory used */
|
||||||
}
|
}
|
||||||
return ( result );
|
return ( result );
|
@@ -1,35 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: FullPath.h
|
||||||
**
|
|
||||||
** Routines for dealing with full pathnames... if you really must.
|
Contains: Routines for dealing with full pathnames... if you really must.
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
Version: Technology: MoreFiles
|
||||||
**
|
Release: 1.5.2
|
||||||
** File: FullPath.h
|
|
||||||
**
|
Copyright: <20> 1995-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
** Copyright <20> 1995-1998 Apple Computer, Inc.
|
|
||||||
** All rights reserved.
|
Bugs?: For bug reports, consult the following page on
|
||||||
**
|
the World Wide Web:
|
||||||
** You may incorporate this sample code into your applications without
|
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
http://developer.apple.com/bugreporter/
|
||||||
** 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 __FULLPATH__
|
/*
|
||||||
#define __FULLPATH__
|
You may incorporate this sample code into your applications without
|
||||||
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
#include <Types.h>
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
#include <Files.h>
|
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,
|
||||||
#include "optim.h"
|
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.
|
||||||
#ifdef __cplusplus
|
*/
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
IMPORTANT NOTE:
|
IMPORTANT NOTE:
|
||||||
@@ -76,14 +70,52 @@ extern "C" {
|
|||||||
foreign file systems or under future system software versions.
|
foreign file systems or under future system software versions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef __FULLPATH__
|
||||||
|
#define __FULLPATH__
|
||||||
|
|
||||||
|
#ifndef __MACTYPES__
|
||||||
|
#include <MacTypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __FILES__
|
||||||
|
#include <Files.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Optimization.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if PRAGMA_ONCE
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_IMPORT
|
||||||
|
#pragma import on
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
|
#pragma options align=mac68k
|
||||||
|
#elif PRAGMA_STRUCT_PACKPUSH
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
#elif PRAGMA_STRUCT_PACK
|
||||||
|
#pragma pack(2)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
pascal OSErr GetFullPath(short vRefNum,
|
EXTERN_API( OSErr )
|
||||||
|
GetFullPath(
|
||||||
|
short vRefNum,
|
||||||
long dirID,
|
long dirID,
|
||||||
ConstStr255Param name,
|
ConstStr255Param name,
|
||||||
short *fullPathLength,
|
short * fullPathLength,
|
||||||
Handle *fullPath);
|
Handle * fullPath);
|
||||||
/* <09> Get a full pathname to a volume, directory or file.
|
|
||||||
|
|
||||||
|
/*
|
||||||
The GetFullPath function builds a full pathname to the specified
|
The GetFullPath function builds a full pathname to the specified
|
||||||
object. The full pathname is returned in the newly created handle
|
object. The full pathname is returned in the newly created handle
|
||||||
fullPath and the length of the full pathname is returned in
|
fullPath and the length of the full pathname is returned in
|
||||||
@@ -125,10 +157,14 @@ pascal OSErr GetFullPath(short vRefNum,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
pascal OSErr FSpGetFullPath(const FSSpec *spec,
|
EXTERN_API( OSErr )
|
||||||
short *fullPathLength,
|
FSpGetFullPath(
|
||||||
Handle *fullPath);
|
const FSSpec * spec,
|
||||||
/* <09> Get a full pathname to a volume, directory or file.
|
short * fullPathLength,
|
||||||
|
Handle * fullPath);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
The GetFullPath function builds a full pathname to the specified
|
The GetFullPath function builds a full pathname to the specified
|
||||||
object. The full pathname is returned in the newly created handle
|
object. The full pathname is returned in the newly created handle
|
||||||
fullPath and the length of the full pathname is returned in
|
fullPath and the length of the full pathname is returned in
|
||||||
@@ -139,6 +175,15 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec,
|
|||||||
yet exist if all directories up to that file/directory exist. In this case,
|
yet exist if all directories up to that file/directory exist. In this case,
|
||||||
FSpGetFullPath will return a fnfErr.
|
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.
|
spec input: An FSSpec record specifying the object.
|
||||||
fullPathLength output: The number of characters in the full pathname.
|
fullPathLength output: The number of characters in the full pathname.
|
||||||
If the function fails to create a full pathname,
|
If the function fails to create a full pathname,
|
||||||
@@ -167,10 +212,14 @@ pascal OSErr FSpGetFullPath(const FSSpec *spec,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
pascal OSErr FSpLocationFromFullPath(short fullPathLength,
|
EXTERN_API( OSErr )
|
||||||
const void *fullPath,
|
FSpLocationFromFullPath(
|
||||||
FSSpec *spec);
|
short fullPathLength,
|
||||||
/* <09> Get a FSSpec from a full pathname.
|
const void * fullPath,
|
||||||
|
FSSpec * spec);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
The FSpLocationFromFullPath function returns a FSSpec to the object
|
The FSpLocationFromFullPath function returns a FSSpec to the object
|
||||||
specified by full pathname. This function requires the Alias Manager.
|
specified by full pathname. This function requires the Alias Manager.
|
||||||
|
|
||||||
@@ -198,12 +247,16 @@ pascal OSErr FSpLocationFromFullPath(short fullPathLength,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
pascal OSErr LocationFromFullPath(short fullPathLength,
|
EXTERN_API( OSErr )
|
||||||
const void *fullPath,
|
LocationFromFullPath(
|
||||||
short *vRefNum,
|
short fullPathLength,
|
||||||
long *parID,
|
const void * fullPath,
|
||||||
|
short * vRefNum,
|
||||||
|
long * parID,
|
||||||
Str31 name);
|
Str31 name);
|
||||||
/* <09> Get an object's location from a full pathname.
|
|
||||||
|
|
||||||
|
/*
|
||||||
The LocationFromFullPath function returns the volume reference number,
|
The LocationFromFullPath function returns the volume reference number,
|
||||||
parent directory ID and name of the object specified by full pathname.
|
parent directory ID and name of the object specified by full pathname.
|
||||||
This function requires the Alias Manager.
|
This function requires the Alias Manager.
|
||||||
@@ -234,10 +287,25 @@ pascal OSErr LocationFromFullPath(short fullPathLength,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "optimend.h"
|
|
||||||
|
|
||||||
#endif /* __FULLPATH__ */
|
#endif /* __FULLPATH__ */
|
||||||
|
|
||||||
|
@@ -1,171 +0,0 @@
|
|||||||
/*
|
|
||||||
** IterateDirectory: File Manager directory iterator routines.
|
|
||||||
**
|
|
||||||
** by Jim Luther
|
|
||||||
**
|
|
||||||
** File: IterateDirectory.h
|
|
||||||
**
|
|
||||||
** Copyright <20> 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 <Types.h>
|
|
||||||
#include <Files.h>
|
|
||||||
|
|
||||||
#include "optim.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
typedef pascal void (*IterateFilterProcPtr) (const CInfoPBRec * const cpbPtr,
|
|
||||||
Boolean *quitFlag,
|
|
||||||
void *yourDataPtr);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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__ */
|
|
@@ -1,29 +1,47 @@
|
|||||||
/*
|
/*
|
||||||
** IterateDirectory: File Manager directory iterator routines.
|
File: IterateDirectory.c
|
||||||
**
|
|
||||||
** by Jim Luther
|
Contains: File Manager directory iterator routines.
|
||||||
**
|
|
||||||
** File: IterateDirectory.c
|
Version: MoreFiles
|
||||||
**
|
|
||||||
** Copyright © 1995-1998 Jim Luther and Apple Computer, Inc.
|
Copyright: © 1995-2001 by Jim Luther and Apple Computer, Inc., all rights reserved.
|
||||||
** All rights reserved.
|
|
||||||
**
|
You may incorporate this sample code into your applications without
|
||||||
** You may incorporate this sample code into your applications without
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
** responsibility for its operation is 100% yours.
|
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,
|
||||||
** IterateDirectory is designed to drop into the MoreFiles sample code
|
we require that you make it clear in the source that the code was
|
||||||
** library I wrote while in Apple Developer Technical Support
|
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
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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 <Types.h>
|
#include <MacTypes.h>
|
||||||
#include <Errors.h>
|
#include <MacErrors.h>
|
||||||
#include <Files.h>
|
#include <Files.h>
|
||||||
|
|
||||||
#define __COMPILINGMOREFILES
|
#define __COMPILINGMOREFILES
|
||||||
|
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "iterated.h"
|
#include "IterateDirectory.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Type definitions
|
** Type definitions
|
||||||
@@ -34,13 +52,8 @@
|
|||||||
** and to hold global information that might be needed at any time.
|
** and to hold global information that might be needed at any time.
|
||||||
*/
|
*/
|
||||||
#if PRAGMA_STRUCT_ALIGN
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=mac68k
|
#pragma options align=mac68k
|
||||||
#elif PRAGMA_STRUCT_PACKPUSH
|
|
||||||
#pragma pack(push, 2)
|
|
||||||
#elif PRAGMA_STRUCT_PACK
|
|
||||||
#pragma pack(2)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct IterateGlobals
|
struct IterateGlobals
|
||||||
{
|
{
|
||||||
IterateFilterProcPtr iterateFilter; /* pointer to IterateFilterProc */
|
IterateFilterProcPtr iterateFilter; /* pointer to IterateFilterProc */
|
||||||
@@ -52,13 +65,8 @@ struct IterateGlobals
|
|||||||
unsigned short currentLevel; /* The current level IterateLevel is on */
|
unsigned short currentLevel; /* The current level IterateLevel is on */
|
||||||
void *yourDataPtr; /* A pointer to caller data the filter may need to access */
|
void *yourDataPtr; /* A pointer to caller data the filter may need to access */
|
||||||
};
|
};
|
||||||
|
|
||||||
#if PRAGMA_STRUCT_ALIGN
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=reset
|
#pragma options align=reset
|
||||||
#elif PRAGMA_STRUCT_PACKPUSH
|
|
||||||
#pragma pack(pop)
|
|
||||||
#elif PRAGMA_STRUCT_PACK
|
|
||||||
#pragma pack()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct IterateGlobals IterateGlobals;
|
typedef struct IterateGlobals IterateGlobals;
|
||||||
@@ -102,7 +110,7 @@ static void IterateDirectoryLevel(long dirID,
|
|||||||
CallIterateFilterProc(theGlobals->iterateFilter, &theGlobals->cPB, &theGlobals->quitFlag, theGlobals->yourDataPtr);
|
CallIterateFilterProc(theGlobals->iterateFilter, &theGlobals->cPB, &theGlobals->quitFlag, theGlobals->yourDataPtr);
|
||||||
|
|
||||||
/* Is it a directory? */
|
/* Is it a directory? */
|
||||||
if ( (theGlobals->cPB.hFileInfo.ioFlAttrib & ioDirMask) != 0 )
|
if ( (theGlobals->cPB.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
|
||||||
{
|
{
|
||||||
/* We have a directory */
|
/* We have a directory */
|
||||||
if ( !theGlobals->quitFlag )
|
if ( !theGlobals->quitFlag )
|
222
src/mac/morefile/IterateDirectory.h
Normal file
222
src/mac/morefile/IterateDirectory.h
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
/*
|
||||||
|
File: IterateDirectory.h
|
||||||
|
|
||||||
|
Contains: File Manager directory iterator routines.
|
||||||
|
|
||||||
|
Version: Technology: MoreFiles
|
||||||
|
Release: 1.5.2
|
||||||
|
|
||||||
|
Copyright: <20> 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 <MacTypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __FILES__
|
||||||
|
#include <Files.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Optimization.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if PRAGMA_ONCE
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_IMPORT
|
||||||
|
#pragma import on
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
|
#pragma options align=mac68k
|
||||||
|
#elif PRAGMA_STRUCT_PACKPUSH
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
#elif PRAGMA_STRUCT_PACK
|
||||||
|
#pragma pack(2)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
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__ */
|
||||||
|
|
@@ -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 <20> 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 <Types.h>
|
|
||||||
#include <Files.h>
|
|
||||||
|
|
||||||
#include "optim.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
pascal OSErr DTOpen(ConstStr255Param volName,
|
|
||||||
short vRefNum,
|
|
||||||
short *dtRefNum,
|
|
||||||
Boolean *newDTDatabase);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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 <09>43 File or directory doesn<73>t exist
|
|
||||||
paramErr -50 Volume doesn't support this function
|
|
||||||
wPrErr <09>44 Volume is locked through hardware
|
|
||||||
vLckdErr <09>46 Volume is locked through software
|
|
||||||
rfNumErr <09>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);
|
|
||||||
/* <09> 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 <09>43 File or directory doesn<73>t exist
|
|
||||||
wPrErr <09>44 Volume is locked through hardware
|
|
||||||
vLckdErr <09>46 Volume is locked through software
|
|
||||||
rfNumErr <09>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);
|
|
||||||
/* <09> 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 <09>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);
|
|
||||||
/* <09> 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 <09>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);
|
|
||||||
/* <09> 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 <09>43 File or directory doesn<73>t exist
|
|
||||||
wPrErr <09>44 Volume is locked through hardware
|
|
||||||
vLckdErr <09>46 Volume is locked through software
|
|
||||||
paramErr -50 Volume doesn't support this function
|
|
||||||
rfNumErr <09>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);
|
|
||||||
/* <09> 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 <09>43 File or directory doesn<73>t exist
|
|
||||||
wPrErr <09>44 Volume is locked through hardware
|
|
||||||
vLckdErr <09>46 Volume is locked through software
|
|
||||||
paramErr -50 Volume doesn't support this function
|
|
||||||
rfNumErr <09>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__ */
|
|
@@ -1,41 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: MoreDesktopMgr.c
|
||||||
**
|
|
||||||
** A collection of useful high-level Desktop Manager routines.
|
Contains: A collection of useful high-level Desktop Manager routines.
|
||||||
** If the Desktop Manager isn't available, use the Desktop file
|
If the Desktop Manager is not available, use the Desktop file
|
||||||
** for 'read' operations.
|
for 'read' operations.
|
||||||
**
|
|
||||||
** We do more because we can...
|
Version: MoreFiles
|
||||||
**
|
|
||||||
** by Jim Luther and Nitin Ganatra, Apple Developer Technical Support Emeriti
|
Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
**
|
|
||||||
** File: MoreDesktopMgr.c
|
You may incorporate this sample code into your applications without
|
||||||
**
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
** Copyright © 1992-1998 Apple Computer, Inc.
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
** All rights reserved.
|
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,
|
||||||
** You may incorporate this sample code into your applications without
|
we require that you make it clear in the source that the code was
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
descended from Apple Sample Code, but that you've made changes.
|
||||||
** responsibility for its operation is 100% yours. However, what you are
|
|
||||||
** not permitted to do is to redistribute the source as "DSC Sample Code"
|
File Ownership:
|
||||||
** 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
|
DRI: Apple Macintosh Developer Technical Support
|
||||||
** descended from Apple Sample Code, but that you've made changes.
|
|
||||||
|
Other Contact: Apple Macintosh Developer Technical Support
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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 <Types.h>
|
#include <MacTypes.h>
|
||||||
#include <Errors.h>
|
#include <MacErrors.h>
|
||||||
#include <Memory.h>
|
#include <MacMemory.h>
|
||||||
#include <Files.h>
|
#include <Files.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
#include <Icons.h>
|
#include <Icons.h>
|
||||||
|
|
||||||
#define __COMPILINGMOREFILES
|
#define __COMPILINGMOREFILES
|
||||||
|
|
||||||
#include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "mfsearch.h"
|
#include "Search.h"
|
||||||
#include "moredesk.h"
|
#include "MoreDesktopMgr.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
@@ -81,11 +97,7 @@ enum
|
|||||||
/* local data structures */
|
/* local data structures */
|
||||||
|
|
||||||
#if PRAGMA_STRUCT_ALIGN
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=mac68k
|
#pragma options align=mac68k
|
||||||
#elif PRAGMA_STRUCT_PACKPUSH
|
|
||||||
#pragma pack(push, 2)
|
|
||||||
#elif PRAGMA_STRUCT_PACK
|
|
||||||
#pragma pack(2)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct IDRec
|
struct IDRec
|
||||||
@@ -134,11 +146,7 @@ typedef struct APPLRec APPLRec;
|
|||||||
typedef APPLRec *APPLRecPtr;
|
typedef APPLRec *APPLRecPtr;
|
||||||
|
|
||||||
#if PRAGMA_STRUCT_ALIGN
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=reset
|
#pragma options align=reset
|
||||||
#elif PRAGMA_STRUCT_PACKPUSH
|
|
||||||
#pragma pack(pop)
|
|
||||||
#elif PRAGMA_STRUCT_PACK
|
|
||||||
#pragma pack()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -245,7 +253,7 @@ pascal OSErr DTOpen(ConstStr255Param volName,
|
|||||||
error = HGetVolParms(volName, vRefNum, &volParmsInfo, &infoSize);
|
error = HGetVolParms(volName, vRefNum, &volParmsInfo, &infoSize);
|
||||||
if ( error == noErr )
|
if ( error == noErr )
|
||||||
{
|
{
|
||||||
if ( hasDesktopMgr(volParmsInfo) )
|
if ( hasDesktopMgr(&volParmsInfo) )
|
||||||
{
|
{
|
||||||
pb.ioNamePtr = (StringPtr)volName;
|
pb.ioNamePtr = (StringPtr)volName;
|
||||||
pb.ioVRefNum = vRefNum;
|
pb.ioVRefNum = vRefNum;
|
||||||
@@ -317,11 +325,7 @@ static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName,
|
|||||||
applResHandle = Get1Resource(kAPPLResType, 0);
|
applResHandle = Get1Resource(kAPPLResType, 0);
|
||||||
if ( applResHandle != NULL )
|
if ( applResHandle != NULL )
|
||||||
{
|
{
|
||||||
#if !TARGET_CARBON
|
|
||||||
applSize = InlineGetHandleSize((Handle)applResHandle);
|
|
||||||
#else
|
|
||||||
applSize = GetHandleSize((Handle)applResHandle);
|
applSize = GetHandleSize((Handle)applResHandle);
|
||||||
#endif
|
|
||||||
if ( applSize != 0 ) /* make sure the APPL resource isn't empty */
|
if ( applSize != 0 ) /* make sure the APPL resource isn't empty */
|
||||||
{
|
{
|
||||||
foundCreator = false;
|
foundCreator = false;
|
||||||
@@ -1117,11 +1121,7 @@ static OSErr GetCommentFromDesktopFile(short vRefNum,
|
|||||||
commentHandle = (StringHandle)Get1Resource(kFCMTResType,commentID);
|
commentHandle = (StringHandle)Get1Resource(kFCMTResType,commentID);
|
||||||
if ( commentHandle != NULL )
|
if ( commentHandle != NULL )
|
||||||
{
|
{
|
||||||
#if !TARGET_CARBON
|
|
||||||
if ( InlineGetHandleSize((Handle)commentHandle) > 0 )
|
|
||||||
#else
|
|
||||||
if ( GetHandleSize((Handle)commentHandle) > 0 )
|
if ( GetHandleSize((Handle)commentHandle) > 0 )
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
BlockMoveData(*commentHandle, comment, *commentHandle[0] + 1);
|
BlockMoveData(*commentHandle, comment, *commentHandle[0] + 1);
|
||||||
}
|
}
|
628
src/mac/morefile/MoreDesktopMgr.h
Normal file
628
src/mac/morefile/MoreDesktopMgr.h
Normal file
@@ -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: <20> 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 <MacTypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __FILES__
|
||||||
|
#include <Files.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Optimization.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if PRAGMA_ONCE
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_IMPORT
|
||||||
|
#pragma import on
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
|
#pragma options align=mac68k
|
||||||
|
#elif PRAGMA_STRUCT_PACKPUSH
|
||||||
|
#pragma pack(push, 2)
|
||||||
|
#elif PRAGMA_STRUCT_PACK
|
||||||
|
#pragma pack(2)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
EXTERN_API( OSErr )
|
||||||
|
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 <20>43 File or directory doesn<73>t exist
|
||||||
|
paramErr -50 Volume doesn't support this function
|
||||||
|
wPrErr <20>44 Volume is locked through hardware
|
||||||
|
vLckdErr <20>46 Volume is locked through software
|
||||||
|
rfNumErr <20>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 <20>43 File or directory doesn<73>t exist
|
||||||
|
wPrErr <20>44 Volume is locked through hardware
|
||||||
|
vLckdErr <20>46 Volume is locked through software
|
||||||
|
rfNumErr <20>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 <20>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 <20>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 <20>43 File or directory doesn<73>t exist
|
||||||
|
wPrErr <20>44 Volume is locked through hardware
|
||||||
|
vLckdErr <20>46 Volume is locked through software
|
||||||
|
paramErr -50 Volume doesn't support this function
|
||||||
|
rfNumErr <20>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 <20>43 File or directory doesn<73>t exist
|
||||||
|
wPrErr <20>44 Volume is locked through hardware
|
||||||
|
vLckdErr <20>46 Volume is locked through software
|
||||||
|
paramErr -50 Volume doesn't support this function
|
||||||
|
rfNumErr <20>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__ */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,32 +1,47 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: MoreFiles.c
|
||||||
**
|
|
||||||
** The long lost high-level and FSSpec File Manager functions.
|
Contains: The long lost high-level and FSSpec File Manager functions.
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
Version: MoreFiles
|
||||||
**
|
|
||||||
** File: MoreFiles.c
|
Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
**
|
|
||||||
** Copyright © 1992-1998 Apple Computer, Inc.
|
You may incorporate this sample code into your applications without
|
||||||
** All rights reserved.
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
**
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
** You may incorporate this sample code into your applications without
|
not permitted to do is to redistribute the source as "DSC Sample Code"
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
after having made changes. If you're going to re-distribute the source,
|
||||||
** responsibility for its operation is 100% yours. However, what you are
|
we require that you make it clear in the source that the code was
|
||||||
** not permitted to do is to redistribute the source as "DSC Sample Code"
|
descended from Apple Sample Code, but that you've made changes.
|
||||||
** 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
|
File Ownership:
|
||||||
** descended from Apple Sample Code, but that you've made changes.
|
|
||||||
|
DRI: Apple Macintosh Developer Technical Support
|
||||||
|
|
||||||
|
Other Contact: Apple Macintosh Developer Technical Support
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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 <Types.h>
|
#include <MacTypes.h>
|
||||||
#include <Errors.h>
|
#include <MacErrors.h>
|
||||||
#include <Files.h>
|
#include <Files.h>
|
||||||
|
|
||||||
#define __COMPILINGMOREFILES
|
#define __COMPILINGMOREFILES
|
||||||
|
|
||||||
#include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
#include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
@@ -153,7 +168,7 @@ pascal OSErr CreateFileIDRef(short vRefNum,
|
|||||||
pb.fidParam.ioVRefNum = vRefNum;
|
pb.fidParam.ioVRefNum = vRefNum;
|
||||||
pb.fidParam.ioSrcDirID = parID;
|
pb.fidParam.ioSrcDirID = parID;
|
||||||
error = PBCreateFileIDRefSync(&pb);
|
error = PBCreateFileIDRefSync(&pb);
|
||||||
if ( error == noErr )
|
if ( (error == noErr) || (error == fidExists) || (error == afpIDExists) )
|
||||||
{
|
{
|
||||||
*fileID = pb.fidParam.ioFileID;
|
*fileID = pb.fidParam.ioFileID;
|
||||||
}
|
}
|
1420
src/mac/morefile/MoreFiles.h
Normal file
1420
src/mac/morefile/MoreFiles.h
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3597
src/mac/morefile/MoreFilesExtras.h
Normal file
3597
src/mac/morefile/MoreFilesExtras.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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 <20> 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
|
|
@@ -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 <20> 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
|
|
109
src/mac/morefile/Optimization.h
Normal file
109
src/mac/morefile/Optimization.h
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
File: Optimization.h
|
||||||
|
|
||||||
|
Contains: Defines that let you make MoreFiles code more efficient.
|
||||||
|
|
||||||
|
Version: MoreFiles
|
||||||
|
|
||||||
|
Copyright: <09> 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
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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 <ConditionalMacros.h>
|
||||||
|
|
||||||
|
// 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
|
56
src/mac/morefile/OptimizationEnd.h
Normal file
56
src/mac/morefile/OptimizationEnd.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
File: OptimizationEnd.h
|
||||||
|
|
||||||
|
Contains: Defines that let you make MoreFiles code more efficient.
|
||||||
|
|
||||||
|
Version: MoreFiles
|
||||||
|
|
||||||
|
Copyright: <09> 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
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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
|
@@ -1,36 +1,55 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: Search.c
|
||||||
**
|
|
||||||
** IndexedSearch and the PBCatSearch compatibility function.
|
Contains: IndexedSearch and the PBCatSearch compatibility function.
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
Version: MoreFiles
|
||||||
**
|
|
||||||
** File: Search.c
|
Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
**
|
|
||||||
** Copyright © 1992-1998 Apple Computer, Inc.
|
You may incorporate this sample code into your applications without
|
||||||
** All rights reserved.
|
restriction, though the sample code has been provided "AS IS" and the
|
||||||
**
|
responsibility for its operation is 100% yours. However, what you are
|
||||||
** You may incorporate this sample code into your applications without
|
not permitted to do is to redistribute the source as "DSC Sample Code"
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
after having made changes. If you're going to re-distribute the source,
|
||||||
** responsibility for its operation is 100% yours. However, what you are
|
we require that you make it clear in the source that the code was
|
||||||
** not permitted to do is to redistribute the source as "DSC Sample Code"
|
descended from Apple Sample Code, but that you've made changes.
|
||||||
** 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
|
File Ownership:
|
||||||
** descended from Apple Sample Code, but that you've made changes.
|
|
||||||
|
DRI: Jim Luther
|
||||||
|
|
||||||
|
Other Contact: Apple Macintosh Developer Technical Support
|
||||||
|
<http://developer.apple.com/bugreporter/>
|
||||||
|
|
||||||
|
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 <Types.h>
|
#include <MacTypes.h>
|
||||||
#include <Gestalt.h>
|
#include <Gestalt.h>
|
||||||
#include <Timer.h>
|
#include <Timer.h>
|
||||||
#include <Errors.h>
|
#include <MacErrors.h>
|
||||||
#include <Memory.h>
|
#include <MacMemory.h>
|
||||||
#include <Files.h>
|
#include <Files.h>
|
||||||
#include <TextUtils.h>
|
#include <TextUtils.h>
|
||||||
|
|
||||||
#define __COMPILINGMOREFILES
|
#define __COMPILINGMOREFILES
|
||||||
|
|
||||||
#include "MoreFile.h"
|
#include "MoreFiles.h"
|
||||||
#include "MoreExtr.h"
|
#include "MoreFilesExtras.h"
|
||||||
|
|
||||||
#include "Search.h"
|
#include "Search.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -66,7 +85,7 @@ typedef LevelRec *LevelRecPtr, **LevelRecHandle;
|
|||||||
** SearchPositionRec is my version of a CatPositionRec. It holds the
|
** SearchPositionRec is my version of a CatPositionRec. It holds the
|
||||||
** information I need to resuming searching.
|
** information I need to resuming searching.
|
||||||
*/
|
*/
|
||||||
#if PRAGMA_ALIGN_SUPPORTED
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=mac68k
|
#pragma options align=mac68k
|
||||||
#endif
|
#endif
|
||||||
struct SearchPositionRec
|
struct SearchPositionRec
|
||||||
@@ -76,7 +95,7 @@ struct SearchPositionRec
|
|||||||
unsigned short stackDepth; /* Current depth on searchStack. */
|
unsigned short stackDepth; /* Current depth on searchStack. */
|
||||||
short priv[11]; /* For future use... */
|
short priv[11]; /* For future use... */
|
||||||
};
|
};
|
||||||
#if PRAGMA_ALIGN_SUPPORTED
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=reset
|
#pragma options align=reset
|
||||||
#endif
|
#endif
|
||||||
typedef struct SearchPositionRec SearchPositionRec;
|
typedef struct SearchPositionRec SearchPositionRec;
|
||||||
@@ -86,7 +105,7 @@ typedef SearchPositionRec *SearchPositionRecPtr;
|
|||||||
/*
|
/*
|
||||||
** ExtendedTMTask is a TMTask record extended to hold the timer flag.
|
** ExtendedTMTask is a TMTask record extended to hold the timer flag.
|
||||||
*/
|
*/
|
||||||
#if PRAGMA_ALIGN_SUPPORTED
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=mac68k
|
#pragma options align=mac68k
|
||||||
#endif
|
#endif
|
||||||
struct ExtendedTMTask
|
struct ExtendedTMTask
|
||||||
@@ -95,7 +114,7 @@ struct ExtendedTMTask
|
|||||||
Boolean stopSearch; /* the Time Mgr task will set stopSearch to */
|
Boolean stopSearch; /* the Time Mgr task will set stopSearch to */
|
||||||
/* true when the timer expires */
|
/* true when the timer expires */
|
||||||
};
|
};
|
||||||
#if PRAGMA_ALIGN_SUPPORTED
|
#if PRAGMA_STRUCT_ALIGN
|
||||||
#pragma options align=reset
|
#pragma options align=reset
|
||||||
#endif
|
#endif
|
||||||
typedef struct ExtendedTMTask ExtendedTMTask;
|
typedef struct ExtendedTMTask ExtendedTMTask;
|
||||||
@@ -135,7 +154,7 @@ static void CheckForMatches(CInfoPBPtr cPB,
|
|||||||
#undef pascal
|
#undef pascal
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GENERATINGCFM
|
#if TARGET_RT_MAC_CFM || TARGET_API_MAC_CARBON
|
||||||
|
|
||||||
static pascal void TimeOutTask(TMTaskPtr tmTaskPtr);
|
static pascal void TimeOutTask(TMTaskPtr tmTaskPtr);
|
||||||
|
|
||||||
@@ -205,7 +224,7 @@ static OSErr CheckStack(unsigned short stackDepth,
|
|||||||
/* Time to grow stack */
|
/* Time to grow stack */
|
||||||
SetHandleSize((Handle)searchStack, *searchStackSize + (kAdditionalLevelRecs * sizeof(LevelRec)));
|
SetHandleSize((Handle)searchStack, *searchStackSize + (kAdditionalLevelRecs * sizeof(LevelRec)));
|
||||||
result = MemError(); /* should be noErr */
|
result = MemError(); /* should be noErr */
|
||||||
*searchStackSize = InlineGetHandleSize((Handle)searchStack);
|
*searchStackSize = GetHandleSize((Handle)searchStack);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -277,16 +296,16 @@ static OSErr VerifyUserPB(CSParamPtr userPB,
|
|||||||
{
|
{
|
||||||
/* The only attributes you can search on are the directory flag */
|
/* The only attributes you can search on are the directory flag */
|
||||||
/* and the locked flag. */
|
/* and the locked flag. */
|
||||||
if ( (searchInfo2->hFileInfo.ioFlAttrib & ~(ioDirMask | 0x01)) != 0 )
|
if ( (searchInfo2->hFileInfo.ioFlAttrib & ~(kioFlAttribDirMask | kioFlAttribLockedMask)) != 0 )
|
||||||
{
|
{
|
||||||
goto ParamErrExit;
|
goto ParamErrExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* interested in the directory bit? */
|
/* 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? */
|
/* yes, so do they want just directories or just files? */
|
||||||
if ( (searchInfo1->hFileInfo.ioFlAttrib & ioDirMask) != 0 )
|
if ( (searchInfo1->hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
|
||||||
{
|
{
|
||||||
*includeDirs = true;
|
*includeDirs = true;
|
||||||
}
|
}
|
||||||
@@ -313,7 +332,7 @@ static OSErr VerifyUserPB(CSParamPtr userPB,
|
|||||||
/* then the locked attribute cannot be requested. */
|
/* then the locked attribute cannot be requested. */
|
||||||
if ( *includeDirs &&
|
if ( *includeDirs &&
|
||||||
((userPB->ioSearchBits & fsSBFlAttrib) != 0) &&
|
((userPB->ioSearchBits & fsSBFlAttrib) != 0) &&
|
||||||
((searchInfo2->hFileInfo.ioFlAttrib & 0x01) != 0) )
|
((searchInfo2->hFileInfo.ioFlAttrib & kioFlAttribLockedMask) != 0) )
|
||||||
{
|
{
|
||||||
goto ParamErrExit;
|
goto ParamErrExit;
|
||||||
}
|
}
|
||||||
@@ -462,7 +481,7 @@ static void CheckForMatches(CInfoPBPtr cPB,
|
|||||||
|
|
||||||
/* Into the if statements that go on forever... */
|
/* Into the if statements that go on forever... */
|
||||||
|
|
||||||
if ( (cPB->hFileInfo.ioFlAttrib & ioDirMask) == 0 )
|
if ( (cPB->hFileInfo.ioFlAttrib & kioFlAttribDirMask) == 0 )
|
||||||
{
|
{
|
||||||
if (!includeFiles)
|
if (!includeFiles)
|
||||||
{
|
{
|
||||||
@@ -678,7 +697,7 @@ Failed:
|
|||||||
#undef pascal
|
#undef pascal
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GENERATINGCFM
|
#if TARGET_RT_MAC_CFM || TARGET_API_MAC_CARBON
|
||||||
|
|
||||||
static pascal void TimeOutTask(TMTaskPtr tmTaskPtr)
|
static pascal void TimeOutTask(TMTaskPtr tmTaskPtr)
|
||||||
{
|
{
|
||||||
@@ -761,7 +780,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb,
|
|||||||
if ( pb->ioSearchTime != 0 )
|
if ( pb->ioSearchTime != 0 )
|
||||||
{
|
{
|
||||||
/* Start timer */
|
/* Start timer */
|
||||||
timerTask.theTask.tmAddr = NewTimerProc(TimeOutTask);
|
timerTask.theTask.tmAddr = NewTimerUPP(TimeOutTask);
|
||||||
InsTime((QElemPtr)&(timerTask.theTask));
|
InsTime((QElemPtr)&(timerTask.theTask));
|
||||||
PrimeTime((QElemPtr)&(timerTask.theTask), pb->ioSearchTime);
|
PrimeTime((QElemPtr)&(timerTask.theTask), pb->ioSearchTime);
|
||||||
}
|
}
|
||||||
@@ -800,7 +819,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb,
|
|||||||
/* Make sure searchStack really exists */
|
/* Make sure searchStack really exists */
|
||||||
if ( searchStack != NULL )
|
if ( searchStack != NULL )
|
||||||
{
|
{
|
||||||
searchStackSize = InlineGetHandleSize((Handle)searchStack);
|
searchStackSize = GetHandleSize((Handle)searchStack);
|
||||||
|
|
||||||
/* See if the search is a new search or a resumed search. */
|
/* See if the search is a new search or a resumed search. */
|
||||||
if ( catPosition->initialize == 0 )
|
if ( catPosition->initialize == 0 )
|
||||||
@@ -897,7 +916,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb,
|
|||||||
CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs);
|
CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs);
|
||||||
|
|
||||||
++index;
|
++index;
|
||||||
if ( (cPB.dirInfo.ioFlAttrib & ioDirMask) != 0 )
|
if ( (cPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
|
||||||
{
|
{
|
||||||
/* It's a directory */
|
/* It's a directory */
|
||||||
|
|
||||||
@@ -1007,7 +1026,7 @@ pascal OSErr IndexedSearch(CSParamPtr pb,
|
|||||||
{
|
{
|
||||||
/* Stop Time Manager task here if it was installed */
|
/* Stop Time Manager task here if it was installed */
|
||||||
RmvTime((QElemPtr)&(timerTask.theTask));
|
RmvTime((QElemPtr)&(timerTask.theTask));
|
||||||
DisposeRoutineDescriptor(timerTask.theTask.tmAddr);
|
DisposeTimerUPP(timerTask.theTask.tmAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( result );
|
return ( result );
|
||||||
@@ -1017,19 +1036,22 @@ pascal OSErr IndexedSearch(CSParamPtr pb,
|
|||||||
|
|
||||||
pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock)
|
pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock)
|
||||||
{
|
{
|
||||||
static Boolean fullExtFSDispatchingtested = false;
|
|
||||||
static Boolean hasFullExtFSDispatching = false;
|
|
||||||
OSErr result;
|
OSErr result;
|
||||||
Boolean supportsCatSearch;
|
Boolean supportsCatSearch;
|
||||||
long response;
|
|
||||||
GetVolParmsInfoBuffer volParmsInfo;
|
GetVolParmsInfoBuffer volParmsInfo;
|
||||||
long infoSize;
|
long infoSize;
|
||||||
|
#if !__MACOSSEVENORLATER
|
||||||
|
static Boolean fullExtFSDispatchingtested = false;
|
||||||
|
static Boolean hasFullExtFSDispatching = false;
|
||||||
|
long response;
|
||||||
|
#endif
|
||||||
|
|
||||||
result = noErr;
|
result = noErr;
|
||||||
|
|
||||||
|
#if !__MACOSSEVENORLATER
|
||||||
/* See if File Manager will pass CatSearch requests to external file systems */
|
/* 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 */
|
/* 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 )
|
if ( !fullExtFSDispatchingtested )
|
||||||
{
|
{
|
||||||
fullExtFSDispatchingtested = true;
|
fullExtFSDispatchingtested = true;
|
||||||
@@ -1038,18 +1060,21 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock)
|
|||||||
hasFullExtFSDispatching = ((response & (1L << gestaltFullExtFSDispatching)) != 0);
|
hasFullExtFSDispatching = ((response & (1L << gestaltFullExtFSDispatching)) != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* CatSearch is a per volume attribute, so we have to check each time we're */
|
/* 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. */
|
/* called to see if it is available on the volume specified. */
|
||||||
supportsCatSearch = false;
|
supportsCatSearch = false;
|
||||||
|
#if !__MACOSSEVENORLATER
|
||||||
if ( hasFullExtFSDispatching )
|
if ( hasFullExtFSDispatching )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
infoSize = sizeof(GetVolParmsInfoBuffer);
|
infoSize = sizeof(GetVolParmsInfoBuffer);
|
||||||
result = HGetVolParms(paramBlock->ioNamePtr, paramBlock->ioVRefNum,
|
result = HGetVolParms(paramBlock->ioNamePtr, paramBlock->ioVRefNum,
|
||||||
&volParmsInfo, &infoSize);
|
&volParmsInfo, &infoSize);
|
||||||
if ( result == noErr )
|
if ( result == noErr )
|
||||||
{
|
{
|
||||||
supportsCatSearch = hasCatSearch(volParmsInfo);
|
supportsCatSearch = hasCatSearch(&volParmsInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1125,7 +1150,7 @@ pascal OSErr NameFileSearch(ConstStr255Param volName,
|
|||||||
|
|
||||||
/* only match files (not directories) */
|
/* only match files (not directories) */
|
||||||
searchInfo1.hFileInfo.ioFlAttrib = 0x00;
|
searchInfo1.hFileInfo.ioFlAttrib = 0x00;
|
||||||
searchInfo2.hFileInfo.ioFlAttrib = ioDirMask;
|
searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask;
|
||||||
|
|
||||||
error = PBCatSearchSyncCompat((CSParamPtr)&pb);
|
error = PBCatSearchSyncCompat((CSParamPtr)&pb);
|
||||||
|
|
||||||
@@ -1204,7 +1229,7 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName,
|
|||||||
|
|
||||||
/* only match files (not directories) */
|
/* only match files (not directories) */
|
||||||
searchInfo1.hFileInfo.ioFlAttrib = 0x00;
|
searchInfo1.hFileInfo.ioFlAttrib = 0x00;
|
||||||
searchInfo2.hFileInfo.ioFlAttrib = ioDirMask;
|
searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask;
|
||||||
|
|
||||||
/* search for creator; if creator = 0x00000000, ignore creator */
|
/* search for creator; if creator = 0x00000000, ignore creator */
|
||||||
searchInfo1.hFileInfo.ioFlFndrInfo.fdCreator = creator;
|
searchInfo1.hFileInfo.ioFlFndrInfo.fdCreator = creator;
|
@@ -1,41 +1,73 @@
|
|||||||
/*
|
/*
|
||||||
** Apple Macintosh Developer Technical Support
|
File: Search.h
|
||||||
**
|
|
||||||
** IndexedSearch and the PBCatSearch compatibility function.
|
Contains: IndexedSearch and the PBCatSearch compatibility function.
|
||||||
**
|
|
||||||
** by Jim Luther, Apple Developer Technical Support Emeritus
|
Version: Technology: MoreFiles
|
||||||
**
|
Release: 1.5.2
|
||||||
** File: Search.h
|
|
||||||
**
|
Copyright: <20> 1992-2001 by Apple Computer, Inc., all rights reserved.
|
||||||
** Copyright <20> 1992-1998 Apple Computer, Inc.
|
|
||||||
** All rights reserved.
|
Bugs?: For bug reports, consult the following page on
|
||||||
**
|
the World Wide Web:
|
||||||
** You may incorporate this sample code into your applications without
|
|
||||||
** restriction, though the sample code has been provided "AS IS" and the
|
http://developer.apple.com/bugreporter/
|
||||||
** 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.
|
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__
|
#ifndef __SEARCH__
|
||||||
#define __SEARCH__
|
#define __SEARCH__
|
||||||
|
|
||||||
#include <Types.h>
|
#ifndef __MACTYPES__
|
||||||
#include <Files.h>
|
#include <MacTypes.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Optim.h"
|
#ifndef __FILES__
|
||||||
|
#include <Files.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Optimization.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if PRAGMA_ONCE
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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,
|
EXTERN_API( OSErr )
|
||||||
|
IndexedSearch(
|
||||||
|
CSParamPtr pb,
|
||||||
long dirID);
|
long dirID);
|
||||||
/* <09> Search in and below a directory.
|
|
||||||
|
|
||||||
|
/*
|
||||||
The IndexedSearch function performs an indexed search in and below the
|
The IndexedSearch function performs an indexed search in and below the
|
||||||
specified directory using the same parameters (in pb) as is passed to
|
specified directory using the same parameters (in pb) as is passed to
|
||||||
PBCatSearch. See Inside Macintosh: Files for a description of the
|
PBCatSearch. See Inside Macintosh: Files for a description of the
|
||||||
@@ -78,8 +110,11 @@ pascal OSErr IndexedSearch(CSParamPtr pb,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock);
|
EXTERN_API( OSErr )
|
||||||
/* <09> Search a volume using PBCatSearch or IndexedSearch.
|
PBCatSearchSyncCompat(CSParamPtr paramBlock);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
The PBCatSearchSyncCompat function uses PBCatSearch (if available) or
|
The PBCatSearchSyncCompat function uses PBCatSearch (if available) or
|
||||||
IndexedSearch (if PBCatSearch is not available) to search a volume
|
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
|
using a set of search criteria that you specify. It builds a list of all
|
||||||
@@ -122,15 +157,19 @@ pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock);
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
pascal OSErr NameFileSearch(ConstStr255Param volName,
|
EXTERN_API( OSErr )
|
||||||
|
NameFileSearch(
|
||||||
|
ConstStr255Param volName,
|
||||||
short vRefNum,
|
short vRefNum,
|
||||||
ConstStr255Param fileName,
|
ConstStr255Param fileName,
|
||||||
FSSpecPtr matches,
|
FSSpecPtr matches,
|
||||||
long reqMatchCount,
|
long reqMatchCount,
|
||||||
long *actMatchCount,
|
long * actMatchCount,
|
||||||
Boolean newSearch,
|
Boolean newSearch,
|
||||||
Boolean partial);
|
Boolean partial);
|
||||||
/* <09> Search for files by file name with PBCatSearch.
|
|
||||||
|
|
||||||
|
/*
|
||||||
The NameFileSearch function searches for files with a specific file
|
The NameFileSearch function searches for files with a specific file
|
||||||
name on a volume that supports PBCatSearch.
|
name on a volume that supports PBCatSearch.
|
||||||
Note: A result of catChangedErr means the catalog has changed between
|
Note: A result of catChangedErr means the catalog has changed between
|
||||||
@@ -179,15 +218,19 @@ pascal OSErr NameFileSearch(ConstStr255Param volName,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName,
|
EXTERN_API( OSErr )
|
||||||
|
CreatorTypeFileSearch(
|
||||||
|
ConstStr255Param volName,
|
||||||
short vRefNum,
|
short vRefNum,
|
||||||
OSType creator,
|
OSType creator,
|
||||||
OSType fileType,
|
OSType fileType,
|
||||||
FSSpecPtr matches,
|
FSSpecPtr matches,
|
||||||
long reqMatchCount,
|
long reqMatchCount,
|
||||||
long *actMatchCount,
|
long * actMatchCount,
|
||||||
Boolean newSearch);
|
Boolean newSearch);
|
||||||
/* <09> Search for files by creator/fileType with PBCatSearch.
|
|
||||||
|
|
||||||
|
/*
|
||||||
The CreatorTypeFileSearch function searches for files with a specific
|
The CreatorTypeFileSearch function searches for files with a specific
|
||||||
creator or fileType on a volume that supports PBCatSearch.
|
creator or fileType on a volume that supports PBCatSearch.
|
||||||
Note: A result of catChangedErr means the catalog has changed between
|
Note: A result of catChangedErr means the catalog has changed between
|
||||||
@@ -237,10 +280,25 @@ pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "OptimEnd.h"
|
|
||||||
|
|
||||||
#endif /* __SEARCH__ */
|
#endif /* __SEARCH__ */
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -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 <20> 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 <Types.h>
|
|
||||||
#include <Files.h>
|
|
||||||
|
|
||||||
#include "optim.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
pascal OSErr IndexedSearch(CSParamPtr pb,
|
|
||||||
long dirID);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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);
|
|
||||||
/* <09> 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__ */
|
|
@@ -28,8 +28,8 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
# include "morefile.h"
|
#include "MoreFiles.h"
|
||||||
# include "moreextr.h"
|
#include "MoreFilesExtras.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
|
Reference in New Issue
Block a user