2
** Apple Macintosh Developer Technical Support
4
** DirectoryCopy: A robust, general purpose directory copy routine.
6
** by Jim Luther, Apple Developer Technical Support Emeritus
8
** File: DirectoryCopy.h
10
** Copyright � 1992-1998 Apple Computer, Inc.
11
** All rights reserved.
13
** You may incorporate this sample code into your applications without
14
** restriction, though the sample code has been provided "AS IS" and the
15
** responsibility for its operation is 100% yours. However, what you are
16
** not permitted to do is to redistribute the source as "DSC Sample Code"
17
** after having made changes. If you're going to re-distribute the source,
18
** we require that you make it clear in the source that the code was
19
** descended from Apple Sample Code, but that you've made changes.
22
// Modified to allow renaming the destination folder
24
#ifndef __MACDIRECTORYCOPY__
25
#define __MACDIRECTORYCOPY__
30
#include "Optimization.h"
36
typedef pascal Boolean (*CopyErrProcPtr) (OSErr error,
37
short failedOperation,
40
ConstStr255Param srcName,
43
ConstStr255Param dstName);
44
/* � Prototype for the CopyErrProc function DirectoryCopy calls.
45
This is the prototype for the CopyErrProc function DirectoryCopy
46
calls if an error condition is detected sometime during the copy. If
47
CopyErrProc returns false, then DirectoryCopy attempts to continue with
48
the directory copy operation. If CopyErrProc returns true, then
49
DirectoryCopy stops the directory copy operation.
51
error input: The error result code that caused CopyErrProc to
53
failedOperation input: The operation that returned an error to
55
srcVRefNum input: Source volume specification.
56
srcDirID input: Source directory ID.
57
srcName input: Source file or directory name, or nil if
58
srcDirID specifies the directory.
59
dstVRefNum input: Destination volume specification.
60
dstDirID input: Destination directory ID.
61
dstName input: Destination file or directory name, or nil if
62
dstDirID specifies the directory.
66
Also see: FilteredDirectoryCopy, FSpFilteredDirectoryCopy, DirectoryCopy, FSpDirectoryCopy
69
pascal OSErr MacFSpDirectoryCopyRename(const FSSpec *srcSpec,
70
const FSSpec *dstSpec,
71
ConstStr255Param newName,
75
CopyErrProcPtr copyErrHandler);
76
/* � Make a copy of a directory structure in a new location.
77
The FSpDirectoryCopy function makes a copy of a directory structure in a
78
new location. If copyBufferPtr <> NIL, it points to a buffer of
79
copyBufferSize that is used to copy files data. The larger the
80
supplied buffer, the faster the copy. If copyBufferPtr = NIL, then this
81
routine allocates a buffer in the application heap. If you pass a
82
copy buffer to this routine, make its size a multiple of 512
83
($200) bytes for optimum performance.
85
srcSpec input: An FSSpec record specifying the directory to copy.
86
dstSpec input: An FSSpec record specifying destination directory
88
copyBufferPtr input: Points to a buffer of copyBufferSize that
89
is used the i/o buffer for the copy or
90
nil if you want DirectoryCopy to allocate its
91
own buffer in the application heap.
92
copyBufferSize input: The size of the buffer pointed to
94
preflight input: If true, FSpDirectoryCopy makes sure there are
95
enough allocation blocks on the destination
96
volume to hold the directory's files before
98
copyErrHandler input: A pointer to the routine you want called if an
99
error condition is detected during the copy, or
100
nil if you don't want to handle error conditions.
101
If you don't handle error conditions, the first
102
error will cause the copy to quit and
103
DirectoryCopy will return the error.
104
Error handling is recommended...
108
readErr �19 Driver does not respond to read requests
109
writErr �20 Driver does not respond to write requests
110
badUnitErr �21 Driver reference number does not
112
unitEmptyErr �22 Driver reference number specifies a
113
nil handle in unit table
114
abortErr �27 Request aborted by KillIO
115
notOpenErr �28 Driver not open
116
dskFulErr -34 Destination volume is full
117
nsvErr -35 No such volume
119
bdNamErr -37 Bad filename
120
tmfoErr -42 Too many files open
121
fnfErr -43 Source file not found, or destination
122
directory does not exist
123
wPrErr -44 Volume locked by hardware
124
fLckdErr -45 File is locked
125
vLckdErr -46 Destination volume is read-only
126
fBsyErr -47 The source or destination file could
127
not be opened with the correct access
129
dupFNErr -48 Destination file already exists
130
opWrErr -49 File already open for writing
131
paramErr -50 No default volume or function not
133
permErr -54 File is already open and cannot be opened using specified deny modes
134
memFullErr -108 Copy buffer could not be allocated
135
dirNFErr -120 Directory not found or incomplete pathname
136
wrgVolTypErr -123 Function not supported by volume
137
afpAccessDenied -5000 User does not have the correct access
138
afpDenyConflict -5006 The source or destination file could
139
not be opened with the correct access
141
afpObjectTypeErr -5025 Source is a directory, directory not found
142
or incomplete pathname
146
Also see: CopyErrProcPtr, DirectoryCopy, FilteredDirectoryCopy,
147
FSpFilteredDirectoryCopy, FileCopy, FSpFileCopy
150
/*****************************************************************************/
156
#include "OptimizationEnd.h"
158
#endif /* __DIRECTORYCOPY__ */