sysdir.inc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Florian Klaempfl and Pavel Ozerski
  4. member of the Free Pascal development team.
  5. FPC Pascal system unit for the Win32 API.
  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. {*****************************************************************************
  13. Directory Handling
  14. *****************************************************************************}
  15. procedure mkdir(const s : string);[IOCheck];
  16. var
  17. tmpStr : array[0..255] of char;
  18. tmpLock: LongInt;
  19. begin
  20. checkCTRLC;
  21. if (s='') or (InOutRes<>0) then exit;
  22. tmpStr:=PathConv(s)+#0;
  23. tmpLock:=dosCreateDir(@tmpStr);
  24. if tmpLock=0 then begin
  25. dosError2InOut(IoErr);
  26. exit;
  27. end;
  28. UnLock(tmpLock);
  29. end;
  30. procedure rmdir(const s : string);[IOCheck];
  31. var
  32. tmpStr : array[0..255] of Char;
  33. begin
  34. checkCTRLC;
  35. if (s='.') then InOutRes:=16;
  36. If (s='') or (InOutRes<>0) then exit;
  37. tmpStr:=PathConv(s)+#0;
  38. if not dosDeleteFile(@tmpStr) then
  39. dosError2InOut(IoErr);
  40. end;
  41. procedure chdir(const s : string);[IOCheck];
  42. var
  43. tmpStr : array[0..255] of Char;
  44. tmpLock: LongInt;
  45. FIB : PFileInfoBlock;
  46. begin
  47. checkCTRLC;
  48. If (s='') or (InOutRes<>0) then exit;
  49. tmpStr:=PathConv(s)+#0;
  50. tmpLock:=0;
  51. { Changing the directory is a pretty complicated affair }
  52. { 1) Obtain a lock on the directory }
  53. { 2) CurrentDir the lock }
  54. tmpLock:=Lock(@tmpStr,SHARED_LOCK);
  55. if tmpLock=0 then begin
  56. dosError2InOut(IoErr);
  57. exit;
  58. end;
  59. FIB:=nil;
  60. new(FIB);
  61. if (Examine(tmpLock,FIB)=True) and (FIB^.fib_DirEntryType>0) then begin
  62. tmpLock:=CurrentDir(tmpLock);
  63. if AOS_OrigDir=0 then begin
  64. AOS_OrigDir:=tmpLock;
  65. tmpLock:=0;
  66. end;
  67. end;
  68. if tmpLock<>0 then Unlock(tmpLock);
  69. if assigned(FIB) then dispose(FIB);
  70. end;
  71. procedure GetDir (DriveNr: byte; var Dir: ShortString);
  72. var tmpbuf: array[0..255] of char;
  73. begin
  74. checkCTRLC;
  75. Dir:='';
  76. if not GetCurrentDirName(tmpbuf,256) then
  77. dosError2InOut(IoErr)
  78. else
  79. Dir:=strpas(tmpbuf);
  80. end;