disk.inc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1998 by the Free Pascal development team
  5. Disk functions from Delphi's sysutils.pas
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. Function DiskFree (Drive : Byte) : Longint;
  13. var Regs: Registers;
  14. begin
  15. Regs.Dl := Drive;
  16. Regs.Ah := $36;
  17. intr($21, Regs);
  18. if Regs.Ax <> $FFFF then
  19. result := Regs.Ax * Regs.Bx * Regs.Cx
  20. else
  21. result := -1;
  22. end;
  23. Function DiskSize (Drive : Byte) : Longint;
  24. var Regs: Registers;
  25. begin
  26. Regs.Dl := Drive;
  27. Regs.Ah := $36;
  28. Intr($21, Regs);
  29. if Regs.Ax <> $FFFF then
  30. result := Regs.Ax * Regs.Cx * Regs.Dx
  31. else
  32. result := -1;
  33. end;
  34. Function GetCurrentDir : String;
  35. begin
  36. GetDir(0, result);
  37. end;
  38. Function SetCurrentDir(Const NewDir : String) : Boolean;
  39. begin
  40. {$I-}
  41. ChDir(NewDir);
  42. result := (IOResult = 0);
  43. {$I+}
  44. end;
  45. Function CreateDir (Const NewDir : String) : Boolean;
  46. begin
  47. {$I-}
  48. MkDir(NewDir);
  49. result := (IOResult = 0);
  50. {$I+}
  51. end;
  52. Function RemoveDir (Const Dir : String) : Boolean;
  53. begin
  54. {$I-}
  55. RmDir(Dir);
  56. result := (IOResult = 0);
  57. {$I+}
  58. end;
  59. {
  60. $Log$
  61. Revision 1.2 1998-10-30 14:13:13 michael
  62. + Implementation of functions by Gertjan Schouten
  63. Revision 1.1 1998/10/11 13:42:55 michael
  64. Added disk functions
  65. }