sysdir.inc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Main OS dependant body of the system unit, loosely modelled
  4. after POSIX. *BSD version (Linux version is near identical)
  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 Do_MkDir(s: rawbytestring);
  15. var
  16. fd: __wasi_fd_t;
  17. pr: PChar;
  18. res: __wasi_errno_t;
  19. begin
  20. if not ConvertToFdRelativePath(PChar(s),fd,pr) then
  21. exit;
  22. res:=__wasi_path_create_directory(fd,pr,StrLen(pr));
  23. if res=__WASI_ERRNO_SUCCESS then
  24. InOutRes:=0
  25. else
  26. InOutRes:=Errno2InoutRes(res);
  27. FreeMem(pr);
  28. end;
  29. procedure Do_RmDir(s: rawbytestring);
  30. var
  31. fd: __wasi_fd_t;
  32. pr: PChar;
  33. res: __wasi_errno_t;
  34. begin
  35. if not ConvertToFdRelativePath(PChar(s),fd,pr) then
  36. exit;
  37. res:=__wasi_path_remove_directory(fd,pr,StrLen(pr));
  38. if res=__WASI_ERRNO_SUCCESS then
  39. InOutRes:=0
  40. else
  41. InOutRes:=Errno2InoutRes(res);
  42. FreeMem(pr);
  43. end;
  44. procedure do_ChDir(s: rawbytestring);
  45. begin
  46. DebugWriteLn('do_ChDir');
  47. end;
  48. procedure do_getdir(drivenr : byte;var dir : rawbytestring);
  49. begin
  50. if drivenr=0 then
  51. drivenr:=current_drive;
  52. if (drivenr<=drives_count) and (current_dirs[drivenr]<>nil) then
  53. dir:=current_dirs[drivenr]
  54. else
  55. InoutRes:=15;
  56. end;