]> git.saurik.com Git - wxWidgets.git/blob - src/mac/morefile/FileCopy.h
no message
[wxWidgets.git] / src / mac / morefile / FileCopy.h
1 /*
2 File: FileCopy.h
3
4 Contains: A robust, general purpose file copy routine.
5
6 Version: Technology: MoreFiles
7 Release: 1.5.2
8
9 Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
10
11 Bugs?: For bug reports, consult the following page on
12 the World Wide Web:
13
14 http://developer.apple.com/bugreporter/
15
16 */
17
18 /*
19 You may incorporate this sample code into your applications without
20 restriction, though the sample code has been provided "AS IS" and the
21 responsibility for its operation is 100% yours. However, what you are
22 not permitted to do is to redistribute the source as "DSC Sample Code"
23 after having made changes. If you're going to re-distribute the source,
24 we require that you make it clear in the source that the code was
25 descended from Apple Sample Code, but that you've made changes.
26 */
27
28 #ifndef __FILECOPY__
29 #define __FILECOPY__
30
31 #ifndef __MACTYPES__
32 #include <MacTypes.h>
33 #endif
34
35 #ifndef __FILES__
36 #include <Files.h>
37 #endif
38
39 #include "Optimization.h"
40
41
42 #if PRAGMA_ONCE
43 #pragma once
44 #endif
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 #if PRAGMA_IMPORT
51 #pragma import on
52 #endif
53
54 #if PRAGMA_STRUCT_ALIGN
55 #pragma options align=mac68k
56 #elif PRAGMA_STRUCT_PACKPUSH
57 #pragma pack(push, 2)
58 #elif PRAGMA_STRUCT_PACK
59 #pragma pack(2)
60 #endif
61
62 /*****************************************************************************/
63
64 EXTERN_API( OSErr )
65 FileCopy(
66 short srcVRefNum,
67 long srcDirID,
68 ConstStr255Param srcName,
69 short dstVRefNum,
70 long dstDirID,
71 ConstStr255Param dstPathname,
72 ConstStr255Param copyName,
73 void * copyBufferPtr,
74 long copyBufferSize,
75 Boolean preflight);
76
77
78 /*
79 The FileCopy function duplicates a file and optionally renames it.
80 Since the PBHCopyFile routine is only available on some
81 AFP server volumes under specific conditions, this routine
82 either uses PBHCopyFile, or does all of the work PBHCopyFile
83 does. The srcVRefNum, srcDirID and srcName are used to
84 determine the location of the file to copy. The dstVRefNum
85 dstDirID and dstPathname are used to determine the location of
86 the destination directory. If copyName <> NIL, then it points
87 to the name of the new file. If copyBufferPtr <> NIL, it
88 points to a buffer of copyBufferSize that is used to copy
89 the file's data. The larger the supplied buffer, the
90 faster the copy. If copyBufferPtr = NIL, then this routine
91 allocates a buffer in the application heap. If you pass a
92 copy buffer to this routine, make its size a multiple of 512
93 ($200) bytes for optimum performance.
94
95 srcVRefNum input: Source volume specification.
96 srcDirID input: Source directory ID.
97 srcName input: Source file name.
98 dstVRefNum input: Destination volume specification.
99 dstDirID input: Destination directory ID.
100 dstPathname input: Pointer to destination directory name, or
101 nil when dstDirID specifies a directory.
102 copyName input: Points to the new file name if the file is
103 to be renamed or nil if the file isn't to
104 be renamed.
105 copyBufferPtr input: Points to a buffer of copyBufferSize that
106 is used the i/o buffer for the copy or
107 nil if you want FileCopy to allocate its
108 own buffer in the application heap.
109 copyBufferSize input: The size of the buffer pointed to
110 by copyBufferPtr.
111 preflight input: If true, FileCopy makes sure there are enough
112 allocation blocks on the destination volume to
113 hold both the data and resource forks before
114 starting the copy.
115
116 Result Codes
117 noErr 0 No error
118 readErr Ð19 Driver does not respond to read requests
119 writErr Ð20 Driver does not respond to write requests
120 badUnitErr Ð21 Driver reference number does not
121 match unit table
122 unitEmptyErr Ð22 Driver reference number specifies a
123 nil handle in unit table
124 abortErr Ð27 Request aborted by KillIO
125 notOpenErr Ð28 Driver not open
126 dskFulErr -34 Destination volume is full
127 nsvErr -35 No such volume
128 ioErr -36 I/O error
129 bdNamErr -37 Bad filename
130 tmfoErr -42 Too many files open
131 fnfErr -43 Source file not found, or destination
132 directory does not exist
133 wPrErr -44 Volume locked by hardware
134 fLckdErr -45 File is locked
135 vLckdErr -46 Destination volume is read-only
136 fBsyErr -47 The source or destination file could
137 not be opened with the correct access
138 modes
139 dupFNErr -48 Destination file already exists
140 opWrErr -49 File already open for writing
141 paramErr -50 No default volume or function not
142 supported by volume
143 permErr -54 File is already open and cannot be opened using specified deny modes
144 memFullErr -108 Copy buffer could not be allocated
145 dirNFErr -120 Directory not found or incomplete pathname
146 wrgVolTypErr -123 Function not supported by volume
147 afpAccessDenied -5000 User does not have the correct access
148 afpDenyConflict -5006 The source or destination file could
149 not be opened with the correct access
150 modes
151 afpObjectTypeErr -5025 Source is a directory, directory not found
152 or incomplete pathname
153
154 __________
155
156 Also see: FSpFileCopy, DirectoryCopy, FSpDirectoryCopy
157 */
158
159 /*****************************************************************************/
160
161 EXTERN_API( OSErr )
162 FSpFileCopy(
163 const FSSpec * srcSpec,
164 const FSSpec * dstSpec,
165 ConstStr255Param copyName,
166 void * copyBufferPtr,
167 long copyBufferSize,
168 Boolean preflight);
169
170
171 /*
172 The FSpFileCopy function duplicates a file and optionally renames it.
173 Since the PBHCopyFile routine is only available on some
174 AFP server volumes under specific conditions, this routine
175 either uses PBHCopyFile, or does all of the work PBHCopyFile
176 does. The srcSpec is used to
177 determine the location of the file to copy. The dstSpec is
178 used to determine the location of the
179 destination directory. If copyName <> NIL, then it points
180 to the name of the new file. If copyBufferPtr <> NIL, it
181 points to a buffer of copyBufferSize that is used to copy
182 the file's data. The larger the supplied buffer, the
183 faster the copy. If copyBufferPtr = NIL, then this routine
184 allocates a buffer in the application heap. If you pass a
185 copy buffer to this routine, make its size a multiple of 512
186 ($200) bytes for optimum performance.
187
188 srcSpec input: An FSSpec record specifying the source file.
189 dstSpec input: An FSSpec record specifying the destination
190 directory.
191 copyName input: Points to the new file name if the file is
192 to be renamed or nil if the file isn't to
193 be renamed.
194 copyBufferPtr input: Points to a buffer of copyBufferSize that
195 is used the i/o buffer for the copy or
196 nil if you want FileCopy to allocate its
197 own buffer in the application heap.
198 copyBufferSize input: The size of the buffer pointed to
199 by copyBufferPtr.
200 preflight input: If true, FSpFileCopy makes sure there are
201 enough allocation blocks on the destination
202 volume to hold both the data and resource forks
203 before starting the copy.
204
205 Result Codes
206 noErr 0 No error
207 readErr Ð19 Driver does not respond to read requests
208 writErr Ð20 Driver does not respond to write requests
209 badUnitErr Ð21 Driver reference number does not
210 match unit table
211 unitEmptyErr Ð22 Driver reference number specifies a
212 nil handle in unit table
213 abortErr Ð27 Request aborted by KillIO
214 notOpenErr Ð28 Driver not open
215 dskFulErr -34 Destination volume is full
216 nsvErr -35 No such volume
217 ioErr -36 I/O error
218 bdNamErr -37 Bad filename
219 tmfoErr -42 Too many files open
220 fnfErr -43 Source file not found, or destination
221 directory does not exist
222 wPrErr -44 Volume locked by hardware
223 fLckdErr -45 File is locked
224 vLckdErr -46 Destination volume is read-only
225 fBsyErr -47 The source or destination file could
226 not be opened with the correct access
227 modes
228 dupFNErr -48 Destination file already exists
229 opWrErr -49 File already open for writing
230 paramErr -50 No default volume or function not
231 supported by volume
232 permErr -54 File is already open and cannot be opened using specified deny modes
233 memFullErr -108 Copy buffer could not be allocated
234 dirNFErr -120 Directory not found or incomplete pathname
235 wrgVolTypErr -123 Function not supported by volume
236 afpAccessDenied -5000 User does not have the correct access
237 afpDenyConflict -5006 The source or destination file could
238 not be opened with the correct access
239 modes
240 afpObjectTypeErr -5025 Source is a directory, directory not found
241 or incomplete pathname
242
243 __________
244
245 Also see: FileCopy, DirectoryCopy, FSpDirectoryCopy
246 */
247
248 /*****************************************************************************/
249
250 #include "OptimizationEnd.h"
251
252 #if PRAGMA_STRUCT_ALIGN
253 #pragma options align=reset
254 #elif PRAGMA_STRUCT_PACKPUSH
255 #pragma pack(pop)
256 #elif PRAGMA_STRUCT_PACK
257 #pragma pack()
258 #endif
259
260 #ifdef PRAGMA_IMPORT_OFF
261 #pragma import off
262 #elif PRAGMA_IMPORT
263 #pragma import reset
264 #endif
265
266 #ifdef __cplusplus
267 }
268 #endif
269
270 #endif /* __FILECOPY__ */
271