home *** CD-ROM | disk | FTP | other *** search
- ********************
-
- FUNCTION Restoring
-
- PARAMETERS _rrow, _rcol, _fromdrive, _todrive
-
- IF PCOUNT() < 2
- RETURN(.F.)
- ELSEIF PCOUNT() = 2
- _fromdrive = "A:"
- _todrive = ""
- ELSEIF PCOUNT() = 3
- IF TYPE("_fromdrive") != "C"
- RETURN(.F.)
- ELSEIF LEN(_fromdrive) > 2
- RETURN(.F.)
- ENDIF
- _todrive = ""
-
- ELSEIF PCOUNT() = 4
- IF TYPE("_fromdrive") != "C"
- RETURN(.F.)
- ELSEIF LEN(_fromdrive) > 2
- RETURN(.F.)
- ENDIF
-
- IF TYPE("_todrive") != "C"
- RETURN(.F.)
- ELSEIF LEN(_todrive) < 2
- RETURN(.F.)
- ENDIF
- _todrive = STRTRAN(_todrive + "\", "\\", "\")
- _todrive = SUBSTR(_todrive, 1, LEN(_todrive)-1)
- IF !VALID_PATH(_todrive)
- RETURN(.F.)
- ELSE
- _todrive = _todrive + "\"
- ENDIF
-
- ELSEIF TYPE("_rrow") + TYPE("_rcol") != "NN"
- RETURN(.F.)
- ENDIF
-
- * Prompt to ask to back up from what drive.
- * Insert the disk.
- * check the disk to see if it is in proper disk order number
- * acquire thye number of disks in operation
- * hold previous name and current name for changing of disks
-
- _fromdrive = IF((TYPE("_fromdrive") = "U"), "A:", _fromdrive)
- _theret = .T.
-
- WINDOWPUSH(_rrow, _rcol, _rrow + 6, _rcol + 40)
- DO WHILE .T.
- CLEAR_AREA()
- WSAYGET(.T.,2,2,"Drive to RESTORE from => ", "_fromdrive", "!:", "VALID_DR(SUBSTR(_fromdrive, 1, 1))")
- CLEAR_AREA()
- IF LASTKEY() = 27 .OR. _fromdrive = " :"
- EXIT
- ELSE
- IF !FILE(_fromdrive + "BACKUPID")
- WSAYGET(2,1,"Not a PROPER disk. Choose another")
- WSAYGET(3,1," disk or drive. Press any key to")
- WSAYGET(4,1," continue or 'Q' to Quit.")
- IF QWAIT("Q")
- _theret = .F.
- EXIT
- ELSE
- KEYBOARD CHR(13)
- ENDIF
- ELSEIF VAL(PARSING(MEMOREAD(_fromdrive + "BACKUPID"))) != 1
- WSAYGET(2,1," Disk is not in proper order.")
- WSAYGET(3,1,"Choose another disk and press any")
- WSAYGET(4,1," key ot 'Q' to Quit.")
- IF QWAIT("Q")
- _theret = .F.
- EXIT
- ELSE
- KEYBOARD CHR(13)
- ENDIF
- ELSE
- IF !RESTING()
- _theret = .F.
- EXIT
- ENDIF
- ENDIF
- ENDIF
- ENDDO
- Windowpop()
- RETURN(_theret)
-
- ******************
-
- FUNCTION Resting
-
- PRIVATE _resttemp, _restlast, _restnow
-
- * _resttemp is the contents of the backupid file
- * _restlast is the last file copied
- * _restnow is the current file being copied
-
- _restlast = ""
- _restnew = ""
- _resttemp = ""
- _resttemp = MEMOREAD(_fromdrive + "BACKUPID")
- _restst = VAL(PARSING(@_resttemp)) && Beginning disk number
- _restend = VAL(PARSING(@_resttemp)) && Ending disk Number
- _rf1 = 0 && Restoring file handles
- _rf2 = 0 && Restoring file handles
- FOR _restx = 1 TO _restend
- CLEAR_AREA()
- IF !FILE(_fromdrive + "BACKUPID")
- WSAYGET(2,1,"Not a PROPER disk. Choose another")
- WSAYGET(3,1," disk or drive. Press any key to")
- WSAYGET(4,1," continue or 'Q' to Quit.")
- IF QWAIT("Q")
- RETURN(.F.)
- ENDIF
- _restx = _restx - 1
- LOOP
- ENDIF
- _resttemp = MEMOREAD(_fromdrive + "BACKUPID")
- IF VAL(PARSING(_resttemp)) != _restx
- WSAYGET(2,1," Disk is not in proper order.")
- WSAYGET(3,1,"Choose another disk and press any")
- WSAYGET(4,1," key or 'Q' to Quit.")
- IF QWAIT("Q")
- RETURN(.F.)
- ENDIF
- _restx = _restx - 1
- LOOP
- ENDIF
- _restst = PARSING(@_resttemp)
- _restend = PARSING(@_resttemp)
- DO WHILE !EMPTY(_resttemp)
- CLEAR_AREA(WROW(1), _rcol, _rrow + 6, _rcol + 40)
- _restlast = _restnew
- _restnew = PARSING(@_resttemp)
- IF _restlast = _restnew && Still copying over the rest of the file
- WSAYGET(2,2,"Still working on " + _restnew)
- * open the new file and keep on copying
- ELSE
- WSAYGET(2,2,"Now Restoring File " + _restnew)
- IF !EMPTY(_rf1)
- FCLOSE(_rf1)
- ENDIF
- _rf1 = FCREATE(_todrive + _restnew)
- ENDIF
- _rf2 = FOPEN(_fromdrive + _restnew)
- IF !EMPTY(FERROR())
- RESTERR()
- RETURN(.F.)
- ENDIF
- DO WHILE .T.
- _restsp = SPACE(1024)
- _restrd = FREAD(_rf2, @_restsp, 1024)
- WSAYGET(3,2,"Writing out " + LTRIM(STR(FPOSIT(_rf1))) + " bytes ")
- FWRITE(_rf1, _restsp, _restrd)
- IF _restrd != 1024 && Didn't read all of 1K
- EXIT
- ENDIF
- ENDDO
- FCLOSE(_rf2)
- ENDDO
- IF TYPE("_restend") != "N"
- _restend = VAL(_restend)
- ENDIF
- CLEAR_AREA()
- IF _restx != _restend
- WSAYGET(2,2,"Insert the next disk for the")
- WSAYGET(3,2," Restoring Procedure")
- INKEY(0)
- ELSE
- WSAYGET(2, 2, "Operation is complete. Any")
- WSAYGET(3, 2, " key to continue....")
- INKEY(0)
- KEYBOARD CHR(27)
- ENDIF
- NEXT
- RETURN(.T.)
-
- *******************
-
- FUNCTION Resterr
-
- CLEAR_AREA()
- WSAYGET(2,1," The restoring procedure have")
- WSAYGET(3,1,"experienced an error. Operation")
- WSAYGET(4,1," aborting. Any key to continue.")
- INKEY(0)
- RETURN(.F.)