FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DISK I/O

Backup data files


Here are the functions that do the backup. They worked ok for me over a network, but I can't guarantee them. These have had most of the interface clipped out of them. If somebody wants the full shebang, let me know.

I suspect that to copy the full file you just have to read/write the resource fork ??? Anybody know.....

gBKUPChunkSize& = SYSTEM(_memAvail) - 24000
IF gBKUPChunkSize& > 50000 THEN gBKUPChunkSize& = 50000
gBKUPMemPtr& = FN NEWPTR (gBKUPChunkSize&)

CLEAR LOCAL
  DIM rect;8
LOCAL FN ClearThermometer(rect;8)
CALL INSETRECT(rect,1,1)
PEN 1, 1,1, 8, 0
LONG COLOR -1,-1,-1
CALL PAINTRECT(rect)
PEN 1, 1,1, 8, 0
LONG COLOR 0, 0, 0
END FN

CLEAR LOCAL
  DIM rect;8
LOCAL FN DisplayThermometer(rect;8,Temp!)
PEN 1,1,1,8,0
Wide% = rect.right - rect.left
Position% = rect.left + Temp! / 100 * Wide%
CALL FRAMERECT(rect)
CALL INSETRECT(rect,1,1)
rect.right = Position%
BOX FILL rect.left, rect.top TO rect.right,rect.bottom
END FN

CLEAR LOCAL
  DIM Counter%
  DIM rect;8
  DIM Temp!
  DIM count!
  DIM numch!
  DIM FileSize&
  DIM NumChunks%
  DIM LastChunkSize&
LOCAL FN BackupFile (FromFile$,ToFile$,FromRefNum%,ToRefNum%)

CALL SETRECT(rect, 15, 150, 485, 165)' thermo rect
DEF OPEN "AdMnDetr"
EDIT$(202) = FromFile$
OPEN "N", #_FromFileID, FromFile$, 1, FromRefNum%
FileSize& = LOF (_FromFileID, 1)
Scratch& = FileSize&
NumChunks% = 0
WHILE Scratch& > 0
INC(NumChunks%)
LastChunkSize& = Scratch&
Scratch& = Scratch& - gBKUPChunkSize&
WEND
LONG IF NumChunks% > 0
err% = FN xFileExists%(ToFile$,ToRefNum%)
LONG IF err% = 0
KILL ToFile$,ToRefNum%
END IF
OPEN "N", #_ToFileID, ToFile$, 1, ToRefNum%
LONG IF NumChunks% > 1
FOR Counter% = 1 TO (NumChunks% - 1)
READ FILE #_FromFileID,gBKUPMemPtr&, gBKUPChunkSize&
WRITE FILE #_ToFileID,gBKUPMemPtr&, gBKUPChunkSize&
count! = Counter%
numch! = NumChunks%
Temp! = (count!/numch!) * 100
FN xDisplayThermometer ( @rect, Temp!)
NEXT
END IF
LONG IF LastChunkSize& > 0
READ FILE #_FromFileID,gBKUPMemPtr&, LastChunkSize&
WRITE FILE #_ToFileID,gBKUPMemPtr&, LastChunkSize&
Temp! = 100
FN xDisplayThermometer ( @rect, Temp!)
END IF
FN xClearThermometer(@rect)
CLOSE #_ToFileID
END IF
CLOSE #_FromFileID
END FN

TRON FN

LOCAL FN TotalBackup (FromFolder$,ToFolder$,FRefNum%,TRefNum%,level)
FOR x = 1 TO 3000
RefNum% = FRefNum%
FromFile$ = FILES$(-x, "",FromFolder$, RefNum%)
LONG IF LEN (FromFile$)
LONG IF INSTR(1,FromFile$,":") 'is a folder
newFromFolder$ = FromFolder$ + FromFile$
newFRefNum% = FOLDER(newFromFolder$,0)
newToFolder$ = ToFolder$ + FromFile$
newTRefNum% = FOLDER(newToFolder$,0)
LONG IF newTRefNum% = 0
RefNum% = TRefNum%
newTRefNum% = FOLDER(newToFolder$,RefNum%)
END IF
FN TotalBackup (newFromFolder$,newToFolder$,newFRefNum%,newTRefNum%,level+1)
XELSE
ToFile$ = FromFile$
FN BackupFile (FromFile$,ToFile$,FRefNum%,TRefNum%)
END IF
XELSE
x = 3000
END IF
NEXT
'CLOSE FOLDER TRefNum%' might crash on multiple backups
END FN

PS I _know_ BackupFile works, I'm not so sure about ToTalBackup, The recursion does my head in.

Ian Mann