sysdir.inc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 S2 : STRING;
  17. Res: LONGINT;
  18. BEGIN
  19. S2 := S;
  20. IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
  21. S2 := S2 + #0;
  22. Res := _mkdir (@S2[1]);
  23. IF Res = 0 THEN
  24. InOutRes:=0
  25. ELSE
  26. SetFileError (Res);
  27. END;
  28. procedure rmdir(const s : string);[IOCheck];
  29. VAR S2 : STRING;
  30. Res: LONGINT;
  31. BEGIN
  32. S2 := S;
  33. IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
  34. S2 := S2 + #0;
  35. Res := _rmdir (@S2[1]);
  36. IF Res = 0 THEN
  37. InOutRes:=0
  38. ELSE
  39. SetFileError (Res);
  40. end;
  41. procedure chdir(const s : string);[IOCheck];
  42. VAR S2 : STRING;
  43. Res: LONGINT;
  44. begin
  45. S2 := S;
  46. IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
  47. S2 := S2 + #0;
  48. Res := _chdir (@S2[1]);
  49. IF Res = 0 THEN
  50. InOutRes:=0
  51. ELSE
  52. SetFileError (Res);
  53. end;
  54. procedure getdir(drivenr : byte;var dir : shortstring);
  55. VAR P : ARRAY [0..255] OF CHAR;
  56. i : LONGINT;
  57. begin
  58. P[0] := #0;
  59. _getcwd (@P, SIZEOF (P));
  60. i := _strlen (P);
  61. if i > 0 then
  62. begin
  63. Move (P, dir[1], i);
  64. BYTE(dir[0]) := i;
  65. For i := 1 to length (dir) do
  66. if dir[i] = '\' then dir [i] := '/';
  67. // fix / after volume, the compiler needs that
  68. // normaly root of a volumes is SERVERNAME/SYS:, change that
  69. // to SERVERNAME/SYS:/
  70. i := pos (':',dir);
  71. if (i > 0) then
  72. if i = Length (dir) then dir := dir + '/' else
  73. if dir [i+1] <> '/' then insert ('/',dir,i+1);
  74. END ELSE
  75. InOutRes := 1;
  76. end;