| 1 | 
 | 
|---|
| 2 | /***********************************************************************
 | 
|---|
| 3 | 
 | 
|---|
| 4 |   $Id: getnames.c 1673 2012-12-30 18:51:01Z gyoung $
 | 
|---|
| 5 | 
 | 
|---|
| 6 |   Directory containers
 | 
|---|
| 7 | 
 | 
|---|
| 8 |   Copyright (c) 1993-98 M. Kimes
 | 
|---|
| 9 |   Copyright (c) 2006, 2010 Steven H. Levine
 | 
|---|
| 10 | 
 | 
|---|
| 11 |   23 Aug 06 SHL Comments
 | 
|---|
| 12 |   20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
 | 
|---|
| 13 |   08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used)
 | 
|---|
| 14 |   28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
 | 
|---|
| 15 |   17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
 | 
|---|
| 16 |   23 Oct 10 GKY Add ForwardslashToBackslash function to streamline code
 | 
|---|
| 17 | 
 | 
|---|
| 18 | ***********************************************************************/
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include <string.h>
 | 
|---|
| 21 | #include <ctype.h>
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #define INCL_DOS
 | 
|---|
| 24 | #define INCL_WIN
 | 
|---|
| 25 | #define INCL_LONGLONG
 | 
|---|
| 26 | 
 | 
|---|
| 27 | #include "fm3dll.h"
 | 
|---|
| 28 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc.
 | 
|---|
| 29 | #include "notebook.h"                   // Data declaration(s)
 | 
|---|
| 30 | #include "info.h"                       // Data declaration(s)
 | 
|---|
| 31 | #include "init.h"                       // Data declaration(s)
 | 
|---|
| 32 | #include "mainwnd.h"                    // Data declaration(s)
 | 
|---|
| 33 | #include "fm3dlg.h"
 | 
|---|
| 34 | #include "fm3str.h"
 | 
|---|
| 35 | #include "errutil.h"                    // Dos_Error...
 | 
|---|
| 36 | #include "strutil.h"                    // GetPString
 | 
|---|
| 37 | #include "getnames.h"
 | 
|---|
| 38 | #include "walkem.h"                     // load_udirs, remove_udir
 | 
|---|
| 39 | #include "valid.h"                      // MakeFullName
 | 
|---|
| 40 | #include "copyf.h"                      // unlinkf
 | 
|---|
| 41 | #include "misc.h"                       // PaintRecessedWindow
 | 
|---|
| 42 | #include "wrappers.h"                   // xDosFindFirst
 | 
|---|
| 43 | #include "pathutil.h"                   // AddBackslashToPath
 | 
|---|
| 44 | 
 | 
|---|
| 45 | #pragma data_seg(DATA1)
 | 
|---|
| 46 | 
 | 
