comparison os2/dw.c @ 1278:700dc6818431

Some code in dw_file_browse() seems to have gotten clobbered. This reenables defpath support on OS/2... memset() screwed it up.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 30 Oct 2011 12:33:07 +0000
parents 1cdc18d760e0
children 4f0f816f1e76
comparison
equal deleted inserted replaced
1277:107e38a29eeb 1278:700dc6818431
31 #include <math.h> 31 #include <math.h>
32 #ifndef __EMX__ 32 #ifndef __EMX__
33 #include <direct.h> 33 #include <direct.h>
34 #endif 34 #endif
35 #include <sys/time.h> 35 #include <sys/time.h>
36 #include <sys/stat.h>
36 #include "dw.h" 37 #include "dw.h"
37 38
38 #define QWP_USER 0 39 #define QWP_USER 0
39 40
40 /* The toolkit headers don't seem to have this */ 41 /* The toolkit headers don't seem to have this */
10089 dw_thread_new((void *)_populate_tree_thread, (void *)window, 0xff); 10090 dw_thread_new((void *)_populate_tree_thread, (void *)window, 0xff);
10090 return (char *)dw_dialog_wait(dwwait); 10091 return (char *)dw_dialog_wait(dwwait);
10091 } 10092 }
10092 else 10093 else
10093 { 10094 {
10094 FILEDLG fild; 10095 FILEDLG fild = { 0 };
10095 HWND hwndFile; 10096 HWND hwndFile;
10096 int len; 10097 int len;
10098 struct stat buf;
10097 10099
10098 if(defpath) 10100 if(defpath)
10099 strcpy(fild.szFullFile, defpath); 10101 strcpy(fild.szFullFile, defpath);
10100 else
10101 strcpy(fild.szFullFile, "");
10102 10102
10103 len = strlen(fild.szFullFile); 10103 len = strlen(fild.szFullFile);
10104 10104
10105 /* If we have a defpath */
10105 if(len) 10106 if(len)
10106 { 10107 {
10107 if(fild.szFullFile[len-1] != '\\') 10108 /* Check to see if it exists */
10108 strcat(fild.szFullFile, "\\"); 10109 if(stat(defpath, &buf) == 0)
10109 } 10110 {
10110 strcat(fild.szFullFile, "*"); 10111 /* If it is a directory... make sure there is a trailing \ */
10111 10112 if(buf.st_mode & S_IFDIR)
10112 if(ext) 10113 {
10113 { 10114 if(fild.szFullFile[len-1] != '\\')
10114 strcat(fild.szFullFile, "."); 10115 strcat(fild.szFullFile, "\\");
10115 strcat(fild.szFullFile, ext); 10116 /* Set len to 0 so the wildcard gets added below */
10116 } 10117 len = 0;
10117 10118 }
10118 memset(&fild, 0, sizeof(FILEDLG)); 10119 }
10120 }
10121
10122 /* If we need a wildcard (defpath isn't a file) */
10123 if(!len)
10124 {
10125 /* Add a * to get all files... */
10126 strcat(fild.szFullFile, "*");
10127
10128 /* If an extension was requested... */
10129 if(ext)
10130 {
10131 /* Limit the results further */
10132 strcat(fild.szFullFile, ".");
10133 strcat(fild.szFullFile, ext);
10134 }
10135 }
10136
10137 /* Setup the structure */
10119 fild.cbSize = sizeof(FILEDLG); 10138 fild.cbSize = sizeof(FILEDLG);
10120 fild.fl = FDS_CENTER | FDS_OPEN_DIALOG; 10139 fild.fl = FDS_CENTER | FDS_OPEN_DIALOG;
10121 fild.pszTitle = title; 10140 fild.pszTitle = title;
10122 fild.pszOKButton = ((flags & DW_FILE_SAVE) ? "Save" : "Open"); 10141 fild.pszOKButton = ((flags & DW_FILE_SAVE) ? "Save" : "Open");
10123 fild.pfnDlgProc = (PFNWP)WinDefFileDlgProc; 10142 fild.pfnDlgProc = (PFNWP)WinDefFileDlgProc;