home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / copymove.swg / 0012_Move File FAST.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-05-28  |  1.5 KB  |  58 lines

  1. {$S-,R-,V-,I-,N-,B-,F-}
  2.  
  3. {$IFNDEF Ver40}
  4.   {Allow overlays}
  5.   {$F+,O-,X+,A-}
  6. {$ENDIF}
  7.  
  8. UNIT MoveFile;
  9.  
  10. INTERFACE
  11.  
  12. USES Dos;
  13.  
  14. FUNCTION MoveFiles ( VAR OldFullPath : PathStr;
  15.                      VAR NewFullPath : PathStr) : BOOLEAN;
  16.  
  17. IMPLEMENTATION
  18.  
  19.  
  20. FUNCTION MoveFiles ( VAR OldFullPath : PathStr;
  21.                      VAR NewFullPath : PathStr) : BOOLEAN;
  22.  
  23. VAR
  24.   regs : REGISTERS;
  25.   Error_Return,
  26.   N      : BYTE;
  27.  
  28.   PROCEDURE MoveToNewPath;
  29.   { On same disk drive }
  30.   BEGIN
  31.   OldFullPath [LENGTH (OldFullPath) + 1] := CHR (0);
  32.   NewFullPath [LENGTH (NewFullPath) + 1] := CHR (0);
  33.   WITH regs DO
  34.     BEGIN
  35.       DS := SEG (OldFullPath);
  36.       DX := OFS (OldFullPath) + 1;  {the very first byte is the length}
  37.       ES := SEG (NewFullPath);
  38.       DI := OFS (NewFullPath) + 1;
  39.       AX := $56 SHL 8;               { ERRORS are             }
  40.       INTR ($21, regs);                {   2 : file not found   }
  41.       IF Flags AND 1 = 1 THEN        {   3 : path not found   }
  42.         error_return := AX           {   5 : access denied    }
  43.       ELSE                           {  17 : not same device  }
  44.         error_return := 0;
  45.     END;  {with}
  46.   END;
  47.  
  48. BEGIN
  49.   Error_Return := 0;
  50.   IF OldFullPath [1] = '\' THEN OldFullPath := FExpand (OldFullPath);
  51.   IF NewFullPath [1] = '\' THEN NewFullPath := FExpand (NewFullPath);
  52.   IF UPCASE (OldFullPath [1]) = UPCASE (NewFullPath [1]) THEN MoveToNewPath
  53.      ELSE Error_Return := 17;
  54.  
  55. MoveFiles := (Error_Return = 0);
  56. END;
  57.  
  58. END.