sysdir.inc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Florian Klaempfl and Pavel Ozerski
  5. member of the Free Pascal development team.
  6. FPC Pascal system unit for the Win32 API.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {*****************************************************************************
  14. Directory Handling
  15. *****************************************************************************}
  16. procedure mkdir(const s : string);[IOCheck];
  17. var
  18. tmpStr : array[0..255] of char;
  19. tmpLock: LongInt;
  20. begin
  21. checkCTRLC;
  22. if (s='') or (InOutRes<>0) then exit;
  23. tmpStr:=PathConv(s)+#0;
  24. tmpLock:=dosCreateDir(@tmpStr);
  25. if tmpLock=0 then begin
  26. dosError2InOut(IoErr);
  27. exit;
  28. end;
  29. UnLock(tmpLock);
  30. end;
  31. procedure rmdir(const s : string);[IOCheck];
  32. var
  33. tmpStr : array[0..255] of Char;
  34. begin
  35. checkCTRLC;
  36. if (s='.') then InOutRes:=16;
  37. If (s='') or (InOutRes<>0) then exit;
  38. tmpStr:=PathConv(s)+#0;
  39. if not dosDeleteFile(@tmpStr) then
  40. dosError2InOut(IoErr);
  41. end;
  42. procedure chdir(const s : string);[IOCheck];
  43. var
  44. tmpStr : array[0..255] of Char;
  45. tmpLock: LongInt;
  46. FIB : PFileInfoBlock;
  47. begin
  48. checkCTRLC;
  49. If (s='') or (InOutRes<>0) then exit;
  50. tmpStr:=PathConv(s)+#0;
  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(@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 MOS_OrigDir=0 then begin
  65. MOS_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 GetDir (DriveNr: byte; var Dir: ShortString);
  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. Dir:=strpas(tmpbuf);
  81. end;
  82. {
  83. $Log$
  84. Revision 1.2 2005-02-14 17:13:30 peter
  85. * truncate log
  86. Revision 1.1 2005/02/07 21:30:12 peter
  87. * system unit updated
  88. Revision 1.1 2005/02/06 16:57:18 peter
  89. * threads for go32v2,os,emx,netware
  90. Revision 1.1 2005/02/06 13:06:20 peter
  91. * moved file and dir functions to sysfile/sysdir
  92. * win32 thread in systemunit
  93. }