diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2006-03-27 03:06:29 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2006-03-27 03:06:29 +0000 |
commit | 07c0b4c96a5a6fb5a95507d1ed85193574395aab (patch) | |
tree | 96005d630abcc3739ce24d7104f83f4a40174af9 | |
parent | 1074fd02b0d83cb7d13b1f649e1fab5a371fd634 (diff) |
got the full path working on windows... ug.. why is windows programming inevitably a total pain in the ass?
svn path=/trunk/externals/hcs/; revision=4779
-rw-r--r-- | folder_list.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/folder_list.c b/folder_list.c index e189dd2..fdf7935 100644 --- a/folder_list.c +++ b/folder_list.c @@ -9,7 +9,7 @@ #include <glob.h> #endif -static char *version = "$Revision: 1.6 $"; +static char *version = "$Revision: 1.7 $"; #define DEBUG(x) //#define DEBUG(x) x @@ -36,12 +36,21 @@ static void folder_list_output(t_folder_list* x) DEBUG(post("folder_list_output");); #ifdef _WIN32 - WIN32_FIND_DATA FindFileData; + WIN32_FIND_DATA findData; HANDLE hFind; DWORD errorNumber; LPVOID lpErrorMessage; + char fullPathNameBuffer[MAX_PATH+1] = ""; + char unbashBuffer[MAX_PATH+1] = ""; + char pathBuffer[MAX_PATH+1] = ""; + int length; + +// arg, looks perfect, but only in Windows Vista +// GetFinalPathNameByHandle(hFind,fullPathNameBuffer,MAX_PATH,FILE_NAME_NORMALIZED); + GetFullPathName(x->x_pattern->s_name,MAX_PATH,fullPathNameBuffer,NULL); + sys_unbashfilename(fullPathNameBuffer,unbashBuffer); - hFind = FindFirstFile(x->x_pattern->s_name, &FindFileData); + hFind = FindFirstFile(x->x_pattern->s_name, &findData); if (hFind == INVALID_HANDLE_VALUE) { errorNumber = GetLastError(); @@ -65,8 +74,19 @@ static void folder_list_output(t_folder_list* x) return; } do { - outlet_symbol( x->x_obj.ob_outlet, gensym(FindFileData.cFileName) ); - } while (FindNextFile(hFind, &FindFileData) != 0); + if( strcmp(findData.cFileName, ".") && strcmp(findData.cFileName, "..") ) + { + length = strlen(unbashBuffer); + do + { + length--; + } while ( *(unbashBuffer + length) == '/' ); + strncpy(pathBuffer, unbashBuffer, length); + pathBuffer[length] = '\0'; + strcat(pathBuffer,findData.cFileName); + outlet_symbol( x->x_obj.ob_outlet, gensym(pathBuffer) ); + } + } while (FindNextFile(hFind, &findData) != 0); FindClose(hFind); #else unsigned int i; |