Add Fl_Darwin_System_Driver::filename_relative()
This removes the last instance in FLTK of use of #if __APPLE__ instead of the driver mechanism.
This commit is contained in:
parent
43e24a7541
commit
0941f0600a
@ -64,6 +64,7 @@ protected:
|
|||||||
static Fl_System_Driver *newSystemDriver();
|
static Fl_System_Driver *newSystemDriver();
|
||||||
Fl_System_Driver();
|
Fl_System_Driver();
|
||||||
static bool awake_ring_empty();
|
static bool awake_ring_empty();
|
||||||
|
int filename_relative_(char *to, int tolen, const char *from, const char *base, bool case_sensitive);
|
||||||
public:
|
public:
|
||||||
virtual ~Fl_System_Driver();
|
virtual ~Fl_System_Driver();
|
||||||
static int command_key;
|
static int command_key;
|
||||||
|
|||||||
@ -79,6 +79,7 @@ public:
|
|||||||
Fl_Sys_Menu_Bar_Driver *sys_menu_bar_driver() FL_OVERRIDE;
|
Fl_Sys_Menu_Bar_Driver *sys_menu_bar_driver() FL_OVERRIDE;
|
||||||
double wait(double time_to_wait) FL_OVERRIDE;
|
double wait(double time_to_wait) FL_OVERRIDE;
|
||||||
int ready() FL_OVERRIDE;
|
int ready() FL_OVERRIDE;
|
||||||
|
int filename_relative(char *to, int tolen, const char *dest_dir, const char *base_dir) FL_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FL_DARWIN_SYSTEM_DRIVER_H
|
#endif // FL_DARWIN_SYSTEM_DRIVER_H
|
||||||
|
|||||||
@ -367,3 +367,8 @@ void Fl_Darwin_System_Driver::tree_draw_expando_button(int x, int y, bool state,
|
|||||||
int Fl_Darwin_System_Driver::tree_connector_style() {
|
int Fl_Darwin_System_Driver::tree_connector_style() {
|
||||||
return FL_TREE_CONNECTOR_NONE;
|
return FL_TREE_CONNECTOR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Fl_Darwin_System_Driver::filename_relative(char *to, int tolen, const char *dest_dir, const char *base_dir) {
|
||||||
|
return Fl_System_Driver::filename_relative_(to, tolen, dest_dir, base_dir, false);
|
||||||
|
}
|
||||||
|
|||||||
@ -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.
|
// Find the relative path from base_dir to dest_dir.
|
||||||
// Both paths must be absolute and well formed (contain no /../ and /./ segments).
|
// 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
|
// compare both path names until we find a difference
|
||||||
for (;;) {
|
for (;;) {
|
||||||
#ifndef __APPLE__ // case sensitive
|
int b, d;
|
||||||
base_i++;
|
if (case_sensitive) { // case sensitive
|
||||||
dest_i++;
|
base_i++;
|
||||||
char b = *base_i, d = *dest_i;
|
dest_i++;
|
||||||
#else // case insensitive
|
b = *base_i, d = *dest_i;
|
||||||
base_i += fl_utf8len1(*base_i);
|
} else { // case insensitive
|
||||||
int b = fl_tolower(fl_utf8decode(base_i, NULL, NULL));
|
base_i += fl_utf8len1(*base_i);
|
||||||
dest_i += fl_utf8len1(*dest_i);
|
b = fl_tolower(fl_utf8decode(base_i, NULL, NULL));
|
||||||
int d = fl_tolower(fl_utf8decode(dest_i, NULL, NULL));
|
dest_i += fl_utf8len1(*dest_i);
|
||||||
#endif
|
d = fl_tolower(fl_utf8decode(dest_i, NULL, NULL));
|
||||||
|
}
|
||||||
int b0 = (b==0) || (isdirsep(b));
|
int b0 = (b==0) || (isdirsep(b));
|
||||||
int d0 = (d==0) || (isdirsep(d));
|
int d0 = (d==0) || (isdirsep(d));
|
||||||
if (b0 && d0) {
|
if (b0 && d0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user