|---|
| 47 | MRESULT EXPENTRY CustomFileDlg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 | 
|---|
| 48 | {
 | 
|---|
| 49 |   switch (msg) {
 | 
|---|
| 50 |   case WM_INITDLG:
 | 
|---|
| 51 |     if (!loadedudirs)
 | 
|---|
| 52 |       load_udirs();
 | 
|---|
| 53 |     {                                   // fill user list box
 | 
|---|
| 54 |       ULONG ulDriveNum, ulDriveMap;
 | 
|---|
| 55 |       ULONG ulSearchCount;
 | 
|---|
| 56 |       FILEFINDBUF3L findbuf;
 | 
|---|
| 57 |       HDIR hDir;
 | 
|---|
| 58 |       APIRET rc;
 | 
|---|
| 59 |       LINKDIRS *info, *temp;
 | 
|---|
| 60 | 
 | 
|---|
| 61 |       DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 62 |       DosQCurDisk(&ulDriveNum, &ulDriveMap);
 | 
|---|
| 63 |       info = udirhead;
 | 
|---|
| 64 |       while (info) {
 | 
|---|
| 65 |         if (IsFullName(info->path) &&
 | 
|---|
| 66 |             !(driveflags[toupper(*info->path) - 'A'] &
 | 
|---|
| 67 |               (DRIVE_IGNORE | DRIVE_INVALID))) {
 | 
|---|
| 68 |           DosError(FERR_DISABLEHARDERR);
 | 
|---|
| 69 |           hDir = HDIR_CREATE;
 | 
|---|
| 70 |           ulSearchCount = 1L;
 | 
|---|
| 71 |           if (!IsRoot(info->path))
 | 
|---|
| 72 |             rc = xDosFindFirst(info->path, &hDir, FILE_DIRECTORY |
 | 
|---|
| 73 |                                MUST_HAVE_DIRECTORY | FILE_READONLY |
 | 
|---|
| 74 |                                FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
 | 
|---|
| 75 |                                &findbuf, sizeof(FILEFINDBUF3L),
 | 
|---|
| 76 |                                &ulSearchCount, FIL_STANDARDL);
 | 
|---|
| 77 |           else {
 | 
|---|
| 78 |             rc = 0;
 | 
|---|
| 79 |             findbuf.attrFile = FILE_DIRECTORY;
 | 
|---|
| 80 |           }
 | 
|---|
| 81 |           if (!rc) {
 | 
|---|
| 82 |             if (!IsRoot(info->path))
 | 
|---|
| 83 |               DosFindClose(hDir);
 | 
|---|
| 84 |             if (findbuf.attrFile & FILE_DIRECTORY)
 | 
|---|
| 85 |               WinSendDlgItemMsg(hwnd, FDLG_USERDIRS, LM_INSERTITEM,
 | 
|---|
| 86 |                                 MPFROM2SHORT(LIT_SORTASCENDING, 0),
 | 
|---|
| 87 |                                 MPFROMP(info->path));
 | 
|---|
| 88 |             else {
 | 
|---|
| 89 |               temp = info->next;
 | 
|---|
| 90 |               remove_udir(info->path);
 | 
|---|
| 91 |               info = temp;
 | 
|---|
| 92 |               continue;
 | 
|---|
| 93 |             }
 | 
|---|
| 94 |           }
 | 
|---|
| 95 |           else if (!(ulDriveMap & (1L << (toupper(*info->path) - 'A')))) {
 | 
|---|
| 96 |             temp = info->next;
 | 
|---|
| 97 |             remove_udir(info->path);
 | 
|---|
| 98 |             info = temp;
 | 
|---|
| 99 |             continue;
 | 
|---|
| 100 |           }
 | 
|---|
| 101 |         }
 | 
|---|
| 102 |         info = info->next;
 | 
|---|
| 103 |       }
 | 
|---|
| 104 |     }
 | 
|---|
| 105 |     break;
 | 
|---|
| 106 | 
 | 
|---|
| 107 |   case WM_ADJUSTWINDOWPOS:
 | 
|---|
| 108 |     PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
 | 
|---|
| 109 |     break;
 | 
|---|
| 110 | 
 | 
|---|
| 111 |   case UM_SETDIR:
 | 
|---|
| 112 |     PaintRecessedWindow(WinWindowFromID(hwnd, FDLG_HELP),
 | 
|---|
| 113 |                         (HPS) 0, FALSE, TRUE);
 | 
|---|
| 114 |     return 0;
 | 
|---|
| 115 | 
 | 
|---|
| 116 |   case WM_CONTROL:
 | 
|---|
| 117 |     switch (SHORT1FROMMP(mp1)) {
 | 
|---|
| 118 |     case 260:                           // drives dropdown list
 | 
|---|
| 119 |       switch (SHORT2FROMMP(mp1)) {
 | 
|---|
| 120 |       case CBN_SHOWLIST:
 | 
|---|
| 121 |         WinSetDlgItemText(hwnd,
 | 
|---|
| 122 |                           FDLG_HELP, (CHAR *) GetPString(IDS_CLICKDRIVEHELPTEXT));
 | 
|---|
| 123 |         break;
 | 
|---|
| 124 |       }
 | 
|---|
| 125 |       break;
 | 
|---|
| 126 | 
 | 
|---|
| 127 |     case 258:                           // name entry field
 | 
|---|
| 128 |       switch (SHORT2FROMMP(mp1)) {
 | 
|---|
| 129 |       case EN_SETFOCUS:
 | 
|---|
| 130 |         WinSetDlgItemText(hwnd,
 | 
|---|
| 131 |                           FDLG_HELP, (CHAR *) GetPString(IDS_ENTERFILEORMASKHELPTEXT));
 | 
|---|
| 132 |         break;
 | 
|---|
| 133 |       case EN_KILLFOCUS:
 | 
|---|
| 134 |         WinSetDlgItemText(hwnd, FDLG_HELP, (CHAR *) GetPString(IDS_NAMEDEFHELPTEXT));
 | 
|---|
| 135 |         break;
 | 
|---|
| 136 |       }
 | 
|---|
| 137 |       break;
 | 
|---|
| 138 | 
 | 
|---|
| 139 |     case 264:                           // dirs listbox
 | 
|---|
| 140 |       switch (SHORT2FROMMP(mp1)) {
 | 
|---|
| 141 |       case LN_SETFOCUS:
 | 
|---|
| 142 |         WinSetDlgItemText(hwnd,
 | 
|---|
| 143 |                           FDLG_HELP, (CHAR *) GetPString(IDS_DBLCLKDIRSWITCHHELPTEXT));
 | 
|---|
| 144 |         break;
 | 
|---|
| 145 |       case LN_KILLFOCUS:
 | 
|---|
| 146 |         WinSetDlgItemText(hwnd, FDLG_HELP, (CHAR *) GetPString(IDS_NAMEDEFHELPTEXT));
 | 
|---|
| 147 |         break;
 | 
|---|
| 148 |       }
 | 
|---|
| 149 |       break;
 | 
|---|
| 150 | 
 | 
|---|
| 151 |     case 266:                           // files listbox
 | 
|---|
| 152 |       switch (SHORT2FROMMP(mp1)) {
 | 
|---|
| 153 |       case LN_SETFOCUS:
 | 
|---|
| 154 |         WinSetDlgItemText(hwnd, FDLG_HELP,
 | 
|---|
| 155 |                           (CHAR *) GetPString(IDS_DBLCLKFILEUSEHELPTEXT));
 | 
|---|
| 156 |         break;
 | 
|---|
| 157 |       case LN_KILLFOCUS:
 | 
|---|
| 158 |         WinSetDlgItemText(hwnd, FDLG_HELP, (CHAR *) GetPString(IDS_NAMEDEFHELPTEXT));
 | 
|---|
| 159 |         break;
 | 
|---|
| 160 |       }
 | 
|---|
| 161 |       break;
 | 
|---|
| 162 | 
 | 
|---|
| 163 |     case FDLG_USERDIRS:
 | 
|---|
| 164 |       switch (SHORT2FROMMP(mp1)) {
 | 
|---|
| 165 |       case CBN_SHOWLIST:
 | 
|---|
| 166 |         WinSetDlgItemText(hwnd,
 | 
|---|
| 167 |                           FDLG_HELP, (CHAR *) GetPString(IDS_DBLCLKDIRSWITCHHELPTEXT));
 | 
|---|
| 168 |         break;
 | 
|---|
| 169 |       case CBN_ENTER:
 | 
|---|
| 170 |         {
 | 
|---|
| 171 |           SHORT sSelect;
 | 
|---|
| 172 |           CHAR szBuffer[CCHMAXPATH], szTemp[CCHMAXPATH], *p;
 | 
|---|
| 173 | 
 | 
|---|
| 174 |           sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
 | 
|---|
| 175 |                                                FDLG_USERDIRS,
 | 
|---|
| 176 |                                                LM_QUERYSELECTION,
 | 
|---|
| 177 |                                                MPVOID, MPVOID);
 | 
|---|
| 178 |           *szBuffer = 0;
 | 
|---|
| 179 |           if (sSelect >= 0) {
 | 
|---|
| 180 |             WinSendDlgItemMsg(hwnd,
 | 
|---|
| 181 |                               FDLG_USERDIRS,
 | 
|---|
| 182 |                               LM_QUERYITEMTEXT,
 | 
|---|
| 183 |                               MPFROM2SHORT(sSelect,
 | 
|---|
| 184 |                                            CCHMAXPATH), MPFROMP(szBuffer));
 | 
|---|
| 185 |             if (*szBuffer) {
 | 
|---|
| 186 |               AddBackslashToPath(szBuffer);
 | 
|---|
| 187 |               //if (szBuffer[strlen(szBuffer) - 1] != '\\')
 | 
|---|
| 188 |               //  strcat(szBuffer, "\\");
 | 
|---|
| 189 |               *szTemp = 0;
 | 
|---|
| 190 |               WinQueryDlgItemText(hwnd, 258, CCHMAXPATH, szTemp);
 | 
|---|
| 191 |               p = strrchr(szTemp, '\\');
 | 
|---|
| 192 |               if (!p)
 | 
|---|
| 193 |                 p = szTemp;
 | 
|---|
| 194 |               else
 | 
|---|
| 195 |                 p++;
 | 
|---|
| 196 |               if (*p)
 | 
|---|
| 197 |                 strcat(szBuffer, p);
 | 
|---|
| 198 |               if (!strchr(szBuffer, '?') && !strchr(szBuffer, '*'))
 | 
|---|
| 199 |                 strcat(szBuffer, "*");
 | 
|---|
| 200 |               WinSetDlgItemText(hwnd, 258, szBuffer);
 | 
|---|
| 201 |               PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
 | 
|---|
| 202 |             }
 | 
|---|
| 203 |           }
 | 
|---|
| 204 |         }
 | 
|---|
| 205 |         break;
 | 
|---|
| 206 |       default:
 | 
|---|
| 207 |         break;
 | 
|---|
| 208 |       }
 | 
|---|
| 209 |       break;
 | 
|---|
| 210 |     }
 | 
|---|
| 211 |     break;
 | 
|---|
| 212 | 
 | 
|---|
| 213 |   case WM_HELP:
 | 
|---|
| 214 |     if (hwndHelp) {
 | 
|---|
| 215 |       WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
 | 
|---|
| 216 |                  MPFROM2SHORT(HELP_FILEDLG, 0), MPFROMSHORT(HM_RESOURCEID));
 | 
|---|
| 217 |       return 0;
 | 
|---|
| 218 |     }
 | 
