From 72feb908b627ef4035f6ecabbd7f26c2443d40b1 Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Mon, 15 May 2023 22:21:33 +1000 Subject: [PATCH] Engine: Fix e_UpperDir() leaving a trailing backslash This fixes a bug with broken folder navigation in file lists. --- src/engine/e_res.pas | 4 ++-- src/game/g_gui.pas | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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; -- 2.29.2