'=========================================================================== ' Subject: FILE COPY Date: 10-28-95 (00:00) ' Author: Thomas Gohel Code: PB ' Origin: comp.lang.basic.misc Packet: DOS.ABC '=========================================================================== '> Here's a way to COPY in PowerBASIC. It's very fast. '> close #1: open "trypb3.exe" for binary as #1 '> close #2: open "test.out" for binary as #2 '... but not with the date/time stamps '************************************************************************* ' ' FileCopy in PowerBASIC 3.0/3.2 ' ' public domain, von/by Thomas Gohel, GERMANY ' ' http://www.snafu.de/~pbsound - author@pbsound.snafu.de ' '************************************************************************* DECLARE SUB FileCopy(Quelle$,Ziel$) SHARED FileCopyError% PRINT PRINT PRINT "FileCopy mit/with PowerBASIC 3.0/3.2";TAB(53);"(c) 1994/95 von/by Thomas Gohel"; PRINT FileCopy "C:\DOS\COMMAND.COM", "C:\TEMP\KILL.ME" IF FileCopyError% > 0 THEN PRINT "Es ist ein Fehler aufgetreten/error detected!" END IF END SUB FileCopy(Quelle$,Ziel$) public LOCAL QuellHandle%, ZielHandle% LOCAL DateiDatum%, DateiZeit% LOCATE , 3: PRINT "Kopiere/Copying: ";Quelle$ LOCATE , 3: PRINT " nach/to: ";Ziel$ '*** Variablen Init *** Quelle$ = Quelle$ + CHR$(0) Ziel$ = Ziel$ + CHR$(0) QuelleSeg% = STRSEG(Quelle$) QuelleOff% = STRPTR(Quelle$) ZielSeg% = STRSEG(Ziel$) ZielOff% = STRPTR(Ziel$) Buffer% = 32000 Copy$ = STRING$(32000, 0) CopySeg% = STRSEG(Copy$) CopyOff% = STRPTR(Copy$) '*** Quell-Datei öffnen / open source file *** ! push ds ! mov ax, &h3d90 ! mov dx, QuelleOff% ! mov ds, QuelleSeg% ! int &h21 ! pop ds ! jnc QuellFileOpenOk FileCopyError% = 1 EXIT SUB QuellFileOpenOk: ! mov QuellHandle%, ax '*** Ziel-Datei öffnen / open destination file *** ! push ds ! mov ax, &h3c00 ! mov cx, &h0 ! mov dx, ZielOff% ! mov ds, ZielSeg% ! int &h21 ! pop ds ! mov ZielHandle%, ax ! jnc ZielFileOpenOk FileCopyError% = 1 EXIT SUB ZielFileOpenOk: '*** Quell-Datei einlesen / read source file *** DO WHILE Buffer% = 32000 ! push ds ! mov ax, &h3F00 ! mov bx, QuellHandle% ! mov cx, Buffer% ! mov dx, CopyOff% ! mov ds, CopySeg% ! int &h21 ! pop ds ! mov Buffer%, ax ! jnc ReadOk FileCopyError% = 1 EXIT SUB ReadOk: '*** Ziel-Datei schreiben / write destination file *** ! push ds ! mov ax, &h4000 ! mov bx, ZielHandle% ! mov cx, Buffer% ! mov dx, CopyOff% ! mov ds, CopySeg% ! int &h21 ! pop ds ! mov Buffer%, ax ! jnc WriteOk FileCopyError% = 1 EXIT SUB WriteOk: LOOP '*** Quell-Datei Datum lesen / read time/date *** ! mov ax, &h5700 ! mov bx, QuellHandle% ! int &h21 ! mov DateiZeit%, cx ! mov DateiDatum%, dx ! jnc LeseZeitOk FileCopyError% = 1 EXIT SUB LeseZeitOk: '*** Ziel-Datei Datum schreiben / write date/time *** ! mov ax, &h5701 ! mov bx, ZielHandle% ! mov cx, DateiZeit% ! mov dx, DateiDatum% ! int &h21 ! jnc SchreibeZeitOk FileCopyError% = 1 EXIT SUB SchreibeZeitOk: '*** Quell- & Ziel-Datei schließen / close files *** CloseAllFiles: ! mov ax, &h3E00 ! mov bx, QuellHandle% ! int &h21 ! jnc QuellFileCloseOk FileCopyError% = 1 EXIT SUB QuellFileCloseOk: ! mov ax, &h3E00 ! mov bx, ZielHandle% ! int &h21 ! jnc ZielFileCloseOk FileCopyError% = 1 EXIT SUB ZielFileCloseOk: END SUB '*************************************************************************