|---|
| 219 |     break;
 | 
|---|
| 220 |   }
 | 
|---|
| 221 |   return WinDefFileDlgProc(hwnd, msg, mp1, mp2);
 | 
|---|
| 222 | }
 | 
|---|
| 223 | 
 | 
|---|
| 224 | BOOL insert_filename(HWND hwnd, CHAR * filename, INT loadit, BOOL newok)
 | 
|---|
| 225 | {
 | 
|---|
| 226 |   FILEDLG fdlg;
 | 
|---|
| 227 |   FILESTATUS3 fsa;
 | 
|---|
| 228 |   CHAR drive[3], *pdrive = drive, *p;
 | 
|---|
| 229 |   APIRET rc;
 | 
|---|
| 230 |   static CHAR lastfilename[CCHMAXPATH] = "";
 | 
|---|
| 231 | 
 | 
|---|
| 232 |   if (!filename)
 | 
|---|
| 233 |     return FALSE;
 | 
|---|
| 234 |   memset(&fdlg, 0, sizeof(FILEDLG));
 | 
|---|
| 235 |   fdlg.cbSize = (ULONG) sizeof(FILEDLG);
 | 
|---|
| 236 |   fdlg.fl = FDS_CENTER | FDS_OPEN_DIALOG;
 | 
|---|
| 237 |   if (!loadit) {
 | 
|---|
| 238 |     fdlg.pszTitle = (PSZ)GetPString(IDS_ENTERFILEINSERTTEXT);
 | 
|---|
| 239 |     fdlg.pszOKButton = (PSZ)GetPString(IDS_INSERTTEXT);
 | 
|---|
| 240 |   }
 | 
|---|
| 241 |   else if (loadit == TRUE) {
 | 
|---|
| 242 |     fdlg.pszTitle = (PSZ)GetPString(IDS_ENTERFILELOADTEXT);
 | 
|---|
| 243 |     fdlg.pszOKButton = (PSZ)GetPString(IDS_LOADTEXT);
 | 
|---|
| 244 |   }
 | 
|---|
| 245 |   else {
 | 
|---|
| 246 |     fdlg.pszTitle = (PSZ)GetPString(IDS_ENTERFILETEXT);
 | 
|---|
| 247 |     fdlg.pszOKButton = (PSZ)GetPString(IDS_OKAYTEXT);
 | 
|---|
| 248 |   }
 | 
|---|
| 249 |   if (IsFullName(filename)) {
 | 
|---|
| 250 |     *drive = *filename;
 | 
|---|
| 251 |     drive[1] = ':';
 | 
|---|
| 252 |     drive[2] = 0;
 | 
|---|
| 253 |     fdlg.pszIDrive = pdrive;
 | 
|---|
| 254 |   }
 | 
|---|
| 255 |   else if (*lastfilename) {
 | 
|---|
| 256 |     *drive = *lastfilename;
 | 
|---|
| 257 |     drive[1] = ':';
 | 
|---|
| 258 |     drive[2] = 0;
 | 
|---|
| 259 |     fdlg.pszIDrive = pdrive;
 | 
|---|
| 260 |   }
 | 
|---|
| 261 | 
 | 
|---|
| 262 |   if (!*filename) {
 | 
|---|
| 263 |     if (*lastfilename) {
 | 
|---|
| 264 |       strcpy(fdlg.szFullFile, lastfilename);
 | 
|---|
| 265 |       p = strrchr(fdlg.szFullFile, '\\');
 | 
|---|
| 266 |       if (p) {
 | 
|---|
| 267 |         p++;
 | 
|---|
| 268 |         *p = 0;
 | 
|---|
| 269 |       }
 | 
|---|
| 270 |     }
 | 
|---|
| 271 |     if (!loadit || loadit == TRUE)
 | 
|---|
| 272 |       strcat(fdlg.szFullFile, PCSZ_STARDOTTXT);
 | 
|---|
| 273 |     else
 | 
|---|
| 274 |       strcat(fdlg.szFullFile, "*");
 | 
|---|
| 275 |   }
 | 
|---|
| 276 |   else
 | 
|---|
| 277 |     strcpy(fdlg.szFullFile, filename);
 | 
|---|
| 278 | 
 | 
|---|
| 279 |   if (fCustomFileDlg) {
 | 
|---|
| 280 |     fdlg.fl |= FDS_HELPBUTTON | FDS_CUSTOM;
 | 
|---|
| 281 |     fdlg.pfnDlgProc = (PFNWP) CustomFileDlg;
 | 
|---|
| 282 |     fdlg.hMod = FM3ModHandle;
 | 
|---|
| 283 |     fdlg.usDlgId = FDLG_FRAME;
 | 
|---|
| 284 |   }
 | 
|---|
| 285 | 
 | 
|---|
| 286 |   if (WinFileDlg(HWND_DESKTOP, hwnd, &fdlg)) {
 | 
|---|
| 287 |     if (fdlg.lReturn != DID_CANCEL && !fdlg.lSRC)
 | 
|---|
| 288 |       strcpy(filename, fdlg.szFullFile);
 | 
|---|
| 289 |     else
 | 
|---|
| 290 |       return FALSE;
 | 
|---|
| 291 |   }
 | 
|---|
| 292 |   else
 | 
|---|
| 293 |     return FALSE;
 | 
|---|
| 294 |   MakeFullName(filename);
 | 
|---|
| 295 |   if (!DosQueryPathInfo(filename, FIL_STANDARD, &fsa, sizeof(fsa))) {
 | 
|---|
| 296 |     if (fsa.attrFile & FILE_DIRECTORY) {
 | 
|---|
| 297 |       // device or directory
 | 
|---|
| 298 |       saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
 | 
|---|
| 299 |              hwnd, filename, GetPString(IDS_EXISTSBUTNOTFILETEXT), filename);
 | 
|---|
| 300 |       return FALSE;
 | 
|---|
| 301 |     }
 | 
|---|
| 302 |     else if (fsa.cbFile == 0) {
 | 
|---|
| 303 |       saymsg(MB_CANCEL,
 | 
|---|
| 304 |              hwnd, filename, GetPString(IDS_ISZEROLENGTHTEXT), filename);
 | 
|---|
| 305 |       return FALSE;
 | 
|---|
| 306 |     }
 | 
|---|
| 307 |   }
 | 
