sysdir.inc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 Amiga.
  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 do_mkdir(const s : rawbytestring);
  16. var
  17. tmpStr : rawbytestring;
  18. tmpLock: LongInt;
  19. begin
  20. checkCTRLC;
  21. tmpStr:=PathConv(s);
  22. tmpLock:=dosCreateDir(pchar(tmpStr));
  23. if tmpLock=0 then begin
  24. dosError2InOut(IoErr);
  25. exit;
  26. end;
  27. UnLock(tmpLock);
  28. end;
  29. procedure do_rmdir(const s : rawbytestring);
  30. var
  31. tmpStr : rawbytestring;
  32. begin
  33. checkCTRLC;
  34. if (s='.') then
  35. begin
  36. InOutRes:=16;
  37. exit;
  38. end;
  39. tmpStr:=PathConv(s);
  40. if not dosDeleteFile(pchar(tmpStr)) then
  41. dosError2InOut(IoErr);
  42. end;
  43. procedure do_ChDir(const s: rawbytestring);
  44. var
  45. tmpStr : rawbytestring;
  46. tmpLock: LongInt;
  47. FIB : PFileInfoBlock;
  48. begin
  49. checkCTRLC;
  50. tmpStr:=PathConv(s);
  51. tmpLock:=0;
  52. { Changing the directory is a pretty complicated affair }
  53. { 1) Obtain a lock on the directory }
  54. { 2) CurrentDir the lock }
  55. tmpLock:=Lock(pchar(tmpStr),SHARED_LOCK);
  56. if tmpLock=0 then begin
  57. dosError2InOut(IoErr);
  58. exit;
  59. end;
  60. FIB:=nil;
  61. new(FIB);
  62. if (Examine(tmpLock,FIB)=True) and (FIB^.fib_DirEntryType>0) then begin
  63. tmpLock:=CurrentDir(tmpLock);
  64. if AOS_OrigDir=0 then begin
  65. AOS_OrigDir:=tmpLock;
  66. tmpLock:=0;
  67. end;
  68. end;
  69. if tmpLock<>0 then Unlock(tmpLock);
  70. if assigned(FIB) then dispose(FIB);
  71. end;
  72. procedure do_GetDir (DriveNr: byte; var Dir: RawByteString);
  73. var tmpbuf: array[0..255] of char;
  74. begin
  75. checkCTRLC;
  76. Dir:='';
  77. if not GetCurrentDirName(tmpbuf,256) then
  78. dosError2InOut(IoErr)
  79. else
  80. begin
  81. Dir:=tmpbuf;
  82. SetCodePage(Dir,DefaultFileSystemCodePage,false);
  83. end;
  84. end;