diff --git a/rtl/human68k/h68kdos.inc b/rtl/human68k/h68kdos.inc index c68cf00acc..e5b8b39056 100644 --- a/rtl/human68k/h68kdos.inc +++ b/rtl/human68k/h68kdos.inc @@ -106,6 +106,7 @@ const SEEK_FROM_END = 2; procedure h68kdos_exit; noreturn; syscall $ff00; +function h68kdos_chgdrv(newdrv: word): longint; syscall $ff0e; function h68kdos_curdrv: longint; syscall $ff17; function h68kdos_gettim2: longint; syscall $ff27; function h68kdos_mkdir(name: pchar): longint; syscall $ff39; diff --git a/rtl/human68k/sysdir.inc b/rtl/human68k/sysdir.inc index d0e685b192..8348b434db 100644 --- a/rtl/human68k/sysdir.inc +++ b/rtl/human68k/sysdir.inc @@ -50,7 +50,39 @@ end; procedure do_ChDir(const s: rawbytestring); +var + ps: rawbytestring; + len: longint; + curdrive: word; + newdrive: word; + dosResult: longint; 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;