sysdir.inc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 do_MkDir(const s: rawbytestring);
  16. var Res: LONGINT;
  17. BEGIN
  18. Res := FpMkdir (pchar(s),S_IRWXU);
  19. if Res = 0 then
  20. InOutRes:=0
  21. else
  22. SetFileError (Res);
  23. end;
  24. procedure do_RmDir(const s: rawbytestring);
  25. var Res: longint;
  26. begin
  27. Res := FpRmdir (pchar(s));
  28. if Res = 0 then
  29. InOutRes:=0
  30. else
  31. SetFileError (Res);
  32. end;
  33. procedure do_ChDir(const s: rawbytestring);
  34. var Res: longint;
  35. begin
  36. Res := FpChdir (s);
  37. if Res = 0 then
  38. InOutRes:=0
  39. else
  40. SetFileError (Res);
  41. end;
  42. procedure do_getdir(drivenr : byte;var dir : rawbytestring);
  43. var P : array [0..255] of CHAR;
  44. i : LONGINT;
  45. begin
  46. P[0] := #0;
  47. getcwdpath(@P,nil,0); // getcwd does not return volume, getcwdpath does
  48. i := libc_strlen (P);
  49. if i > 0 then
  50. begin
  51. SetLength (dir, i);
  52. Move (P, dir[1], i);
  53. DoDirSeparators(dir);
  54. // fix / after volume, the compiler needs that
  55. // normaly root of a volumes is SERVERNAME/SYS:, change that
  56. // to SERVERNAME/SYS:/
  57. i := pos (':',dir);
  58. if (i > 0) then
  59. if i = Length (dir) then dir := dir + '/' else
  60. if dir [i+1] <> '/' then insert ('/',dir,i+1);
  61. SetCodePage (dir,DefaultFileSystemCodePage,false);
  62. end else
  63. InOutRes := 1;
  64. end;