diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-09-05 14:45:51 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-09-05 14:45:57 +0200 |
| commit | 6bb5a81cee7e76e8a4e69f7f49869f39c1c382f0 (patch) | |
| tree | 2a6d6f73dd19dd52aaccd1d99b50a20bb53946d6 /src/drivers | |
| parent | b2a41e08c3b9b5fbbd0c899537611b8e28e5993d (diff) | |
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)
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.H | 2 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 12 |
2 files changed, 5 insertions, 9 deletions
diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H index 10047b632..aae1017e2 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H @@ -74,7 +74,7 @@ public: char *errmsg=NULL, int errmsg_sz=0) FL_OVERRIDE; int filename_expand(char *to,int tolen, const char *from) FL_OVERRIDE; int filename_relative(char *to, int tolen, const char *from, const char *base) FL_OVERRIDE; - int filename_absolute(char *to, int tolen, const char *from) FL_OVERRIDE; + int filename_absolute(char *to, int tolen, const char *from, const char *base) FL_OVERRIDE; int filename_isdir(const char *n) FL_OVERRIDE; int filename_isdir_quick(const char *n) FL_OVERRIDE; const char *filename_ext(const char *buf) FL_OVERRIDE; 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 == '.') { |
