home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / basic / bmag / copyfile.bas < prev    next >
Encoding:
BASIC Source File  |  1994-04-15  |  1.9 KB  |  60 lines

  1. '─ Area: F-QUICKBASIC ─────────────────────────────────────────────────────────
  2. '  Msg#: 386                                          Date: 12 Apr 94  15:46:00
  3. '  From: Blair Colbey                                 Read: Yes    Replied: No 
  4. '    To: Mark Pruitt                                  Mark:                     
  5. '  Subj: Re: High Speed Qb
  6. '──────────────────────────────────────────────────────────────────────────────
  7. 'MP>I'd be really interested in seeing the "copy files with no shelling" and
  8. 'MP>"file exist" things if you could be convinced to dig 'em out and post
  9. 'MP>'em.
  10.  
  11. DECLARE FUNCTION CopyFile% (Source$, Dest$)
  12. '*************************************************************************
  13. DIM regs AS RegType
  14.  
  15.      SFileNum = FREEFILE
  16.      OPEN Source$ FOR BINARY AS #SFileNum
  17.  
  18.      DFileNum = FREEFILE
  19.      OPEN Dest$ FOR BINARY AS #DFileNum
  20.  
  21.      DO
  22.         Buffer$ = INPUT$(Block, #SFileNum)
  23.         PUT #DFileNum, , Buffer$
  24.      LOOP UNTIL EOF(SFileNum)
  25.  
  26.      regs.ax = &H5700
  27.      regs.bx = FILEATTR(SFileNum, 2)
  28.      INTERRUPT &H21, regs, regs
  29.  
  30.      IF (regs.flags AND 1) THEN
  31.         CLOSE #SFileNum, #DFileNum
  32.         KILL Dest$
  33.         CopyFile% = 3
  34.         EXIT FUNCTION
  35.      END IF
  36.  
  37.      regs.ax = &H5701
  38.      regs.bx = FILEATTR(DFileNum, 2)
  39.      INTERRUPT &H21, regs, regs
  40.  
  41.      IF (regs.flags AND 1) THEN
  42.         CLOSE #SFileNum, #DFileNum
  43.         KILL Dest$
  44.         CopyFile% = 3
  45.         EXIT FUNCTION
  46.      END IF
  47.  
  48.      CLOSE #SFileNum, #DFileNum
  49.      CopyFile% = 0
  50. END FUNCTION
  51.  
  52. 'Now here is what you use to call it! Note! Be sure to use a file exist
  53. 'to make sure the files are there before you try to copy them.
  54.  
  55. 'Here is is
  56. CONST Block = 4096   'leave it at this size no bigger
  57. Dumb = CopyFile("C:\AUTOEXEC.BAT", "C:\TEMP\ZZ.TXT")
  58. 'That's it you can rename the file as you copy of you want. i like this
  59. 'routine since you don't have to shell to dos!.
  60.