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