home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / vdl020d.zip / VCOPY.DOC < prev    next >
Text File  |  1993-04-14  |  11KB  |  312 lines

  1. {
  2.  ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix File Copy Unit (VCOPY)
  5.  Copyright 1991,92,93 Visionix
  6.  ALL RIGHTS RESERVED
  7.  
  8.  ────────────────────────────────────────────────────────────────────────────
  9.  
  10.  Revision history in reverse chronological order:
  11.  
  12.  Initials  Date      Comment
  13.  ────────  ────────  ────────────────────────────────────────────────────────
  14.  
  15.  mep       03/26/93  Fixed bug with "Append" command.  Also added use of
  16.                      VType.maxArrSize variable.
  17.  
  18.  mep       03/23/93  Updated show parameter and added to "CallBack" stuff.
  19.  
  20.  mep       03/12/93  Added External "CallBack" Procedure for user interface.
  21.  
  22.  mep       02/12/93  Fixed bug with ListFile (EOF).
  23.  
  24.  mep       02/11/93  Cleaned up code for beta release
  25.  
  26.  jrt       02/08/93  Sync with beta 0.12 release
  27.  
  28.  mep       01/24/93  Few minor bug fixes.
  29.  
  30.  mep       12/22/92  General cleanup of code.
  31.  
  32.  mep       12/18/92  Deleted: SHOWFILES, SHOWATTR.
  33.                      Added: SHOW=FADTPS
  34.  
  35.  mep       12/16/92  Now allowed to place wildcards, target paths, and
  36.                        additional parameters per line in a list file
  37.                        (see below for usage).
  38.                      Ranged dates are now allowed by using multiple
  39.                        DATE/TIME parameter fields.
  40.                      Added new parameters: DATEOA, DATEOB, TIMEOA, and TIMEOB.
  41.  
  42.  mep       12/09/92  New functionality throughout unit.
  43.                      Fixed VCopySetFlag and VCopyClearFlag to work with
  44.                        the LongInt flag.  Also fixed some bugs.
  45.                      Added new parameters: TESTMODE, TARGETDIRONLY,
  46.                        and SHOWATTR.
  47.                      Added @ListFile for selected file copies.
  48.                      Changed MAKEDIR command to MAKETARGETDIR.
  49.  
  50.  mep       12/06/92  Moved some functions to VGen
  51.  
  52.  jrt       11/21/92  Sync with beta 0.08
  53.  
  54.  mep       11/19/92  Added most of the planned functionality.
  55.  
  56.  mep       11/04/92  First logged revision.
  57.  
  58.  ────────────────────────────────────────────────────────────────────────────
  59. }
  60.  
  61. Unit VCopy;
  62.  
  63.  
  64. Uses
  65.  
  66.   DOS,
  67.   VTypes,
  68.   VGen,
  69.   VDOSHigh,
  70.   VDates;
  71.  
  72. Const
  73.  
  74.   {-------------------}
  75.   { VCopy error codes }
  76.   {-------------------}
  77.  
  78.   erVCopy_None             = 0;
  79.   erVCopy_SamePath         = 1;
  80.   erVCopy_NoExistFileFrom  = 2;
  81.   erVCopy_NoExistFileTo    = 3;
  82.   erVCopy_NoExistDirFrom   = 4;
  83.   erVCopy_NoExistDirTo     = 5;
  84.   erVCopy_NoRoom           = 6;
  85.   erVCopy_Timeout          = 7;
  86.   erVCopy_ListFileNotFound = 9;
  87.   erVCopy_TargetPathIsFile = 10;
  88.  
  89. Const
  90.  
  91.   {---------------------------}
  92.   { Call Back Events          }
  93.   {                           }
  94.   { HiWord = Selective Events }
  95.   { LoWord = Global Events    }
  96.   {---------------------------}
  97.  
  98.   cbeSourceOpen       = $00000001;
  99.   cbeTargetOpen       = $00000002;
  100.   cbeReadBlock        = $00000004;
  101.   cbeWriteBlock       = $00000008;
  102.   cbeExternReadBlock  = $00010000;
  103.   cbeExternWriteBlock = $00020000;
  104.   cbeSourceClose      = $00000010;
  105.   cbeTargetClose      = $00000020;
  106.   cbeIOErr            = $00000040;
  107.   cbeVCopyErr         = $00000080;
  108.  
  109.   cbeAll              = $0000FFFF;
  110.  
  111. Type
  112.  
  113.   TCopyCallBackInfo = RECORD
  114.  
  115.     Event     : LONGINT;
  116.     StrParam  : PSTRING;
  117.     NumParam1 : LONGINT;
  118.     NumParam2 : LONGINT;
  119.     PtrParam1 : POINTER;
  120.     RetCode   : LONGINT
  121.  
  122.   END;
  123.   PCopyCallBackInfo = ^TCopyCallBackInfo;
  124.  
  125.   {----}
  126.  
  127.   TCopyCallBackProc = Procedure( CBI : PCopyCallBackInfo );
  128.   PCopyCallBackProc = ^TCopyCallBackProc;
  129.  
  130. {────────────────────────────────────────────────────────────────────────────}
  131.  
  132. Function VCopyFileEx(   stPathFrom  : PathStr;
  133.                         stPathTo    : PathStr;
  134.                         Params      : STRING;
  135.                         CBFlags     : LONGINT;
  136.                         CBProc      : PCopyCallBackProc   ) : INTEGER;
  137.  
  138. Function VCopyFile(     stPathFrom  : PathStr;
  139.                         stPathTo    : PathStr;
  140.                         Params      : STRING     ) : INTEGER;
  141.  
  142. { ══════════════════════════════════════════════════════════════════════════
  143.  
  144.   stPathFrom ... [d:][path]filespec(s) for source of copy.  Wildcards allowed.
  145.  
  146.                         or
  147.  
  148.              ... @[d:][path]listfile - get filespec(s) from this text file.
  149.                  (see notes below).
  150.  
  151.   stPathTo   ... [d:][path]filespec(s) for target.  Wildcard-mask allowed.
  152.  
  153.   Params     ... the 23 defined parameters:
  154.  
  155.     MOVE             Move instead of copy.
  156.  
  157.     NOOVERWRITE      Do not overwrite duplicate target file.
  158.  
  159.     SUBDIR           Copy source directory and all subdirectories.
  160.  
  161.     SHOW=FADTPS      Show each file's general info:
  162.                        Filename, Attributes, Date, Time, Packed-date, or Size.
  163.  
  164.     ATTR=ASHR        Search mask for source attributes types:
  165.                        Archive, System, Hidden, and Readonly
  166.  
  167.     EXACTATTR        Each found source file needs to be exactly the above
  168.                        attribute mask in order to be copied.
  169.  
  170.     NEWER            Copy only if target doesn't exist or source is newer.
  171.  
  172.     SHARE            Use file-sharing/locking for copy.
  173.  
  174.     TIMEOUT=SSS      Timeout for events (like SHARE).
  175.  
  176.     APPEND           Append source file(s) to single target file.
  177.  
  178.     DATE=MM-DD-YY    Copy file(s) ON this date.
  179.  
  180.     DATEB=MM-DD-YY   Copy file(s) BEFORE this date.
  181.  
  182.     DATEA=MM-DD-YY   Copy file(s) AFTER this date.
  183.  
  184.     DATEOB=MM-DD-YY  Copy file(s) ON or BEFORE this date.
  185.  
  186.     DATEOA=MM-DD-YY  Copy file(s) ON or AFTER this date.
  187.  
  188.     TIME=HH:MM       Copy file(s) AT this time.
  189.  
  190.     TIMEB=HH:MM      Copy file(s) BEFORE this time.
  191.  
  192.     TIMEA=HH:MM      Copy file(s) AFTER this time.
  193.  
  194.     TIMEOB=HH:MM     Copy file(s) ON or BEFORE this time.
  195.  
  196.     TIMEOA=HH:MM     Copy file(s) ON or AFTER this time.
  197.  
  198.     MAKETARGETDIR    Create the target directory if it does not exist.
  199.                        Otherwise, stPathTo will be thought as the target
  200.                        filename (wildcard) mask.
  201.  
  202.     TARGETDIRONLY    Do not create target subdirectories to match source
  203.                        subdirectories; instead, copy all source filespecs
  204.                        only to the main target directory.
  205.  
  206.     TESTMODE         Do everything as usual except the actual copying.
  207.  
  208.   --------------------------------------------------------------------------
  209.  
  210.   NOTES:
  211.  
  212.   ■ There are no set order for parameters to be passed in - only that
  213.       there be no spaces in the string and that commas are used between
  214.       all parameters.
  215.  
  216.   ■ Share parameter is for network environments, where a source/target file
  217.       might be opened by someone else.  In order to insure system integrity,
  218.       VCopy will keep polling on the file until it becomes available or a
  219.       timeout occurs.
  220.  
  221.   ■ Timeout for events defaults to 30 seconds.
  222.  
  223.   ■ VCopy is fully compliant with VMulti for background file and multiple
  224.     file copying.
  225.  
  226.   ■ When using a listfile, it is a valid ASCII file containing line-by-line
  227.       valid filenames (including exact path if not in default directory)
  228.       with three parameters per line (the second two are optional) -
  229.       (1) Source filespec, (2) target filespec, and (3) additional parameters.
  230.       Spacing between these three parameters is not significant.
  231.  
  232.       Usage: SourcePath [TargetPath] [/AdditionalParams]
  233.  
  234.       Although the TargetPath is optional (defaults to stPathTo if
  235.       not present), the SourcePath must be present for a copy to occur.
  236.  
  237.       If additional parameters are needed for a specific line, just
  238.       add them the same way the parameters are originally passed in,
  239.       except remember to add a "/" BEFORE the additional parameter list.
  240.  
  241.   EXAMPLES:
  242.  
  243.   #1  Copy COMMAND.COM to drive E root directory.
  244.  
  245.       VCopyFile('C:\COMMAND.COM','E:\','');
  246.  
  247.   #2  Move all of drive D to drive E's TEST directory and show files.
  248.         It will create directory TEST if not there.  In addition, this
  249.         will create all of the target directories under the main source
  250.         directory and place the target files accordingly.
  251.  
  252.       VCopyFile('D:\', 'E:\TEST', 'MOVE,SUBDIR,MAKETARGETDIR,SHOW=F');
  253.  
  254.   #3  Copy all files with ONLY the Hidden and System attributes set
  255.         from drive C to drive A.
  256.  
  257.       VCopyFile('C:\', 'A:\', 'SUBDIR,SHOW=F,ATTR=HS,EXACTATTR');
  258.  
  259.   #4  Copy all files in subdirectory DOS that match the wildcard pattern
  260.         to subdirectory B (create if not exist) with a different mask.
  261.  
  262.       VCopyFile('\DOS\*.COM', '\B\*.BIN', 'SHOW=F,MAKETARGETDIR');
  263.  
  264.   #5  Copy all files from subdirectory TEST1 to subdirectory TEST2
  265.         in week of 01-03-93 to 01-09-93.  Note that these directories
  266.         are considered in the "current/default" directory; if not, make
  267.         sure the full path for each is supplied.
  268.  
  269.       VCopyFile('TEST1', 'TEST2', 'DATEOA=01-03-93,DATEOB=01-09-93');
  270.  
  271.   #6  Copy all of drive D to drive E's TEST directory and show files.
  272.         (see example #2).  The difference is that the target directories
  273.         will not be created; rather, all of the matching source files
  274.         will only go into the TEST directory.
  275.  
  276.       VCopyFile('D:\', 'E:\TEST', 'SUBDIR,MAKETARGETDIR,TARGETDIRONLY,SHOW=F');
  277.  
  278.   #7  Copy all the files inside listfile C:\DIR.LST into subdirectory
  279.         D:\TEST with default parameters - each line will add to this set.
  280.  
  281.       VCopyFile('@C:\FILE.LST', 'D:\TEST', 'SHOW=F,TARGETDIRONLY' );
  282.  
  283.       The listfile 'C:\FILE.LST' looks like this:
  284.       ---
  285.       C:\WINDOWS\HIMEM.SYS
  286.       F:\WP51\*.*   C:\WP51         /MAKETARGETDIR,SUBDIR,SHOW=A
  287.       C:\DOS\C*.*  D:\SHIP\*.BAT
  288.       ---
  289.  
  290.       The first pathspec "C:\WINDOWS\HIMEM.SYS" will be copied to
  291.         directory D:\TEST.
  292.  
  293.       The second pathspec "F:\WP51\*.*" will copy all files in and under
  294.         that subdirectory to drive C subdirectory WP51 (and create it if
  295.         it doesn't exist), while showing each file's attribute set.
  296.  
  297.       The third pathspec "C:\DOS\C*.*" will copy all files that match
  298.         the wildcards to D:\SHIP while renaming all files to *.BAT.  Note
  299.         that the additional parameters toggled on the second line did not
  300.         occur on this line.
  301.  
  302.  
  303.   KNOWN BUGS:
  304.  
  305.   ■ In TestMode, the SubDir (actual directory creation/removal), NoOverwrite
  306.     and Newer flags do not function.
  307.  
  308.   ══════════════════════════════════════════════════════════════════════════ }
  309.  
  310. {────────────────────────────────────────────────────────────────────────────}
  311.  
  312.