sysdir.inc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. {$ifdef todo}
  16. procedure DosDir(func:byte;s: rawbytestring);
  17. var
  18. regs : Registers;
  19. len : Integer;
  20. begin
  21. DoDirSeparators(s);
  22. { True DOS does not like backslashes at end
  23. Win95 DOS accepts this !!
  24. but "\" and "c:\" should still be kept and accepted hopefully PM }
  25. len:=length(s);
  26. if (len>0) and (s[len]='\') and
  27. Not ((len=1) or ((len=3) and (s[2]=':'))) then
  28. s[len]:=#0;
  29. regs.DX:=Ofs(s[1]);
  30. regs.DS:=Seg(s[1]);
  31. if LFNSupport then
  32. regs.AX:=$7100+func
  33. else
  34. regs.AX:=func shl 8;
  35. MsDos(regs);
  36. if (regs.Flags and fCarry) <> 0 then
  37. GetInOutRes(regs.AX);
  38. end;
  39. {$endif}
  40. Procedure do_MkDir(const s: rawbytestring);
  41. begin
  42. GetInOutRes(153);
  43. //DosDir($39,s);
  44. end;
  45. Procedure do_RmDir(const s: rawbytestring);
  46. begin
  47. if s='.' then
  48. begin
  49. InOutRes:=16;
  50. exit;
  51. end;
  52. GetInOutRes(153);
  53. //DosDir($3a,s);
  54. end;
  55. Procedure do_ChDir(const s: rawbytestring);
  56. {$ifdef todo}
  57. var
  58. regs : Registers;
  59. len : Integer;
  60. {$endif}
  61. begin
  62. GetInOutRes(153);
  63. {$ifdef todo}
  64. len:=Length(s);
  65. { First handle Drive changes }
  66. if (len>=2) and (s[2]=':') then
  67. begin
  68. regs.DX:=(ord(s[1]) and (not 32))-ord('A');
  69. regs.AX:=$0e00;
  70. MsDos(regs);
  71. regs.AX:=$1900;
  72. MsDos(regs);
  73. if regs.AL<>regs.DL then
  74. begin
  75. Inoutres:=15;
  76. exit;
  77. end;
  78. { DosDir($3b,'c:') give Path not found error on
  79. pure DOS PM }
  80. if len=2 then
  81. exit;
  82. end;
  83. { do the normal dos chdir }
  84. DosDir($3b,s);
  85. {$endif}
  86. end;
  87. procedure do_GetDir (DriveNr: byte; var Dir: RawByteString);
  88. {$ifdef todo}
  89. var
  90. temp : array[0..260] of AnsiChar;
  91. i : integer;
  92. regs : Registers;
  93. {$endif}
  94. begin
  95. GetInOutRes(153);
  96. {$ifdef todo}
  97. regs.DX:=drivenr;
  98. regs.SI:=Ofs(temp);
  99. regs.DS:=Seg(temp);
  100. if LFNSupport then
  101. regs.AX:=$7147
  102. else
  103. regs.AX:=$4700;
  104. MsDos(regs);
  105. if (regs.Flags and fCarry) <> 0 then
  106. Begin
  107. GetInOutRes (regs.AX);
  108. Dir := AnsiChar (DriveNr + 64) + ':\';
  109. SetCodePage (Dir,DefaultFileSystemCodePage,false);
  110. exit;
  111. end
  112. else
  113. temp[252] := #0; { to avoid shortstring buffer overflow }
  114. { conversion to Pascal string including slash conversion }
  115. i:=0;
  116. SetLength(dir,260);
  117. while (temp[i]<>#0) do
  118. begin
  119. if temp[i] in AllowDirectorySeparators then
  120. temp[i]:=DirectorySeparator;
  121. dir[i+4]:=temp[i];
  122. inc(i);
  123. end;
  124. dir[2]:=':';
  125. dir[3]:='\';
  126. SetLength(dir,i+3);
  127. SetCodePage (dir,DefaultFileSystemCodePage,false);
  128. { upcase the string }
  129. if not FileNameCasePreserving then
  130. dir:=upcase(dir);
  131. if drivenr<>0 then { Drive was supplied. We know it }
  132. dir[1]:=AnsiChar(65+drivenr-1)
  133. else
  134. begin
  135. { We need to get the current drive from DOS function 19H }
  136. { because the drive was the default, which can be unknown }
  137. regs.AX:=$1900;
  138. MsDos(regs);
  139. i:= (regs.AX and $ff) + ord('A');
  140. dir[1]:=chr(i);
  141. end;
  142. {$endif}
  143. end;