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