| [451] | 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 | 
|---|
| [1498] | 9 | Copyright (c) 2006, 2010 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. | 
|---|
| [1498] | 15 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *. | 
|---|
| [1545] | 16 | 23 Oct 10 GKY Add ForwardslashToBackslash function to streamline code | 
|---|
| [451] | 17 |  | 
|---|
|  | 18 | ***********************************************************************/ | 
|---|
|  | 19 |  | 
|---|
| [907] | 20 | #include <string.h> | 
|---|
|  | 21 | #include <ctype.h> | 
|---|
|  | 22 |  | 
|---|
| [2] | 23 | #define INCL_DOS | 
|---|
|  | 24 | #define INCL_WIN | 
|---|
| [841] | 25 | #define INCL_LONGLONG | 
|---|
| [2] | 26 |  | 
|---|
| [1180] | 27 | #include "fm3dll.h" | 
|---|
| [1223] | 28 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| [1208] | 29 | #include "notebook.h"                   // Data declaration(s) | 
|---|
|  | 30 | #include "info.h"                       // Data declaration(s) | 
|---|
| [1398] | 31 | #include "init.h"                       // Data declaration(s) | 
|---|
| [1208] | 32 | #include "mainwnd.h"                    // Data declaration(s) | 
|---|
| [2] | 33 | #include "fm3dlg.h" | 
|---|
|  | 34 | #include "fm3str.h" | 
|---|
| [907] | 35 | #include "errutil.h"                    // Dos_Error... | 
|---|
|  | 36 | #include "strutil.h"                    // GetPString | 
|---|
| [1158] | 37 | #include "getnames.h" | 
|---|
|  | 38 | #include "walkem.h"                     // load_udirs, remove_udir | 
|---|
| [1180] | 39 | #include "valid.h"                      // MakeFullName | 
|---|
|  | 40 | #include "copyf.h"                      // unlinkf | 
|---|
|  | 41 | #include "misc.h"                       // PaintRecessedWindow | 
|---|
|  | 42 | #include "wrappers.h"                   // xDosFindFirst | 
|---|
| [1438] | 43 | #include "pathutil.h"                   // AddBackslashToPath | 
|---|
| [2] | 44 |  | 
|---|
|  | 45 | #pragma data_seg(DATA1) | 
|---|
|  | 46 |  | 
|---|
| [551] | 47 | MRESULT EXPENTRY CustomFileDlg(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| [451] | 48 | { | 
|---|
| [551] | 49 | switch (msg) { | 
|---|
|  | 50 | case WM_INITDLG: | 
|---|
|  | 51 | if (!loadedudirs) | 
|---|
|  | 52 | load_udirs(); | 
|---|
| [1673] | 53 | {                                   // fill user list box | 
|---|
| [551] | 54 | ULONG ulDriveNum, ulDriveMap; | 
|---|
|  | 55 | ULONG ulSearchCount; | 
|---|
| [841] | 56 | FILEFINDBUF3L findbuf; | 
|---|
| [551] | 57 | HDIR hDir; | 
|---|
|  | 58 | APIRET rc; | 
|---|
|  | 59 | LINKDIRS *info, *temp; | 
|---|
| [2] | 60 |  | 
|---|
| [551] | 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)) | 
|---|
| [838] | 72 | rc = xDosFindFirst(info->path, &hDir, FILE_DIRECTORY | | 
|---|
|  | 73 | MUST_HAVE_DIRECTORY | FILE_READONLY | | 
|---|
|  | 74 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN, | 
|---|
| [841] | 75 | &findbuf, sizeof(FILEFINDBUF3L), | 
|---|
|  | 76 | &ulSearchCount, FIL_STANDARDL); | 
|---|
| [551] | 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; | 
|---|
| [2] | 103 | } | 
|---|
| [551] | 104 | } | 
|---|
|  | 105 | break; | 
|---|
| [2] | 106 |  | 
|---|
| [551] | 107 | case WM_ADJUSTWINDOWPOS: | 
|---|
|  | 108 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID); | 
|---|
|  | 109 | break; | 
|---|
| [2] | 110 |  | 
|---|
| [551] | 111 | case UM_SETDIR: | 
|---|
|  | 112 | PaintRecessedWindow(WinWindowFromID(hwnd, FDLG_HELP), | 
|---|
|  | 113 | (HPS) 0, FALSE, TRUE); | 
|---|
|  | 114 | return 0; | 
|---|
| [2] | 115 |  | 
|---|
| [551] | 116 | case WM_CONTROL: | 
|---|
|  | 117 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| [1673] | 118 | case 260:                           // drives dropdown list | 
|---|
| [551] | 119 | switch (SHORT2FROMMP(mp1)) { | 
|---|
|  | 120 | case CBN_SHOWLIST: | 
|---|
|  | 121 | WinSetDlgItemText(hwnd, | 
|---|
| [1498] | 122 | FDLG_HELP, (CHAR *) GetPString(IDS_CLICKDRIVEHELPTEXT)); | 
|---|
| [551] | 123 | break; | 
|---|
|  | 124 | } | 
|---|
|  | 125 | break; | 
|---|
| [2] | 126 |  | 
|---|
| [1673] | 127 | case 258:                           // name entry field | 
|---|
| [551] | 128 | switch (SHORT2FROMMP(mp1)) { | 
|---|
|  | 129 | case EN_SETFOCUS: | 
|---|
|  | 130 | WinSetDlgItemText(hwnd, | 
|---|
| [1498] | 131 | FDLG_HELP, (CHAR *) GetPString(IDS_ENTERFILEORMASKHELPTEXT)); | 
|---|
| [551] | 132 | break; | 
|---|
|  | 133 | case EN_KILLFOCUS: | 
|---|
| [1498] | 134 | WinSetDlgItemText(hwnd, FDLG_HELP, (CHAR *) GetPString(IDS_NAMEDEFHELPTEXT)); | 
|---|
| [551] | 135 | break; | 
|---|
|  | 136 | } | 
|---|
|  | 137 | break; | 
|---|
| [2] | 138 |  | 
|---|
| [1673] | 139 | case 264:                           // dirs listbox | 
|---|
| [551] | 140 | switch (SHORT2FROMMP(mp1)) { | 
|---|
|  | 141 | case LN_SETFOCUS: | 
|---|
|  | 142 | WinSetDlgItemText(hwnd, | 
|---|
| [1498] | 143 | FDLG_HELP, (CHAR *) GetPString(IDS_DBLCLKDIRSWITCHHELPTEXT)); | 
|---|
| [551] | 144 | break; | 
|---|
|  | 145 | case LN_KILLFOCUS: | 
|---|
| [1498] | 146 | WinSetDlgItemText(hwnd, FDLG_HELP, (CHAR *) GetPString(IDS_NAMEDEFHELPTEXT)); | 
|---|
| [551] | 147 | break; | 
|---|
|  | 148 | } | 
|---|
|  | 149 | break; | 
|---|
| [2] | 150 |  | 
|---|
| [1673] | 151 | case 266:                           // files listbox | 
|---|
| [551] | 152 | switch (SHORT2FROMMP(mp1)) { | 
|---|
|  | 153 | case LN_SETFOCUS: | 
|---|
|  | 154 | WinSetDlgItemText(hwnd, FDLG_HELP, | 
|---|
| [1498] | 155 | (CHAR *) GetPString(IDS_DBLCLKFILEUSEHELPTEXT)); | 
|---|
| [551] | 156 | break; | 
|---|
|  | 157 | case LN_KILLFOCUS: | 
|---|
| [1498] | 158 | WinSetDlgItemText(hwnd, FDLG_HELP, (CHAR *) GetPString(IDS_NAMEDEFHELPTEXT)); | 
|---|
| [551] | 159 | break; | 
|---|
|  | 160 | } | 
|---|
|  | 161 | break; | 
|---|
| [2] | 162 |  | 
|---|
| [551] | 163 | case FDLG_USERDIRS: | 
|---|
|  | 164 | switch (SHORT2FROMMP(mp1)) { | 
|---|
|  | 165 | case CBN_SHOWLIST: | 
|---|
|  | 166 | WinSetDlgItemText(hwnd, | 
|---|
| [1498] | 167 | FDLG_HELP, (CHAR *) GetPString(IDS_DBLCLKDIRSWITCHHELPTEXT)); | 
|---|
| [551] | 168 | break; | 
|---|
|  | 169 | case CBN_ENTER: | 
|---|
|  | 170 | { | 
|---|
|  | 171 | SHORT sSelect; | 
|---|
|  | 172 | CHAR szBuffer[CCHMAXPATH], szTemp[CCHMAXPATH], *p; | 
|---|
| [2] | 173 |  | 
|---|
| [551] | 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)); | 
|---|
| [1438] | 185 | if (*szBuffer) { | 
|---|
|  | 186 | AddBackslashToPath(szBuffer); | 
|---|
|  | 187 | //if (szBuffer[strlen(szBuffer) - 1] != '\\') | 
|---|
|  | 188 | //  strcat(szBuffer, "\\"); | 
|---|
| [551] | 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; | 
|---|
| [2] | 208 | } | 
|---|
|  | 209 | break; | 
|---|
| [551] | 210 | } | 
|---|
|  | 211 | break; | 
|---|
| [2] | 212 |  | 
|---|
| [551] | 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; | 
|---|
| [2] | 220 | } | 
|---|
| [551] | 221 | return WinDefFileDlgProc(hwnd, msg, mp1, mp2); | 
|---|
| [2] | 222 | } | 
|---|
|  | 223 |  | 
|---|
| [551] | 224 | BOOL insert_filename(HWND hwnd, CHAR * filename, INT loadit, BOOL newok) | 
|---|
| [451] | 225 | { | 
|---|
| [551] | 226 | FILEDLG fdlg; | 
|---|
| [847] | 227 | FILESTATUS3 fsa; | 
|---|
| [551] | 228 | CHAR drive[3], *pdrive = drive, *p; | 
|---|
|  | 229 | APIRET rc; | 
|---|
| [2] | 230 | static CHAR lastfilename[CCHMAXPATH] = ""; | 
|---|
|  | 231 |  | 
|---|
| [551] | 232 | if (!filename) | 
|---|
| [2] | 233 | return FALSE; | 
|---|
| [551] | 234 | memset(&fdlg, 0, sizeof(FILEDLG)); | 
|---|
|  | 235 | fdlg.cbSize = (ULONG) sizeof(FILEDLG); | 
|---|
|  | 236 | fdlg.fl = FDS_CENTER | FDS_OPEN_DIALOG; | 
|---|
|  | 237 | if (!loadit) { | 
|---|
| [1394] | 238 | fdlg.pszTitle = (PSZ)GetPString(IDS_ENTERFILEINSERTTEXT); | 
|---|
|  | 239 | fdlg.pszOKButton = (PSZ)GetPString(IDS_INSERTTEXT); | 
|---|
| [2] | 240 | } | 
|---|
| [551] | 241 | else if (loadit == TRUE) { | 
|---|
| [1394] | 242 | fdlg.pszTitle = (PSZ)GetPString(IDS_ENTERFILELOADTEXT); | 
|---|
|  | 243 | fdlg.pszOKButton = (PSZ)GetPString(IDS_LOADTEXT); | 
|---|
| [2] | 244 | } | 
|---|
|  | 245 | else { | 
|---|
| [1394] | 246 | fdlg.pszTitle = (PSZ)GetPString(IDS_ENTERFILETEXT); | 
|---|
|  | 247 | fdlg.pszOKButton = (PSZ)GetPString(IDS_OKAYTEXT); | 
|---|
| [2] | 248 | } | 
|---|
| [551] | 249 | if (IsFullName(filename)) { | 
|---|
| [2] | 250 | *drive = *filename; | 
|---|
|  | 251 | drive[1] = ':'; | 
|---|
|  | 252 | drive[2] = 0; | 
|---|
|  | 253 | fdlg.pszIDrive = pdrive; | 
|---|
|  | 254 | } | 
|---|
| [551] | 255 | else if (*lastfilename) { | 
|---|
| [2] | 256 | *drive = *lastfilename; | 
|---|
|  | 257 | drive[1] = ':'; | 
|---|
|  | 258 | drive[2] = 0; | 
|---|
|  | 259 | fdlg.pszIDrive = pdrive; | 
|---|
|  | 260 | } | 
|---|
|  | 261 |  | 
|---|
| [551] | 262 | if (!*filename) { | 
|---|
|  | 263 | if (*lastfilename) { | 
|---|
|  | 264 | strcpy(fdlg.szFullFile, lastfilename); | 
|---|
|  | 265 | p = strrchr(fdlg.szFullFile, '\\'); | 
|---|
|  | 266 | if (p) { | 
|---|
|  | 267 | p++; | 
|---|
|  | 268 | *p = 0; | 
|---|
| [2] | 269 | } | 
|---|
|  | 270 | } | 
|---|
| [551] | 271 | if (!loadit || loadit == TRUE) | 
|---|
| [1398] | 272 | strcat(fdlg.szFullFile, PCSZ_STARDOTTXT); | 
|---|
| [2] | 273 | else | 
|---|
| [551] | 274 | strcat(fdlg.szFullFile, "*"); | 
|---|
| [2] | 275 | } | 
|---|
|  | 276 | else | 
|---|
| [551] | 277 | strcpy(fdlg.szFullFile, filename); | 
|---|
| [2] | 278 |  | 
|---|
| [551] | 279 | if (fCustomFileDlg) { | 
|---|
| [2] | 280 | fdlg.fl |= FDS_HELPBUTTON | FDS_CUSTOM; | 
|---|
| [551] | 281 | fdlg.pfnDlgProc = (PFNWP) CustomFileDlg; | 
|---|
| [2] | 282 | fdlg.hMod = FM3ModHandle; | 
|---|
|  | 283 | fdlg.usDlgId = FDLG_FRAME; | 
|---|
|  | 284 | } | 
|---|
|  | 285 |  | 
|---|
| [551] | 286 | if (WinFileDlg(HWND_DESKTOP, hwnd, &fdlg)) { | 
|---|
|  | 287 | if (fdlg.lReturn != DID_CANCEL && !fdlg.lSRC) | 
|---|
|  | 288 | strcpy(filename, fdlg.szFullFile); | 
|---|
| [2] | 289 | else | 
|---|
|  | 290 | return FALSE; | 
|---|
|  | 291 | } | 
|---|
|  | 292 | else | 
|---|
|  | 293 | return FALSE; | 
|---|
|  | 294 | MakeFullName(filename); | 
|---|
| [847] | 295 | if (!DosQueryPathInfo(filename, FIL_STANDARD, &fsa, sizeof(fsa))) { | 
|---|
| [551] | 296 | if (fsa.attrFile & FILE_DIRECTORY) { | 
|---|
| [1673] | 297 | // device or directory | 
|---|
| [2] | 298 | saymsg(MB_CANCEL | MB_ICONEXCLAMATION, | 
|---|
| [551] | 299 | hwnd, filename, GetPString(IDS_EXISTSBUTNOTFILETEXT), filename); | 
|---|
| [2] | 300 | return FALSE; | 
|---|
|  | 301 | } | 
|---|
| [841] | 302 | else if (fsa.cbFile == 0) { | 
|---|
| [2] | 303 | saymsg(MB_CANCEL, | 
|---|
| [551] | 304 | hwnd, filename, GetPString(IDS_ISZEROLENGTHTEXT), filename); | 
|---|
| [2] | 305 | return FALSE; | 
|---|
|  | 306 | } | 
|---|
|  | 307 | } | 
|---|
| [551] | 308 | else if (!newok) { | 
|---|
| [2] | 309 | saymsg(MB_CANCEL, | 
|---|
| [551] | 310 | hwnd, filename, GetPString(IDS_DOESNTEXISTTEXT), filename); | 
|---|
| [2] | 311 | return FALSE; | 
|---|
|  | 312 | } | 
|---|
|  | 313 | else { | 
|---|
|  | 314 | rc = saymsg(MB_YESNOCANCEL, | 
|---|
| [551] | 315 | hwnd, filename, GetPString(IDS_CREATENEWTEXT)); | 
|---|
|  | 316 | if (rc != MBID_YES) | 
|---|
| [2] | 317 | return FALSE; | 
|---|
|  | 318 | } | 
|---|
| [1545] | 319 | ForwardslashToBackslash(filename); | 
|---|
| [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))) { | 
|---|
| [1673] | 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 | } | 
|---|
| [1545] | 395 | ForwardslashToBackslash(filename); | 
|---|
| [551] | 396 | if (*filename) | 
|---|
|  | 397 | strcpy(lastfilename, filename); | 
|---|
| [2] | 398 | return TRUE; | 
|---|
|  | 399 | } | 
|---|
| [793] | 400 |  | 
|---|
|  | 401 | #pragma alloc_text(GETNAMES,insert_filename,export_filename,CustomFileDlg) | 
|---|