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:
parent
5ca7674da3
commit
2c8fc6f66a
2
CHANGES
2
CHANGES
@ -2,6 +2,8 @@ CHANGES IN FLTK 1.1.7
|
||||
|
||||
- Documentation fixes (STR #648, STR #692, STR #730, STR
|
||||
#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
|
||||
directory, allowing all platforms to try the colbrowser
|
||||
demo (STR #843)
|
||||
|
||||
@ -158,6 +158,20 @@ Fl_File_Chooser::directory(const char *d)// I - Directory to change to
|
||||
if (d == NULL)
|
||||
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')
|
||||
{
|
||||
// Make the directory absolute...
|
||||
@ -1071,12 +1085,13 @@ Fl_File_Chooser::value(int f) // I - File number
|
||||
//
|
||||
|
||||
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
|
||||
fcount; // Number of items in list
|
||||
char *slash; // Directory separator
|
||||
char pathname[1024]; // Local copy of filename
|
||||
int i, // Looping var
|
||||
fcount; // Number of items in list
|
||||
char *slash; // Directory separator
|
||||
char pathname[1024]; // Local copy of 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;
|
||||
}
|
||||
|
||||
#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...
|
||||
fl_filename_absolute(pathname, sizeof(pathname), filename);
|
||||
|
||||
if ((slash = strrchr(pathname, '/')) == NULL)
|
||||
slash = strrchr(pathname, '\\');
|
||||
|
||||
if (slash != NULL) {
|
||||
if ((slash = strrchr(pathname, '/')) != NULL) {
|
||||
// Yes, change the display to the directory...
|
||||
if (!fl_filename_isdir(pathname)) *slash++ = '\0';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user