Browse Source

human68k: implemented do_chdir

Karoly Balogh 1 year ago
parent
commit
34519c67a1
2 changed files with 33 additions and 0 deletions
  1. 1 0
      rtl/human68k/h68kdos.inc
  2. 32 0
      rtl/human68k/sysdir.inc

+ 1 - 0
rtl/human68k/h68kdos.inc

@@ -106,6 +106,7 @@ const
     SEEK_FROM_END     = 2;
     SEEK_FROM_END     = 2;
 
 
 procedure h68kdos_exit; noreturn; syscall $ff00;
 procedure h68kdos_exit; noreturn; syscall $ff00;
+function h68kdos_chgdrv(newdrv: word): longint; syscall $ff0e;
 function h68kdos_curdrv: longint; syscall $ff17;
 function h68kdos_curdrv: longint; syscall $ff17;
 function h68kdos_gettim2: longint; syscall $ff27;
 function h68kdos_gettim2: longint; syscall $ff27;
 function h68kdos_mkdir(name: pchar): longint; syscall $ff39;
 function h68kdos_mkdir(name: pchar): longint; syscall $ff39;

+ 32 - 0
rtl/human68k/sysdir.inc

@@ -50,7 +50,39 @@ end;
 
 
 
 
 procedure do_ChDir(const s: rawbytestring);
 procedure do_ChDir(const s: rawbytestring);
+var
+  ps: rawbytestring;
+  len: longint;
+  curdrive: word;
+  newdrive: word;
+  dosResult: longint;
 begin
 begin
+  ps:=s;
+  DoDirSeparators(ps);
+  len:=Length(ps);
+
+  { first, handle drive changes }
+  if (len>=2) and (ps[2]=':') then
+    begin
+      curdrive:=h68kdos_curdrv;
+      newdrive:=(ord(ps[1]) and (not 32))-ord('A');
+      if (newdrive <> curdrive) then
+        begin
+          dosResult:=h68kdos_chgdrv(newdrive);
+          if dosResult <= newdrive then
+            begin
+              Error2InOutRes(DOSE_ILGDRV);
+              exit;
+            end;
+        end;
+
+      if len=2 then
+        exit;
+    end;
+  { do normal setpath }
+  dosResult:=h68kdos_chdir(PAnsiChar(ps));
+  if dosResult < 0 then
+    Error2InOutRes(dosResult);
 end;
 end;