From: Dmitry D. Chernov Date: Mon, 15 May 2023 12:21:33 +0000 (+1000) Subject: Engine: Fix e_UpperDir() leaving a trailing backslash X-Git-Url: https://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=72feb908b627ef4035f6ecabbd7f26c2443d40b1 Engine: Fix e_UpperDir() leaving a trailing backslash This fixes a bug with broken folder navigation in file lists. --- diff --git a/src/engine/e_res.pas b/src/engine/e_res.pas index e48cc32..69adb6e 100644 --- a/src/engine/e_res.pas +++ b/src/engine/e_res.pas @@ -79,9 +79,9 @@ implementation function e_UpperDir (path: AnsiString): AnsiString; var i: Integer; begin - i := High(path); + i := High(path); // consider possible cases: '\a\', '\a', '\abc\' while (i >= 1) and (path[i] <> '/') and (path[i] <> '\') do Dec(i); - result := Copy(path, 1, i) + result := Copy(path, 1, i-1) // exclude the trailing separator end; function HasRelativeDirs (name: AnsiString): Boolean; diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index b8b1999..2200703 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -3232,13 +3232,13 @@ begin begin if FItems[FIndex] = #29 + '..' then begin - e_LogWritefln('TGUIFileListBox: Upper dir "%s" -> "%s"', [FSubPath, e_UpperDir(FSubPath)]); + //e_LogWritefln('TGUIFileListBox: Upper dir "%s" -> "%s"', [FSubPath, e_UpperDir(FSubPath)]); FSubPath := e_UpperDir(FSubPath) end else begin s := Copy(AnsiString(FItems[FIndex]), 2); - e_LogWritefln('TGUIFileListBox: Enter dir "%s" -> "%s"', [FSubPath, e_CatPath(FSubPath, s)]); + //e_LogWritefln('TGUIFileListBox: Enter dir "%s" -> "%s"', [FSubPath, e_CatPath(FSubPath, s)]); FSubPath := e_CatPath(FSubPath, s); end; ScanDirs;