home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / NWTP04 / XBINDRY / BACKBIN.PAS next >
Pascal/Delphi Source File  |  1993-12-29  |  4KB  |  131 lines

  1. {$X+,B-,V-}
  2. Program backbin; { as of 931229}
  3.  
  4. { Example for the nwBindry unit / NwTP 0.4 API. (c) 1994, R.Spronk }
  5.  
  6. {Backs up the bindery files to the a: drive. }
  7. {You need to be supervisor-equivalent to run this. }
  8.  
  9. Uses DOS,nwMisc,nwBindry;
  10.  
  11. Var BindSeq:byte;
  12.     myObjID:LongInt;
  13.     Version:word;
  14.     s      :string;
  15.  
  16. LABEL enable;
  17.  
  18. Procedure FileCopy(fn1,fn2:string);
  19. LABEL 1;
  20. Var f1,f2    :file;
  21.     buffer   :array[1..4096] of byte;
  22.     BytesRead:word;
  23. begin
  24. {$I-}
  25. assign(f1,fn1);
  26. reset(f1,1);
  27. if ioresult<>0
  28.  then begin
  29.       writeln('Error opening input file:',fn1);
  30.       writeln('>> File wasn''t copied.');
  31.       goto 1;
  32.       end;
  33. assign(f2,fn2);
  34. rewrite(f2,1);
  35. if ioresult<>0
  36.  then begin
  37.       writeln('Error opening output file :',fn2);
  38.       writeln('>> File wasn''t copied.');
  39.       goto 1;
  40.       end;
  41. REPEAT
  42. BlockRead(f1,buffer[1],4096,BytesRead);
  43. BlockWrite(f2,buffer[1],BytesRead);
  44. UNTIL (BytesRead<4096);
  45. 1: ;
  46. close(f1);
  47. close(f2);
  48. {$I+}
  49. end;
  50.  
  51.  
  52. begin
  53. writeln('BACKBIN Test program for the nwBindry unit of the NwTP package.');
  54. writeln('-Backs up the bindery files to drive A');
  55. writeln;
  56. { need supervisor privileges to run this test }
  57. GetBinderyAccessLevel(BindSeq,myObjId);
  58. if bindSeq<>(BS_SUPER_WRITE OR BS_SUPER_READ) { $33}
  59.  then begin
  60.       writeln('You need to be supervisor equivalent to run this program.');
  61.       halt(1);
  62.       end;
  63.  
  64. writeln;
  65. writeln('WARNING:');
  66. writeln('Continue this program ONLY WHEN:');
  67. writeln('-You are the only user logged in.');
  68. writeln('-No other users will login in next few minutes.');
  69. writeln('-You are running Netware 2.15c, 2.2 or 3.x');
  70. writeln('-A diskette with sufficient space is in the A drive.');
  71. writeln;
  72. writeln('-If you have doubts about any of the above points: PLEASE ABORT NOW');
  73. writeln('-This program was made for test purposes only.');
  74. writeln;
  75. write('Type Y <return> to continue, <return> to abort.');
  76. readln(s);
  77. if NOT ( s[1] IN ['y','Y'])
  78.  then begin
  79.       writeln('Program aborted..');
  80.       halt(1);
  81.       end;
  82.  
  83. {determine Advanced Netware version. }
  84. nwMisc.GetNWVersion(version);
  85.  
  86. if (Version<215) or (version>399)
  87.  then begin
  88.       writeln('This util only works with NW 2.15+ or 3.x');
  89.       writeln('The bindery files were NOT backed up.');
  90.       halt(1);
  91.       end;
  92. version:=(version DIV 100);
  93.  
  94. {Note for final version: make sure no users are logged in. (NwConn functions)}
  95. {Note for final version: disable user login}
  96.  
  97. {close the bindery to backup the files..}
  98. IF NOT CloseBindery
  99.  then begin
  100.       writeln('Couldn''t close the bindery.');
  101.       writeln('The bindery files were NOT backed up');
  102.       writeln('Error : $',HexStr(NwBindry.Result,2));
  103.       goto enable;
  104.       end;
  105.  
  106. {back up the bindery files}
  107. if version=2
  108.  then begin
  109.       FileCopy('SYS:\SYSTEM\NET$BIND.SYS','A:\NET$BIND.OLD');
  110.       FileCopy('SYS:\SYSTEM\NET$BVAL.SYS','A:\NET$BVAL.OLD');
  111.       end
  112.  else begin {3.x}
  113.       FileCopy('SYS:\SYSTEM\NET$OBJ.SYS' ,'A:\NET$OBJ.OLD');
  114.       FileCopy('SYS:\SYSTEM\NET$PROP.SYS','A:\NET$PROP.OLD');
  115.       FileCopy('SYS:\SYSTEM\NET$VAL.SYS' ,'A:\NET$VAL.OLD');
  116.       end;
  117.  
  118. {open the bindery again}
  119. IF NOT OpenBindery
  120.  then begin
  121.       writeln('Couldn''t open the bindery after copying the bindery files.');
  122.       writeln('Error : $',HexStr(NwBindry.Result,2),' (',NwBindry.result,')');
  123.       end
  124.  else writeln('The bindery files were successfully backed up.');
  125.  
  126. {Note for final version: enable users to login}
  127.  
  128. enable: ;
  129.  
  130. end.
  131.