sysdir.inc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 S2 : STRING;
  18. Res: LONGINT;
  19. BEGIN
  20. S2 := S;
  21. IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
  22. S2 := S2 + #0;
  23. Res := FpMkdir (@S2[1],S_IRWXU);
  24. if Res = 0 then
  25. InOutRes:=0
  26. else
  27. SetFileError (Res);
  28. end;
  29. procedure rmdir(const s : string);[IOCheck];
  30. VAR S2 : STRING;
  31. Res: LONGINT;
  32. BEGIN
  33. S2 := S;
  34. IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
  35. S2 := S2 + #0;
  36. Res := FpRmdir (@S2[1]);
  37. IF Res = 0 THEN
  38. InOutRes:=0
  39. ELSE
  40. SetFileError (Res);
  41. end;
  42. procedure chdir(const s : string);[IOCheck];
  43. VAR S2 : STRING;
  44. Res: LONGINT;
  45. begin
  46. S2 := S;
  47. IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
  48. S2 := S2 + #0;
  49. Res := FpChdir (@S2[1]);
  50. IF Res = 0 THEN
  51. InOutRes:=0
  52. ELSE
  53. SetFileError (Res);
  54. end;
  55. procedure getdir(drivenr : byte;var dir : shortstring);
  56. var P : array [0..255] of CHAR;
  57. i : LONGINT;
  58. begin
  59. P[0] := #0;
  60. getcwdpath(@P,nil,0); // getcwd does not return volume, getcwdpath does
  61. i := libc_strlen (P);
  62. if i > 0 then
  63. begin
  64. Move (P, dir[1], i);
  65. BYTE(dir[0]) := i;
  66. For i := 1 to length (dir) do
  67. if dir[i] = '\' then dir [i] := '/';
  68. // fix / after volume, the compiler needs that
  69. // normaly root of a volumes is SERVERNAME/SYS:, change that
  70. // to SERVERNAME/SYS:/
  71. i := pos (':',dir);
  72. if (i > 0) then
  73. if i = Length (dir) then dir := dir + '/' else
  74. if dir [i+1] <> '/' then insert ('/',dir,i+1);
  75. end else
  76. InOutRes := 1;
  77. end;
  78. {
  79. $Log$
  80. Revision 1.1 2005-02-06 16:57:18 peter
  81. * threads for go32v2,os,emx,netware
  82. Revision 1.1 2005/02/06 13:06:20 peter
  83. * moved file and dir functions to sysfile/sysdir
  84. * win32 thread in systemunit
  85. }