home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-21 | 7.0 KB | 166 lines | [TEXT/CWIE] |
- UNIT DirectoryCopy;
-
- { Apple Macintosh Developer Technical Support }
- { }
- { DirectoryCopy: A robust, general purpose directory copy routine. }
- { by Jim Luther, Apple Developer Technical Support Emeritus }
- { }
- { File: DirectoryCopy.p }
- { }
- { Copyright © 1992-1995 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. }
-
-
- INTERFACE
-
- USES
- Files;
-
- {***************************************************************************}
-
- { DirectoryCopy failedOperation codes. }
- CONST
- 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 }
-
-
- {***************************************************************************}
-
- TYPE
- CopyErrProcPtr = ProcPtr;
-
- { A DirectoryCopy CopyErrProc function should have the following form: }
- { }
- { FUNCTION MyCopyErrProc (error: OSErr; }
- { failedOperation: Integer; }
- { srcVRefNum: Integer; }
- { srcDirID: LongInt; }
- { srcName: StringPtr; }
- { dstVRefNum: Integer; }
- { dstDirID: LongInt; }
- { dstName: StringPtr): Boolean; }
- { }
- { DirectoryCopy will call your CopyErrProc function if an error condition }
- { is detected sometime during the copy. If your CopyErrProc returns }
- { true, then DirectoryCopy attempts to continue with the directory copy }
- { operation. If your CopyErrProc returns false, 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. }
-
-
- {***************************************************************************}
-
-
- FUNCTION DirectoryCopy (srcVRefNum: Integer;
- srcDirID: LongInt;
- srcName: StringPtr;
- dstVRefNum: Integer;
- dstDirID: LongInt;
- dstName: StringPtr;
- copyBufferPtr: Ptr;
- copyBufferSize: LongInt;
- preflight: Boolean;
- copyErrHandler: CopyErrProcPtr): OSErr;
- { Use DirectoryCopy to make 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. }
- { }
- { 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. Error handling is recommended... }
-
-
- {***************************************************************************}
-
-
- FUNCTION FSpDirectoryCopy ({CONST}VAR srcSpec: FSSpec;
- {CONST}VAR dstSpec: FSSpec;
- copyBufferPtr: Ptr;
- copyBufferSize: LongInt;
- preflight: Boolean;
- copyErrHandler: CopyErrProcPtr): OSErr;
- { Use FSpDirectoryCopy to make 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. Error handling is recommended... }
-
-
- {***************************************************************************}
-
-
- IMPLEMENTATION
-
- END.