sysdir.inc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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: ansistring;
  18. res: __wasi_errno_t;
  19. begin
  20. if not ConvertToFdRelativePath(s,fd,pr) then
  21. exit;
  22. res:=__wasi_path_create_directory(fd,PChar(pr),Length(pr));
  23. if res=__WASI_ERRNO_SUCCESS then
  24. InOutRes:=0
  25. else
  26. InOutRes:=Errno2InoutRes(res);
  27. end;
  28. procedure Do_RmDir(s: rawbytestring);
  29. var
  30. fd: __wasi_fd_t;
  31. pr: ansistring;
  32. res: __wasi_errno_t;
  33. begin
  34. if not ConvertToFdRelativePath(s,fd,pr) then
  35. exit;
  36. res:=__wasi_path_remove_directory(fd,PChar(pr),Length(pr));
  37. if res=__WASI_ERRNO_SUCCESS then
  38. InOutRes:=0
  39. else
  40. InOutRes:=Errno2InoutRes(res);
  41. end;
  42. procedure do_ChDir(s: rawbytestring);
  43. begin
  44. DebugWriteLn('do_ChDir');
  45. end;
  46. procedure do_getdir(drivenr : byte;var dir : rawbytestring);
  47. begin
  48. if drivenr=0 then
  49. drivenr:=current_drive;
  50. if (drivenr<=drives_count) and (current_dirs[drivenr].dir_name<>'') then
  51. dir:=current_dirs[drivenr].dir_name
  52. else
  53. InoutRes:=15;
  54. end;