From b5f14ff78074d8caa3c7bd2ca33e77dad3a5c185 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Mon, 15 Aug 2005 20:03:36 +0000 Subject: fl_filename_list now correctly handles path names like 'c:' or 'c:/windows' by listing it contents instead of the filename itself. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4512 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 ++ src/scandir_win32.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 4c99d5d73..7ca8eaf84 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,8 @@ CHANGES IN FLTK 1.1.7 - Documentation fixes (STR #571, STR #648, STR #692, STR #730, STR #744, STR #745, STR #931, STR #942, STR #960, STR #969) + - fl_filename_list now recognizes pathnames without trailing + slash as directions (STR #854) - Fl_Text_Display now auto-scrolls in all directions (STR #915) - Borderless windows will not show in the taskbar anymore diff --git a/src/scandir_win32.c b/src/scandir_win32.c index c2c3f2ad8..001d4f94b 100644 --- a/src/scandir_win32.c +++ b/src/scandir_win32.c @@ -37,7 +37,7 @@ int fl_scandir(const char *dirname, struct dirent ***namelist, int (*select)(struct dirent *), int (*compar)(struct dirent **, struct dirent **)) { int len; - char *findIn, *d; + char *findIn, *d, is_dir = 0; WIN32_FIND_DATA find; HANDLE h; int nDir = 0, NDir = 0; @@ -52,10 +52,15 @@ int fl_scandir(const char *dirname, struct dirent ***namelist, strcpy(findIn, dirname); for (d = findIn; *d; d++) if (*d=='/') *d='\\'; if ((len==0)) { strcpy(findIn, ".\\*"); } - if ((len==1)&& (d[-1]=='.')) { strcpy(findIn, ".\\*"); } - if ((len>0) && (d[-1]=='\\')) { *d++ = '*'; *d = 0; } - if ((len>1) && (d[-1]=='.') && (d[-2]=='\\')) { d[-1] = '*'; } - + if ((len==2)&&findIn[1]==':'&&isalpha(findIn[0])) { *d++ = '\\'; *d = 0; } + if ((len==1)&& (d[-1]=='.')) { strcpy(findIn, ".\\*"); is_dir = 1; } + if ((len>0) && (d[-1]=='\\')) { *d++ = '*'; *d = 0; is_dir = 1; } + if ((len>1) && (d[-1]=='.') && (d[-2]=='\\')) { d[-1] = '*'; is_dir = 1; } + if (!is_dir) { // this file may still be a directory that we need to list + DWORD attr = GetFileAttributes(findIn); + if (attr&FILE_ATTRIBUTE_DIRECTORY) + strcpy(d, "\\*"); + } if ((h=FindFirstFile(findIn, &find))==INVALID_HANDLE_VALUE) { free(findIn); ret = GetLastError(); -- cgit v1.2.3