|---|
| 308 |   else if (!newok) {
 | 
|---|
| 309 |     saymsg(MB_CANCEL,
 | 
|---|
| 310 |            hwnd, filename, GetPString(IDS_DOESNTEXISTTEXT), filename);
 | 
|---|
| 311 |     return FALSE;
 | 
|---|
| 312 |   }
 | 
|---|
| 313 |   else {
 | 
|---|
| 314 |     rc = saymsg(MB_YESNOCANCEL,
 | 
|---|
| 315 |                 hwnd, filename, GetPString(IDS_CREATENEWTEXT));
 | 
|---|
| 316 |     if (rc != MBID_YES)
 | 
|---|
| 317 |       return FALSE;
 | 
|---|
| 318 |   }
 | 
|---|
| 319 |   ForwardslashToBackslash(filename);
 | 
|---|
| 320 |   if (*filename)
 | 
|---|
| 321 |     strcpy(lastfilename, filename);
 | 
|---|
| 322 |   return TRUE;
 | 
|---|
| 323 | }
 | 
|---|
| 324 | 
 | 
|---|
| 325 | BOOL export_filename(HWND hwnd, CHAR * filename, INT overwrite)
 | 
|---|
| 326 | {
 | 
|---|
| 327 |   FILEDLG fdlg;
 | 
|---|
| 328 |   FILESTATUS3 fsa;
 | 
|---|
| 329 |   CHAR drive[3], *pdrive = drive, *p;
 | 
|---|
| 330 |   static CHAR lastfilename[CCHMAXPATH] = "";
 | 
|---|
| 331 | 
 | 
|---|
| 332 |   if (!filename)
 | 
|---|
| 333 |     return FALSE;
 | 
|---|
| 334 |   memset(&fdlg, 0, sizeof(FILEDLG));
 | 
|---|
| 335 |   fdlg.cbSize = sizeof(FILEDLG);
 | 
|---|
| 336 |   fdlg.fl = FDS_CENTER | FDS_OPEN_DIALOG;
 | 
|---|
| 337 |   fdlg.pszTitle = (PSZ)GetPString(IDS_EXPORTNAMETITLETEXT);
 | 
|---|
| 338 |   fdlg.pszOKButton = (PSZ)GetPString(IDS_OKAYTEXT);
 | 
|---|
| 339 |   if (IsFullName(filename)) {
 | 
|---|
| 340 |     *drive = *filename;
 | 
|---|
| 341 |     drive[1] = ':';
 | 
|---|
| 342 |     drive[2] = 0;
 | 
|---|
| 343 |     fdlg.pszIDrive = pdrive;
 | 
|---|
| 344 |   }
 | 
|---|
| 345 |   else if (*lastfilename) {
 | 
|---|
| 346 |     *drive = *lastfilename;
 | 
|---|
| 347 |     drive[1] = ':';
 | 
|---|
| 348 |     drive[2] = 0;
 | 
|---|
| 349 |     fdlg.pszIDrive = pdrive;
 | 
|---|
| 350 |   }
 | 
|---|
| 351 |   if (!*filename) {
 | 
|---|
| 352 |     if (*lastfilename) {
 | 
|---|
| 353 |       strcpy(fdlg.szFullFile, lastfilename);
 | 
|---|
| 354 |       p = strrchr(fdlg.szFullFile, '\\');
 | 
|---|
| 355 |       if (p) {
 | 
|---|
| 356 |         p++;
 | 
|---|
| 357 |         *p = 0;
 | 
|---|
| 358 |       }
 | 
|---|
| 359 |     }
 | 
|---|
| 360 |     strcat(fdlg.szFullFile, PCSZ_STARDOTTXT);
 | 
|---|
| 361 |   }
 | 
|---|
| 362 |   else
 | 
|---|
| 363 |     strcpy(fdlg.szFullFile, filename);
 | 
|---|
| 364 | 
 | 
|---|
| 365 |   if (fCustomFileDlg) {
 | 
|---|
| 366 |     fdlg.fl |= FDS_HELPBUTTON | FDS_CUSTOM;
 | 
|---|
| 367 |     fdlg.pfnDlgProc = (PFNWP) CustomFileDlg;
 | 
|---|
| 368 |     fdlg.hMod = FM3ModHandle;
 | 
|---|
| 369 |     fdlg.usDlgId = FDLG_FRAME;
 | 
|---|
| 370 |   }
 | 
|---|
| 371 | 
 | 
|---|
| 372 |   if (WinFileDlg(HWND_DESKTOP, hwnd, &fdlg)) {
 | 
|---|
| 373 |     if (fdlg.lReturn != DID_CANCEL && !fdlg.lSRC)
 | 
|---|
| 374 |       strcpy(filename, fdlg.szFullFile);
 | 
|---|
| 375 |     else
 | 
|---|
| 376 |       return FALSE;
 | 
|---|
| 377 |   }
 | 
|---|
| 378 |   else
 | 
|---|
| 379 |     return FALSE;
 | 
|---|
| 380 |   MakeFullName(filename);
 | 
|---|
| 381 |   if (!DosQueryPathInfo(filename, FIL_STANDARD, &fsa, sizeof(fsa))) {
 | 
|---|
| 382 |     if (fsa.attrFile & FILE_DIRECTORY) {        // device or directory
 | 
|---|
| 383 |       saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
 | 
|---|
| 384 |              hwnd, filename, GetPString(IDS_EXISTSBUTNOTFILETEXT), filename);
 | 
|---|
| 385 |       return FALSE;
 | 
|---|
| 386 |     }
 | 
|---|
| 387 |     else if (overwrite && fsa.cbFile != 0) {
 | 
|---|
| 388 |       if (saymsg(MB_YESNO,
 | 
|---|
| 389 |                  hwnd,
 | 
|---|
| 390 |                  filename,
 | 
|---|
| 391 |                  GetPString(IDS_EXISTSERASETEXT), filename) == MBID_YES)
 | 
|---|
| 392 |         unlinkf(filename);
 | 
|---|
| 393 |     }
 | 
|---|
| 394 |   }
 | 
|---|
| 395 |   ForwardslashToBackslash(filename);
 | 
|---|
| 396 |   if (*filename)
 | 
|---|
| 397 |     strcpy(lastfilename, filename);
 | 
|---|
| 398 |   return TRUE;
 | 
|---|
| 399 | }
 | 
|---|
| 400 | 
 | 
|---|
| 401 | #pragma alloc_text(GETNAMES,insert_filename,export_filename,CustomFileDlg)
 | 
|---|