sysdir.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2020 by Free Pascal development team
  4. Low level directory functions for Human 68k (Sharp X68000)
  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(const s : rawbytestring);
  15. var
  16. dosResult: longint;
  17. ps: rawbytestring;
  18. begin
  19. ps:=s;
  20. DoDirSeparators(ps);
  21. dosResult:=h68kdos_mkdir(PAnsiChar(ps));
  22. if dosResult < 0 then
  23. Error2InOutRes(dosResult);
  24. end;
  25. procedure do_rmdir(const s : rawbytestring);
  26. var
  27. dosResult: longint;
  28. ps: rawbytestring;
  29. begin
  30. ps:=s;
  31. DoDirSeparators(ps);
  32. if ps='.' then
  33. begin
  34. InOutRes:=16;
  35. exit;
  36. end;
  37. dosResult:=h68kdos_rmdir(PAnsiChar(ps));
  38. if dosResult < 0 then
  39. Error2InOutRes(dosResult);
  40. end;
  41. procedure do_ChDir(const s: rawbytestring);
  42. var
  43. ps: rawbytestring;
  44. len: longint;
  45. curdrive: word;
  46. newdrive: word;
  47. dosResult: longint;
  48. begin
  49. ps:=s;
  50. DoDirSeparators(ps);
  51. len:=Length(ps);
  52. { first, handle drive changes }
  53. if (len>=2) and (ps[2]=':') then
  54. begin
  55. curdrive:=h68kdos_curdrv;
  56. newdrive:=(ord(ps[1]) and (not 32))-ord('A');
  57. if (newdrive <> curdrive) then
  58. begin
  59. dosResult:=h68kdos_chgdrv(newdrive);
  60. if dosResult <= newdrive then
  61. begin
  62. Error2InOutRes(DOSE_ILGDRV);
  63. exit;
  64. end;
  65. end;
  66. if len=2 then
  67. exit;
  68. end;
  69. { do normal setpath }
  70. dosResult:=h68kdos_chdir(PAnsiChar(ps));
  71. if dosResult < 0 then
  72. Error2InOutRes(dosResult);
  73. end;
  74. procedure do_GetDir (DriveNr: byte; var Dir: RawByteString);
  75. var
  76. dosResult: longint;
  77. pathbuf: array[0..259] of AnsiChar;
  78. begin
  79. Dir := '';
  80. dosResult:=h68kdos_curdir(DriveNr,@pathbuf[2]);
  81. if dosResult < 0 then
  82. begin
  83. Error2InOutRes(dosResult);
  84. exit;
  85. end;
  86. if DriveNr = 0 then
  87. DriveNr := h68kdos_curdrv + 1;
  88. { return a full path, including drive }
  89. pathbuf[0]:=AnsiChar(ord('A') + DriveNr - 1);
  90. pathbuf[1]:=DriveSeparator;
  91. Dir:=pathbuf;
  92. SetCodePage(Dir,DefaultSystemCodePage,false);
  93. end;