diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2025-03-08 16:59:02 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2025-03-08 16:59:02 +0100 |
| commit | 0941f0600a26b85b49ab37ab2068a42a4962359c (patch) | |
| tree | aa277563904084a7e8bf97704440e07c017a5915 /src/filename_absolute.cxx | |
| parent | 43e24a7541fabf6479432b189998bb07436d7288 (diff) | |
Add Fl_Darwin_System_Driver::filename_relative()
This removes the last instance in FLTK of use of #if __APPLE__ instead of the driver mechanism.
Diffstat (limited to 'src/filename_absolute.cxx')
| -rw-r--r-- | src/filename_absolute.cxx | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/filename_absolute.cxx b/src/filename_absolute.cxx index f70d59873..b134c48c0 100644 --- a/src/filename_absolute.cxx +++ b/src/filename_absolute.cxx @@ -201,7 +201,12 @@ int fl_filename_relative(char *to, int tolen, const char *from, const char *base \{ */ -int Fl_System_Driver::filename_relative(char *to, int tolen, const char *dest_dir, const char *base_dir) +int Fl_System_Driver::filename_relative(char *to, int tolen, const char *dest_dir, const char *base_dir) { + return filename_relative_(to, tolen, dest_dir, base_dir, true); +} + + +int Fl_System_Driver::filename_relative_(char *to, int tolen, const char *dest_dir, const char *base_dir, bool case_sensitive) { // Find the relative path from base_dir to dest_dir. // Both paths must be absolute and well formed (contain no /../ and /./ segments). @@ -223,16 +228,17 @@ int Fl_System_Driver::filename_relative(char *to, int tolen, const char *dest_di // compare both path names until we find a difference for (;;) { -#ifndef __APPLE__ // case sensitive - base_i++; - dest_i++; - char b = *base_i, d = *dest_i; -#else // case insensitive - base_i += fl_utf8len1(*base_i); - int b = fl_tolower(fl_utf8decode(base_i, NULL, NULL)); - dest_i += fl_utf8len1(*dest_i); - int d = fl_tolower(fl_utf8decode(dest_i, NULL, NULL)); -#endif + int b, d; + if (case_sensitive) { // case sensitive + base_i++; + dest_i++; + b = *base_i, d = *dest_i; + } else { // case insensitive + base_i += fl_utf8len1(*base_i); + b = fl_tolower(fl_utf8decode(base_i, NULL, NULL)); + dest_i += fl_utf8len1(*dest_i); + d = fl_tolower(fl_utf8decode(dest_i, NULL, NULL)); + } int b0 = (b==0) || (isdirsep(b)); int d0 = (d==0) || (isdirsep(d)); if (b0 && d0) { |
