home *** CD-ROM | disk | FTP | other *** search
- '─ Area: F-QUICKBASIC ─────────────────────────────────────────────────────────
- ' Msg#: 441 Date: 14 Apr 94 00:58:00
- ' From: Howard Hull Jr Read: Yes Replied: No
- ' To: Blair Colbey Mark:
- ' Subj: Re: High Speed Qb
- '──────────────────────────────────────────────────────────────────────────────
- 'BC>MP>I'd be really interested in seeing the "copy files with no shelling" and
- 'BC>MP>"file exist" things if you could be convinced to dig 'em out and post
- 'BC>MP>'em.
-
- ' Blair here is a quick routine that seems a little simpler. at least
- 'for me it is. It uses the main theory with some minor differences.
- 'Then again how many different Copy functions can there be.
-
- DEFINT A-Z
- DECLARE FUNCTION CopyIt% (FromFile$, ToFile$)
- '$INCLUDE: '\QB\QB.BI'
- CONST TRUE = -1, FALSE = NOT TRUE
-
- Ct = CopyIt(From$, ToFil$)
- END
-
-
- FUNCTION CopyIt% (FromFile$, ToFile$)
- From = FREEFILE
- Tof = FREEFILE
- OPEN FromFile$ FOR BINARY AS #From
- OPEN ToFile$ FOR BINARY AS #Tof
- '---- 32000 is a made-up number and can be changed to suit your needs
- '---- it can not be larger than 32766, and all instances must be changed
- IF LOF(From) >= 32000 THEN
- Counts = LOF(From) \ 32000
- Extra = LOF(From) MOD 32000
- ELSEIF LOF(From) < 32000 THEN
- Counts = 0
- Extra = LOF(From)
- END IF
- FOR A = 1 TO Counts ' This loop will be skipped if Counts = 0
- BigSpace$ = SPACE$(32000)
- GET #From, , BigSpace$
- PUT #Tof, , BigSpace$
- NEXT A
- BigSpace$ = "" ' erase BigSpace$ to release memory
- SmallSpace$ = SPACE$(Extra)
- GET #From, , SmallSpace$
- PUT #2, , SmallSpace$
- SmallSpace$ = "" ' erase SmallSpace$ to release memory
- CLOSE Tof, From ' Close files
-
- '------ Change new files attributes to coencide with old one's.
- DIM Reg AS RegTypeX
- ZFrom$ = From$ + CHR$(0)
- Reg.ax = &H4300 ' Get file attributes
- Reg.ds = VARSEG(ZFrom$)
- Reg.dx = SADD(ZFrom$)
- INTERRUPTX &H21, Reg, Reg ' Call the interrupt to get attribute
-
- IF Reg.flags AND 1 then 'Error occurred so return it
- CopyIt = Reg.ax
- EXIT FUNCTION
- ELSE
- Attributes = Reg.cx
- END IF
- ZTo$ = To$ + CHR$(0)
- Reg.ax = &H4301 ' Set attributes
- Reg.cx = Attributes
- Reg.ds = VARSEG(ZTo$)
- Reg.dx = SADD(ZTo$)
- INTERRUPTX &H21, Reg, Reg ' Call the interrupt to set attribute
-
- IF Reg.flags AND 1 then 'Error occurred so return it
- CopyIt = Reg.ax
- EXIT FUNCTION
- ELSE
- END IF
-
- END FUNCTION
-