sysdir.inc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2004-2011 by Armin Diehl
  4. FPC Pascal system unit for the netware API.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {*****************************************************************************
  12. Directory Handling
  13. *****************************************************************************}
  14. Procedure MkDir(s: pchar;len:sizeuint);[IOCheck, public, alias : 'FPC_SYS_MKDIR'];
  15. var
  16. Rc : longint;
  17. begin
  18. If not assigned(s) or (len=0) or (InOutRes <> 0) then
  19. exit;
  20. DoDirSeparators(s);
  21. Rc := _mkdir(pchar(s));
  22. if Rc <> 0 then
  23. SetFileError (Rc);
  24. end;
  25. procedure RmDir(s: pchar;len:sizeuint);[IOCheck, public, alias : 'FPC_SYS_RMDIR'];
  26. var Rc : longint;
  27. begin
  28. if (len=1) and (s^ = '.' ) then
  29. InOutRes := 16;
  30. If not assigned(s) or (len=0) or (InOutRes <> 0) then
  31. exit;
  32. DoDirSeparators(s);
  33. Rc := _rmdir(pchar(s));
  34. if Rc <> 0 then
  35. SetFileError(Rc);
  36. end;
  37. procedure ChDir(s: pchar;len:sizeuint);[IOCheck, public, alias : 'FPC_SYS_CHDIR'];
  38. var RC: longint;
  39. begin
  40. If not assigned(s) or (len=0) or (InOutRes <> 0) then
  41. exit;
  42. RC := _chdir (pchar(s));
  43. if Rc <> 0 then
  44. SetFileError(Rc);
  45. end;
  46. procedure getdir(drivenr : byte;var dir : shortstring);
  47. VAR P : ARRAY [0..255] OF CHAR;
  48. i : LONGINT;
  49. begin
  50. P[0] := #0;
  51. _getcwd (@P, SIZEOF (P));
  52. i := _strlen (P);
  53. if i > 0 then
  54. begin
  55. Move (P, dir[1], i);
  56. BYTE(dir[0]) := i;
  57. DoDirSeparators(dir);
  58. // fix / after volume, the compiler needs that
  59. // normaly root of a volumes is SERVERNAME/SYS:, change that
  60. // to SERVERNAME/SYS:/
  61. i := pos (':',dir);
  62. if (i > 0) then
  63. if i = Length (dir) then dir := dir + '/' else
  64. if dir [i+1] <> '/' then insert ('/',dir,i+1);
  65. END ELSE
  66. InOutRes := 1;
  67. end;