# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1319977987 0 # Node ID 700dc6818431e2c2f28fc6b8ff6d219eaeb8fb02 # Parent 107e38a29eeb15f31ea25a0a734667b5e3553257 Some code in dw_file_browse() seems to have gotten clobbered. This reenables defpath support on OS/2... memset() screwed it up. diff -r 107e38a29eeb -r 700dc6818431 os2/dw.c --- a/os2/dw.c Sun Oct 30 11:50:45 2011 +0000 +++ b/os2/dw.c Sun Oct 30 12:33:07 2011 +0000 @@ -33,6 +33,7 @@ #include #endif #include +#include #include "dw.h" #define QWP_USER 0 @@ -10091,31 +10092,49 @@ } else { - FILEDLG fild; + FILEDLG fild = { 0 }; HWND hwndFile; int len; + struct stat buf; if(defpath) strcpy(fild.szFullFile, defpath); - else - strcpy(fild.szFullFile, ""); len = strlen(fild.szFullFile); + /* If we have a defpath */ if(len) { - if(fild.szFullFile[len-1] != '\\') - strcat(fild.szFullFile, "\\"); - } - strcat(fild.szFullFile, "*"); - - if(ext) - { - strcat(fild.szFullFile, "."); - strcat(fild.szFullFile, ext); - } - - memset(&fild, 0, sizeof(FILEDLG)); + /* Check to see if it exists */ + if(stat(defpath, &buf) == 0) + { + /* If it is a directory... make sure there is a trailing \ */ + if(buf.st_mode & S_IFDIR) + { + if(fild.szFullFile[len-1] != '\\') + strcat(fild.szFullFile, "\\"); + /* Set len to 0 so the wildcard gets added below */ + len = 0; + } + } + } + + /* If we need a wildcard (defpath isn't a file) */ + if(!len) + { + /* Add a * to get all files... */ + strcat(fild.szFullFile, "*"); + + /* If an extension was requested... */ + if(ext) + { + /* Limit the results further */ + strcat(fild.szFullFile, "."); + strcat(fild.szFullFile, ext); + } + } + + /* Setup the structure */ fild.cbSize = sizeof(FILEDLG); fild.fl = FDS_CENTER | FDS_OPEN_DIALOG; fild.pszTitle = title;