From 6bb5a81cee7e76e8a4e69f7f49869f39c1c382f0 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Tue, 5 Sep 2023 14:45:51 +0200 Subject: Adds some convenience methods. fl_filename_absolute can no generate a path using arbitrary source paths. Fl_Menu_ adds find_item_with_user_data and find_item_with_argument Fl_String adds find(string, start) --- src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx') diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx index cda8c1b36..c2d41f98e 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx @@ -636,21 +636,17 @@ Fl_WinAPI_System_Driver::filename_relative(char *to, // O - Relative filename return 1; } -int Fl_WinAPI_System_Driver::filename_absolute(char *to, int tolen, const char *from) { - if (isdirsep(*from) || *from == '|' || from[1]==':') { +int Fl_WinAPI_System_Driver::filename_absolute(char *to, int tolen, const char *from, const char *base) { + if (isdirsep(*from) || *from == '|' || from[1]==':' || !base) { strlcpy(to, from, tolen); return 0; } char *a; char *temp = new char[tolen]; const char *start = from; - a = getcwd(temp, tolen); - if (!a) { - strlcpy(to, from, tolen); - delete[] temp; - return 0; - } + strlcpy(temp, base, tolen); for (a = temp; *a; a++) if (*a=='\\') *a = '/'; // ha ha + /* remove trailing '/' in current working directory */ if (isdirsep(*(a-1))) a--; /* remove intermediate . and .. names: */ while (*start == '.') { -- cgit v1.2.3