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