home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a075 / 1.img / TOOLKIT1.EXE / SST113.PRG < prev    next >
Encoding:
Text File  |  1989-10-17  |  5.7 KB  |  192 lines

  1. ********************
  2.  
  3. FUNCTION Restoring
  4.  
  5.    PARAMETERS _rrow, _rcol, _fromdrive, _todrive
  6.  
  7.    IF PCOUNT() < 2
  8.       RETURN(.F.)
  9.    ELSEIF PCOUNT() = 2
  10.       _fromdrive = "A:"
  11.       _todrive   = ""
  12.    ELSEIF PCOUNT() = 3
  13.       IF TYPE("_fromdrive") != "C"
  14.          RETURN(.F.)
  15.       ELSEIF LEN(_fromdrive) > 2
  16.         RETURN(.F.)
  17.       ENDIF
  18.       _todrive = ""
  19.  
  20.    ELSEIF PCOUNT() = 4
  21.       IF TYPE("_fromdrive") != "C"
  22.          RETURN(.F.)
  23.       ELSEIF LEN(_fromdrive) > 2
  24.         RETURN(.F.)
  25.       ENDIF
  26.  
  27.       IF TYPE("_todrive") != "C"
  28.          RETURN(.F.)
  29.       ELSEIF LEN(_todrive) < 2
  30.          RETURN(.F.)
  31.       ENDIF
  32.       _todrive = STRTRAN(_todrive + "\", "\\", "\")
  33.       _todrive = SUBSTR(_todrive, 1, LEN(_todrive)-1)
  34.       IF !VALID_PATH(_todrive)
  35.          RETURN(.F.)
  36.       ELSE
  37.          _todrive = _todrive + "\"
  38.       ENDIF
  39.  
  40.    ELSEIF TYPE("_rrow") + TYPE("_rcol") != "NN"
  41.       RETURN(.F.)
  42.    ENDIF
  43.  
  44.    * Prompt to ask to back up from what drive.
  45.    * Insert the disk.
  46.    * check the disk to see if it is in proper disk order number
  47.    * acquire thye number of disks in operation
  48.    * hold previous name and current name for changing of disks
  49.  
  50.    _fromdrive = IF((TYPE("_fromdrive") = "U"), "A:", _fromdrive)
  51.    _theret  = .T.
  52.  
  53.    WINDOWPUSH(_rrow, _rcol, _rrow + 6, _rcol + 40)
  54.    DO WHILE .T.
  55.       CLEAR_AREA()
  56.       WSAYGET(.T.,2,2,"Drive to RESTORE from => ", "_fromdrive", "!:", "VALID_DR(SUBSTR(_fromdrive, 1, 1))")
  57.       CLEAR_AREA()
  58.       IF LASTKEY() = 27 .OR. _fromdrive = " :"
  59.          EXIT
  60.       ELSE
  61.          IF !FILE(_fromdrive + "BACKUPID")
  62.             WSAYGET(2,1,"Not a PROPER disk.  Choose another")
  63.             WSAYGET(3,1," disk or drive.  Press any key to")
  64.             WSAYGET(4,1,"    continue or 'Q' to Quit.")
  65.             IF QWAIT("Q")
  66.                _theret = .F.
  67.                EXIT
  68.             ELSE
  69.                KEYBOARD CHR(13)
  70.             ENDIF
  71.          ELSEIF VAL(PARSING(MEMOREAD(_fromdrive + "BACKUPID"))) != 1
  72.             WSAYGET(2,1,"  Disk is not in proper order.")
  73.             WSAYGET(3,1,"Choose another disk and press any")
  74.             WSAYGET(4,1,"     key ot 'Q' to Quit.")
  75.             IF QWAIT("Q")
  76.                _theret = .F.
  77.                EXIT
  78.             ELSE
  79.                KEYBOARD CHR(13)
  80.             ENDIF
  81.          ELSE
  82.             IF !RESTING()
  83.                _theret = .F.
  84.                EXIT
  85.             ENDIF
  86.          ENDIF
  87.       ENDIF
  88.    ENDDO
  89.    Windowpop()
  90.    RETURN(_theret)
  91.  
  92. ******************
  93.  
  94. FUNCTION Resting
  95.  
  96.    PRIVATE _resttemp, _restlast, _restnow
  97.  
  98.    * _resttemp is the contents of the backupid file
  99.    * _restlast is the last file copied
  100.    * _restnow is the current file being copied
  101.  
  102.    _restlast = ""
  103.    _restnew  = ""
  104.    _resttemp = ""
  105.    _resttemp = MEMOREAD(_fromdrive + "BACKUPID")
  106.    _restst   = VAL(PARSING(@_resttemp))              && Beginning disk number
  107.    _restend  = VAL(PARSING(@_resttemp))              && Ending disk Number
  108.    _rf1      = 0                                     && Restoring file handles
  109.    _rf2      = 0                                     && Restoring file handles
  110.    FOR _restx = 1 TO _restend
  111.       CLEAR_AREA()
  112.       IF !FILE(_fromdrive + "BACKUPID")
  113.          WSAYGET(2,1,"Not a PROPER disk.  Choose another")
  114.          WSAYGET(3,1," disk or drive.  Press any key to")
  115.          WSAYGET(4,1,"    continue or 'Q' to Quit.")
  116.          IF QWAIT("Q")
  117.             RETURN(.F.)
  118.          ENDIF
  119.          _restx = _restx - 1
  120.          LOOP
  121.       ENDIF
  122.       _resttemp = MEMOREAD(_fromdrive + "BACKUPID")
  123.       IF VAL(PARSING(_resttemp)) != _restx
  124.          WSAYGET(2,1,"  Disk is not in proper order.")
  125.          WSAYGET(3,1,"Choose another disk and press any")
  126.          WSAYGET(4,1,"     key or 'Q' to Quit.")
  127.          IF QWAIT("Q")
  128.             RETURN(.F.)
  129.          ENDIF
  130.          _restx = _restx - 1
  131.          LOOP
  132.       ENDIF
  133.       _restst   = PARSING(@_resttemp)
  134.       _restend  = PARSING(@_resttemp)
  135.       DO WHILE !EMPTY(_resttemp)
  136.          CLEAR_AREA(WROW(1), _rcol, _rrow + 6, _rcol + 40)
  137.          _restlast = _restnew
  138.          _restnew = PARSING(@_resttemp)
  139.          IF _restlast = _restnew         && Still copying over the rest of the file
  140.             WSAYGET(2,2,"Still working on " + _restnew)
  141.             * open the new file and keep on copying
  142.          ELSE
  143.             WSAYGET(2,2,"Now Restoring File " + _restnew)
  144.             IF !EMPTY(_rf1)
  145.                FCLOSE(_rf1)
  146.             ENDIF
  147.             _rf1 = FCREATE(_todrive + _restnew)
  148.          ENDIF
  149.          _rf2 = FOPEN(_fromdrive + _restnew)
  150.          IF !EMPTY(FERROR())
  151.             RESTERR()
  152.             RETURN(.F.)
  153.          ENDIF
  154.          DO WHILE .T.
  155.             _restsp = SPACE(1024)
  156.             _restrd = FREAD(_rf2, @_restsp, 1024)
  157.             WSAYGET(3,2,"Writing out " + LTRIM(STR(FPOSIT(_rf1))) + " bytes ")
  158.             FWRITE(_rf1, _restsp, _restrd)
  159.             IF _restrd != 1024                       && Didn't read all of 1K
  160.                EXIT
  161.             ENDIF
  162.          ENDDO
  163.          FCLOSE(_rf2)
  164.       ENDDO
  165.       IF TYPE("_restend") != "N"
  166.          _restend = VAL(_restend)
  167.       ENDIF
  168.       CLEAR_AREA()
  169.       IF _restx != _restend
  170.          WSAYGET(2,2,"Insert the next disk for the")
  171.          WSAYGET(3,2,"    Restoring Procedure")
  172.          INKEY(0)
  173.       ELSE
  174.          WSAYGET(2, 2, "Operation is complete.  Any")
  175.          WSAYGET(3, 2, "    key to continue....")
  176.          INKEY(0)
  177.          KEYBOARD CHR(27)
  178.       ENDIF
  179.    NEXT
  180.    RETURN(.T.)
  181.  
  182. *******************
  183.  
  184. FUNCTION Resterr
  185.  
  186.    CLEAR_AREA()
  187.    WSAYGET(2,1,"  The restoring procedure have")
  188.    WSAYGET(3,1,"experienced an error.  Operation")
  189.    WSAYGET(4,1," aborting.  Any key to continue.")
  190.    INKEY(0)
  191.    RETURN(.F.)
  192.