mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 13:55:38 +08:00
Fl_File_Chooser::value() and ::directory() now handle paths with
backslashes on WIN32 (STR #811) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4346 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -2,6 +2,8 @@ CHANGES IN FLTK 1.1.7
|
|||||||
|
|
||||||
- Documentation fixes (STR #648, STR #692, STR #730, STR
|
- Documentation fixes (STR #648, STR #692, STR #730, STR
|
||||||
#744, STR #745)
|
#744, STR #745)
|
||||||
|
- Fl_File_Chooser::value() and ::directory() now handle
|
||||||
|
paths with backslashes on WIN32 (STR #811)
|
||||||
- Added the standard rgb.txt file from X11 to the test
|
- Added the standard rgb.txt file from X11 to the test
|
||||||
directory, allowing all platforms to try the colbrowser
|
directory, allowing all platforms to try the colbrowser
|
||||||
demo (STR #843)
|
demo (STR #843)
|
||||||
|
|||||||
@@ -158,6 +158,20 @@ Fl_File_Chooser::directory(const char *d)// I - Directory to change to
|
|||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
d = ".";
|
d = ".";
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// See if the filename contains backslashes...
|
||||||
|
char fixpath[1024]; // Path with slashes converted
|
||||||
|
if (strchr(d, '\\')) {
|
||||||
|
// Convert backslashes to slashes...
|
||||||
|
strlcpy(fixpath, d, sizeof(fixpath));
|
||||||
|
|
||||||
|
for (slash = strchr(fixpath, '\\'); slash; slash = strchr(slash + 1, '\\'))
|
||||||
|
*slash = '/';
|
||||||
|
|
||||||
|
d = fixpath;
|
||||||
|
}
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
if (d[0] != '\0')
|
if (d[0] != '\0')
|
||||||
{
|
{
|
||||||
// Make the directory absolute...
|
// Make the directory absolute...
|
||||||
@@ -1071,12 +1085,13 @@ Fl_File_Chooser::value(int f) // I - File number
|
|||||||
//
|
//
|
||||||
|
|
||||||
void
|
void
|
||||||
Fl_File_Chooser::value(const char *filename) // I - Filename + directory
|
Fl_File_Chooser::value(const char *filename)
|
||||||
|
// I - Filename + directory
|
||||||
{
|
{
|
||||||
int i, // Looping var
|
int i, // Looping var
|
||||||
fcount; // Number of items in list
|
fcount; // Number of items in list
|
||||||
char *slash; // Directory separator
|
char *slash; // Directory separator
|
||||||
char pathname[1024]; // Local copy of filename
|
char pathname[1024]; // Local copy of filename
|
||||||
|
|
||||||
|
|
||||||
// printf("Fl_File_Chooser::value(\"%s\")\n", filename == NULL ? "(null)" : filename);
|
// printf("Fl_File_Chooser::value(\"%s\")\n", filename == NULL ? "(null)" : filename);
|
||||||
@@ -1090,13 +1105,24 @@ Fl_File_Chooser::value(const char *filename) // I - Filename + directory
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// See if the filename contains backslashes...
|
||||||
|
char fixpath[1024]; // Path with slashes converted
|
||||||
|
if (strchr(filename, '\\')) {
|
||||||
|
// Convert backslashes to slashes...
|
||||||
|
strlcpy(fixpath, filename, sizeof(fixpath));
|
||||||
|
|
||||||
|
for (slash = strchr(fixpath, '\\'); slash; slash = strchr(slash + 1, '\\'))
|
||||||
|
*slash = '/';
|
||||||
|
|
||||||
|
filename = fixpath;
|
||||||
|
}
|
||||||
|
#endif // WIN32
|
||||||
|
|
||||||
// See if there is a directory in there...
|
// See if there is a directory in there...
|
||||||
fl_filename_absolute(pathname, sizeof(pathname), filename);
|
fl_filename_absolute(pathname, sizeof(pathname), filename);
|
||||||
|
|
||||||
if ((slash = strrchr(pathname, '/')) == NULL)
|
if ((slash = strrchr(pathname, '/')) != NULL) {
|
||||||
slash = strrchr(pathname, '\\');
|
|
||||||
|
|
||||||
if (slash != NULL) {
|
|
||||||
// Yes, change the display to the directory...
|
// Yes, change the display to the directory...
|
||||||
if (!fl_filename_isdir(pathname)) *slash++ = '\0';
|
if (!fl_filename_isdir(pathname)) *slash++ = '\0';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user