home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 May: Tool Chest / Apple_Developer_CD_Series_May_1994_Tool_Chest.iso / Sample Code / MoreFiles 1.1.1 / FileCopy.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-18  |  5.2 KB  |  149 lines  |  [TEXT/KAHL]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    FileCopy: A robust, general purpose file copy routine.
  5. **
  6. **    by Jim Luther, Apple Developer Technical Support
  7. **
  8. **    File:        FileCopy.h
  9. **
  10. **    Copyright © 1992-1994 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  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.
  20. */
  21.  
  22. #ifndef __FILECOPY__
  23. #define __FILECOPY__
  24.  
  25. #ifndef __TYPES__
  26. #include <Types.h>
  27. #endif
  28.  
  29. #ifndef __ERRORS__
  30. #include <Errors.h>
  31. #endif
  32.  
  33. #ifndef __MEMORY__
  34. #include <Memory.h>
  35. #endif
  36.  
  37. #ifndef __OSUTILS__
  38. #include <OSUtils.h>
  39. #endif
  40.  
  41. #ifndef __FILES__
  42. #include <Files.h>
  43. #endif
  44.  
  45. #ifndef __MOREFILES__
  46. #include "MoreFiles.h"
  47. #endif
  48.  
  49. #ifndef __MOREFILESEXTRAS__
  50. #include "MoreFilesExtras.h"
  51. #endif
  52.  
  53.  
  54. /*****************************************************************************/
  55.  
  56. pascal    OSErr    FileCopy(short srcVRefNum,
  57.                          long srcDirID,
  58.                          const Str255 srcName,
  59.                          short dstVRefNum,
  60.                          long dstDirID,
  61.                          StringPtr dstPathname,
  62.                          StringPtr copyName,
  63.                          Ptr copyBufferPtr,
  64.                          long copyBufferSize,
  65.                          Boolean preflight);
  66. /*    Use FileCopy to duplicate a file and optionally rename it.
  67.     Since the PBHCopyFile routine is only available on some
  68.     AFP server volumes under specific conditions, this routine
  69.     either uses PBHCopyFile, or does all of the work PBHCopyFile
  70.     does.  The srcVRefNum, srcDirID and srcName are used to
  71.     determine the location of the file to copy.  The dstVRefNum
  72.     dstDirID and dstPathname are used to determine the location of
  73.     the destination directory.  If copyName <> NIL, then it points
  74.     to the name of the new file.  If copyBufferPtr <> NIL, it
  75.     points to a buffer of copyBufferSize that is used to copy
  76.     the file's data.  The larger the supplied buffer, the
  77.     faster the copy.  If copyBufferPtr = NIL, then this routine
  78.     allocates a buffer in the application heap. If you pass a
  79.     copy buffer to this routine, make its size a multiple of 512
  80.     ($200) bytes for optimum performance.
  81.     
  82.     srcVRefNum        input:    Source volume specification.
  83.     srcDirID        input:    Source directory ID.
  84.     srcName            input:    Source file name.
  85.     dstVRefNum        input:    Destination volume specification.
  86.     dstDirID        input:    Destination directory ID.
  87.     dstPathname        input:    Pointer to destination directory name, or
  88.                             nil when dstDirID specifies a directory.
  89.     copyName        input:    Points to the new file name if the file is
  90.                             to be renamed or nil if the file isn't to
  91.                             be renamed.
  92.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  93.                             is used the i/o buffer for the copy or
  94.                             nil if you want FileCopy to allocate its
  95.                             own buffer in the application heap.
  96.     copyBufferSize    input:    The size of the buffer pointed to
  97.                             by copyBufferPtr.
  98.     preflight        input:    If true, FileCopy makes sure there are enough
  99.                             allocation blocks on the destination volume to
  100.                             hold both the data and resource forks before
  101.                             starting the copy.
  102. */
  103.  
  104. /*****************************************************************************/
  105.  
  106. pascal    OSErr    FSpFileCopy(const FSSpec *srcSpec,
  107.                             const FSSpec *dstSpec,
  108.                             StringPtr copyName,
  109.                             Ptr copyBufferPtr,
  110.                             long copyBufferSize,
  111.                             Boolean preflight);
  112. /*    Use FSpFileCopy to duplicate a file and optionally rename it.
  113.     Since the PBHCopyFile routine is only available on some
  114.     AFP server volumes under specific conditions, this routine
  115.     either uses PBHCopyFile, or does all of the work PBHCopyFile
  116.     does.  The srcSpec is used to
  117.     determine the location of the file to copy.  The dstSpec is
  118.     used to determine the location of the
  119.     destination directory.  If copyName <> NIL, then it points
  120.     to the name of the new file.  If copyBufferPtr <> NIL, it
  121.     points to a buffer of copyBufferSize that is used to copy
  122.     the file's data.  The larger the supplied buffer, the
  123.     faster the copy.  If copyBufferPtr = NIL, then this routine
  124.     allocates a buffer in the application heap. If you pass a
  125.     copy buffer to this routine, make its size a multiple of 512
  126.     ($200) bytes for optimum performance.
  127.     
  128.     srcSpec            input:    An FSSpec record specifying the source file.
  129.     dstSpec            input:    An FSSpec record specifying the destination
  130.                             directory.
  131.     copyName        input:    Points to the new file name if the file is
  132.                             to be renamed or nil if the file isn't to
  133.                             be renamed.
  134.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  135.                             is used the i/o buffer for the copy or
  136.                             nil if you want FileCopy to allocate its
  137.                             own buffer in the application heap.
  138.     copyBufferSize    input:    The size of the buffer pointed to
  139.                             by copyBufferPtr.
  140.     preflight        input:    If true, FSpFileCopy makes sure there are
  141.                             enough allocation blocks on the destination
  142.                             volume to hold both the data and resource forks
  143.                             before starting the copy.
  144. */
  145.  
  146. /*****************************************************************************/
  147.  
  148. #endif
  149.