| 1 |
|
|---|
| 2 | /***********************************************************************
|
|---|
| 3 |
|
|---|
| 4 | $Id: walkem.c 1119 2008-08-24 21:46:42Z gyoung $
|
|---|
| 5 |
|
|---|
| 6 | Misc persistent lists support
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
|---|
| 9 | Copyright (c) 2005, 2008 Steven H. Levine
|
|---|
| 10 |
|
|---|
| 11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
|---|
| 12 | 05 Jun 05 SHL Use QWL_USER
|
|---|
| 13 | 13 Aug 05 SHL Run through indent
|
|---|
| 14 | 13 Aug 05 SHL remove_udir - avoid corrupting last dirs list
|
|---|
| 15 | 17 Jul 06 SHL Use Runtime_Error
|
|---|
| 16 | 29 Jul 06 SHL Use xfgets
|
|---|
| 17 | 20 Oct 06 SHL Correct . .. check
|
|---|
| 18 | 06 Nov 06 SHL Oops - need to allow .. here
|
|---|
| 19 | 14 Nov 06 SHL Correct FillPathListBox regression
|
|---|
| 20 | 22 Mar 07 GKY Use QWL_USER
|
|---|
| 21 | 20 Apr 07 SHL Avoid spurious add_udir error reports
|
|---|
| 22 | 16 Aug 07 SHL Update add_setups for ticket# 109
|
|---|
| 23 | 19 Aug 07 SHL Correct load_setups error reporting
|
|---|
| 24 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
|---|
| 25 | 25 Aug 07 SHL Correct #pragma alloc_text typos
|
|---|
| 26 | 11 Nov 07 GKY Cancel now directly closes dialog even if directory path text has changed
|
|---|
| 27 | 20 Jan 08 GKY Walk & walk2 dialogs now save and restore size and position
|
|---|
| 28 | 19 Feb 08 JBS Add "State at last FM/2 close" to the states combo box
|
|---|
| 29 | 29 Feb 08 GKY Use xfree where appropriate
|
|---|
| 30 | 29 Feb 08 GKY Refactor global command line variables to notebook.h
|
|---|
| 31 | 19 Jun 08 JBS Ticket 227: Allow temporary saving/deleting of the shutdown state of directory containers
|
|---|
| 32 | 22 Jun 08 GKY Add free_?dir for fortify testing
|
|---|
| 33 | 18 Jul 08 SHL More Fortify support
|
|---|
| 34 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory and use BldFullPathName
|
|---|
| 35 | 24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
|
|---|
| 36 |
|
|---|
| 37 | ***********************************************************************/
|
|---|
| 38 |
|
|---|
| 39 | #include <stdlib.h>
|
|---|
| 40 | #include <string.h>
|
|---|
| 41 | #include <ctype.h>
|
|---|
| 42 | #include <share.h>
|
|---|
| 43 |
|
|---|
| 44 | #define INCL_WIN
|
|---|
| 45 | #define INCL_DOS
|
|---|
| 46 | #define INCL_DOSERRORS
|
|---|
| 47 | #define INCL_SHLERRORS // PMERR_NOT_IN_IDX
|
|---|
| 48 | #define INCL_LONGLONG
|
|---|
| 49 |
|
|---|
| 50 | #include "fm3dlg.h"
|
|---|
| 51 | #include "fm3str.h"
|
|---|
| 52 | #include "errutil.h" // Dos_Error...
|
|---|
| 53 | #include "strutil.h" // GetPString
|
|---|
| 54 | #include "notebook.h" // targetdirectory
|
|---|
| 55 | #include "pathutil.h" // BldFullPathName
|
|---|
| 56 | #include "fm3dll.h"
|
|---|
| 57 | #include "fortify.h"
|
|---|
| 58 | #include "walkem.h"
|
|---|
| 59 |
|
|---|
| 60 | #pragma data_seg(DATA1)
|
|---|
| 61 |
|
|---|
| 62 | static PSZ pszSrcFile = __FILE__;
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 | typedef struct
|
|---|
| 66 | {
|
|---|
| 67 | USHORT size;
|
|---|
| 68 | USHORT changed;
|
|---|
| 69 | BOOL nounwriteable;
|
|---|
| 70 | CHAR szCurrentPath[CCHMAXPATH];
|
|---|
| 71 | CHAR *szReturnPath;
|
|---|
| 72 | }
|
|---|
| 73 | WALKER;
|
|---|
| 74 |
|
|---|
| 75 | static CHAR WalkFont[CCHMAXPATH] = "";
|
|---|
| 76 | static ULONG WalkFontSize = sizeof(WalkFont);
|
|---|
| 77 |
|
|---|
| 78 | /**
|
|---|
| 79 | * States names management
|
|---|
| 80 | */
|
|---|
| 81 |
|
|---|
| 82 | static BOOL fSetupsLoaded;
|
|---|
| 83 | static LINKDIRS *pFirstSetup;
|
|---|
| 84 | static const PSZ pszLastSetups = "LastSetups";
|
|---|
| 85 | // 18 Aug 07 SHL fixme to stop supporting old style 1 year from now?
|
|---|
| 86 | static const ULONG ulOldSetupsBytes = 100 * 13; // Prior to 3.0.7
|
|---|
| 87 |
|
|---|
| 88 | /**
|
|---|
| 89 | * Fill States drop down list with known state names
|
|---|
| 90 | */
|
|---|
| 91 |
|
|---|
| 92 | VOID fill_setups_list(VOID)
|
|---|
| 93 | {
|
|---|
| 94 | WinSendMsg(hwndStatelist, LM_DELETEALL, MPVOID, MPVOID);
|
|---|
| 95 | if (fUserComboBox) {
|
|---|
| 96 | LINKDIRS *pld;
|
|---|
| 97 | load_setups();
|
|---|
| 98 | for (pld = pFirstSetup; pld; pld = pld->next) {
|
|---|
| 99 | // DbgMsg(pszSrcFile, __LINE__, "Inserted %s", pld->path);
|
|---|
| 100 | WinSendMsg(hwndStatelist,
|
|---|
| 101 | LM_INSERTITEM,
|
|---|
| 102 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
|---|
| 103 | MPFROMP(pld->path));
|
|---|
| 104 | }
|
|---|
| 105 | WinSetWindowText(hwndStatelist, GetPString(IDS_STATETEXT));
|
|---|
| 106 | }
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | /**
|
|---|
| 110 | * Lookup setup and do requested action
|
|---|
| 111 | * @param - action, Support old/new style storage method
|
|---|
| 112 | * @return 1 if found and action OK, 0 if not found and action OK, -1 if error during action
|
|---|
| 113 | */
|
|---|
| 114 |
|
|---|
| 115 | #define LS_FIND 0
|
|---|
| 116 | #define LS_ADD 1
|
|---|
| 117 | #define LS_DELETE 2
|
|---|
| 118 |
|
|---|
| 119 | static INT lookup_setup(PSZ name, UINT action)
|
|---|
| 120 | {
|
|---|
| 121 | LINKDIRS *pld;
|
|---|
| 122 | LINKDIRS *pldLast = NULL;
|
|---|
| 123 |
|
|---|
| 124 | if (!name || !*name) {
|
|---|
| 125 | Runtime_Error(pszSrcFile, __LINE__, "no data");
|
|---|
| 126 | return -1;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | load_setups();
|
|---|
| 130 |
|
|---|
| 131 | for (pld = pFirstSetup; pld; pld = pld->next) {
|
|---|
| 132 | if (!stricmp(pld->path, name)) {
|
|---|
| 133 | if (action == LS_DELETE) {
|
|---|
| 134 | if (pldLast)
|
|---|
| 135 | pldLast->next = pld->next;
|
|---|
| 136 | else
|
|---|
| 137 | pFirstSetup = pld->next;
|
|---|
| 138 | xfree(pld->path, pszSrcFile, __LINE__);
|
|---|
| 139 | free(pld);
|
|---|
| 140 | }
|
|---|
| 141 | return 1; // Found or added
|
|---|
| 142 | }
|
|---|
| 143 | pldLast = pld; // In case deleting
|
|---|
| 144 | } // for
|
|---|
| 145 |
|
|---|
| 146 | // Not found
|
|---|
| 147 | if (action == LS_ADD) {
|
|---|
| 148 | pld = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
|---|
| 149 | if (!pld)
|
|---|
| 150 | return -1;
|
|---|
| 151 | pld->path = xstrdup(name, pszSrcFile, __LINE__);
|
|---|
| 152 | if (!pld->path) {
|
|---|
| 153 | free(pld);
|
|---|
| 154 | return -1;
|
|---|
| 155 | }
|
|---|
| 156 | // Insert at front of list - drop down will sort
|
|---|
| 157 | pld->next = pFirstSetup;
|
|---|
| 158 | pFirstSetup = pld;
|
|---|
| 159 | return 0;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | return FALSE; // Not found
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | /**
|
|---|
| 166 | * Load state names from ini
|
|---|
| 167 | * Support old/new style storage method
|
|---|
| 168 | */
|
|---|
| 169 |
|
|---|
| 170 | VOID load_setups(VOID)
|
|---|
| 171 | {
|
|---|
| 172 | ULONG ulDataBytes;
|
|---|
| 173 | ULONG l;
|
|---|
| 174 | PSZ pszBuf;
|
|---|
| 175 | PSZ psz;
|
|---|
| 176 | LINKDIRS *pld;
|
|---|
| 177 |
|
|---|
| 178 | if (fSetupsLoaded)
|
|---|
| 179 | return;
|
|---|
| 180 |
|
|---|
| 181 | if (!PrfQueryProfileSize(fmprof, FM3Str, pszLastSetups, &ulDataBytes)) {
|
|---|
| 182 | // fixme to use generic hab
|
|---|
| 183 | ERRORID eid = WinGetLastError((HAB)0);
|
|---|
| 184 | if ((eid & 0xffff) != PMERR_NOT_IN_IDX) {
|
|---|
| 185 | // Get error info back
|
|---|
| 186 | PrfQueryProfileSize(fmprof, FM3Str, pszLastSetups, &ulDataBytes);
|
|---|
| 187 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, "PrfQueryProfileSize");
|
|---|
| 188 | }
|
|---|
| 189 | else
|
|---|
| 190 | fSetupsLoaded = TRUE; // Nothing saved
|
|---|
| 191 | return;
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | if (ulDataBytes == 0) {
|
|---|
| 195 | Runtime_Error(pszSrcFile, __LINE__, "PrfQueryProfileSize reported 0 bytes");
|
|---|
| 196 | return;
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | pszBuf = xmalloc(ulDataBytes + 1, pszSrcFile, __LINE__); // One extra for end marker
|
|---|
| 200 | if (!pszBuf)
|
|---|
| 201 | return;
|
|---|
| 202 | l = ulDataBytes;
|
|---|
| 203 | if (!PrfQueryProfileData(fmprof, FM3Str, pszLastSetups, pszBuf, &l)) {
|
|---|
| 204 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, "PrfQueryProfileData");
|
|---|
| 205 | free(pszBuf);
|
|---|
| 206 | return;
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | if (ulDataBytes != l) {
|
|---|
| 210 | Runtime_Error(pszSrcFile, __LINE__, "PrfQueryProfileData reported %u expected %u", l, ulDataBytes);
|
|---|
| 211 | free(pszBuf);
|
|---|
| 212 | return;
|
|---|
| 213 | }
|
|---|
| 214 |
|
|---|
| 215 | *(pszBuf + ulDataBytes) = 0; // Insert end marker
|
|---|
| 216 |
|
|---|
| 217 | psz = pszBuf;
|
|---|
| 218 | if (!*psz && ulDataBytes == ulOldSetupsBytes)
|
|---|
| 219 | psz += 13; // Rarely used 1st fixed width entry prior to 3.0.7
|
|---|
| 220 |
|
|---|
| 221 | while (*psz) {
|
|---|
| 222 | pld = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
|---|
| 223 | if (!pld) {
|
|---|
| 224 | free(pszBuf);
|
|---|
| 225 | return;
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | # ifdef FORTIFY
|
|---|
| 229 | Fortify_SetOwner(pld, 1);
|
|---|
| 230 | Fortify_SetScope(pld, 1);
|
|---|
| 231 | # endif
|
|---|
| 232 |
|
|---|
| 233 | pld->path = xstrdup(psz, pszSrcFile, __LINE__);
|
|---|
| 234 | if (!pld->path) {
|
|---|
| 235 | free(pszBuf);
|
|---|
| 236 | free(pld);
|
|---|
| 237 | return;
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | # ifdef FORTIFY
|
|---|
| 241 | Fortify_SetOwner(pld->path, 1);
|
|---|
| 242 | Fortify_SetScope(pld->path, 1);
|
|---|
| 243 | # endif
|
|---|
| 244 |
|
|---|
| 245 | // Insert at front of list - drop down will sort
|
|---|
| 246 | pld->next = pFirstSetup;
|
|---|
| 247 | pFirstSetup = pld;
|
|---|
| 248 | // DbgMsg(pszSrcFile, __LINE__, "Inserted %s", pld->path);
|
|---|
| 249 |
|
|---|
| 250 | if (ulDataBytes == ulOldSetupsBytes)
|
|---|
| 251 | psz += 13; // Buffers fixed width prior to 3.0.7
|
|---|
| 252 | else
|
|---|
| 253 | psz += strlen(psz) + 1;
|
|---|
| 254 | } // while
|
|---|
| 255 |
|
|---|
| 256 | free(pszBuf);
|
|---|
| 257 |
|
|---|
| 258 | fSetupsLoaded = TRUE;
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 | VOID save_setups(VOID)
|
|---|
| 262 | {
|
|---|
| 263 | ULONG ulBufBytes;
|
|---|
| 264 | ULONG ulFillBytes;
|
|---|
| 265 | ULONG l;
|
|---|
| 266 | PSZ pszBuf;
|
|---|
| 267 | PSZ psz;
|
|---|
| 268 | LINKDIRS *pld;
|
|---|
| 269 |
|
|---|
| 270 | if (!fSetupsLoaded)
|
|---|
| 271 | return;
|
|---|
| 272 |
|
|---|
| 273 | ulBufBytes = 0;
|
|---|
| 274 | for (pld = pFirstSetup; pld; pld = pld->next) {
|
|---|
| 275 | ulBufBytes += strlen(pld->path) + 1;
|
|---|
| 276 | } // for
|
|---|
| 277 |
|
|---|
| 278 | if (!ulBufBytes)
|
|---|
| 279 | pszBuf = NULL;
|
|---|
| 280 | else {
|
|---|
| 281 | // Ensure different than size prior to 3.0.7
|
|---|
| 282 | ulFillBytes = ulBufBytes == ulOldSetupsBytes ? 1 : 0;
|
|---|
| 283 | pszBuf = xmalloc(ulBufBytes + ulFillBytes, pszSrcFile, __LINE__);
|
|---|
| 284 | if (!pszBuf)
|
|---|
| 285 | return;
|
|---|
| 286 |
|
|---|
| 287 | psz = pszBuf;
|
|---|
| 288 | for (pld = pFirstSetup; pld; pld = pld->next) {
|
|---|
| 289 | l = strlen(pld->path) + 1;
|
|---|
| 290 | memcpy(psz, pld->path, l);
|
|---|
| 291 | psz += l;
|
|---|
| 292 | } // for
|
|---|
| 293 | if (ulFillBytes)
|
|---|
| 294 | *psz = 0;
|
|---|
| 295 | }
|
|---|
| 296 |
|
|---|
| 297 | if (!PrfWriteProfileData(fmprof,
|
|---|
| 298 | FM3Str,
|
|---|
| 299 | pszLastSetups, pszBuf, ulBufBytes)) {
|
|---|
| 300 | // Win_Error(pszSrcFile, __LINE__, HWND_DESKTOP, HWND_DESKTOP, "PrfWriteProfileData");
|
|---|
| 301 | ERRORID eid = WinGetLastError((HAB)0);
|
|---|
| 302 | if ((eid & 0xffff) != PMERR_NOT_IN_IDX)
|
|---|
| 303 | Runtime_Error(pszSrcFile, __LINE__, "PrfWriteProfileData returned %u", eid);
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | // Delete obsolete INI entry
|
|---|
| 307 | PrfWriteProfileData(fmprof, FM3Str, "LastSetup", NULL, 0);
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | /**
|
|---|
| 311 | * Add named state to setups list
|
|---|
| 312 | * @return same as lookup_setup
|
|---|
| 313 | */
|
|---|
| 314 |
|
|---|
| 315 | INT add_setup(PSZ name)
|
|---|
| 316 | {
|
|---|
| 317 | return lookup_setup(name, LS_ADD);
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 | /**
|
|---|
| 321 | * Delete named state from setups list
|
|---|
| 322 | * @return same as lookup_setup
|
|---|
| 323 | */
|
|---|
| 324 |
|
|---|
| 325 | INT remove_setup(PSZ name)
|
|---|
| 326 | {
|
|---|
| 327 | return lookup_setup(name, LS_DELETE);
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | #ifdef FORTIFY
|
|---|
| 331 |
|
|---|
| 332 | VOID free_setups(VOID)
|
|---|
| 333 | {
|
|---|
| 334 | LINKDIRS *pld = pFirstSetup;
|
|---|
| 335 | while (pld) {
|
|---|
| 336 | LINKDIRS *next = pld->next;
|
|---|
| 337 | free(pld->path);
|
|---|
| 338 | free(pld);
|
|---|
| 339 | pld = next;
|
|---|
| 340 | }
|
|---|
| 341 | pFirstSetup = NULL;
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | #endif // FORTIFY
|
|---|
| 345 |
|
|---|
| 346 | VOID load_udirs(VOID)
|
|---|
| 347 | {
|
|---|
| 348 | /* load linked list of user directories from USERDIRS.DAT file */
|
|---|
| 349 |
|
|---|
| 350 | FILE *fp;
|
|---|
| 351 | LINKDIRS *info;
|
|---|
| 352 | LINKDIRS *last = NULL;
|
|---|
| 353 | CHAR s[CCHMAXPATH + 24];
|
|---|
| 354 |
|
|---|
| 355 | if (udirhead)
|
|---|
| 356 | free_udirs();
|
|---|
| 357 | loadedudirs = TRUE;
|
|---|
| 358 | fUdirsChanged = FALSE;
|
|---|
| 359 | BldFullPathName(s, pFM2SaveDirectory, "USERDIRS.DAT");
|
|---|
| 360 | fp = _fsopen(s, "r", SH_DENYWR);
|
|---|
| 361 | if (fp) {
|
|---|
| 362 | while (!feof(fp)) {
|
|---|
| 363 | if (!xfgets(s, CCHMAXPATH + 24, fp, pszSrcFile, __LINE__))
|
|---|
| 364 | break;
|
|---|
| 365 | s[CCHMAXPATH] = 0;
|
|---|
| 366 | bstripcr(s);
|
|---|
| 367 | if (*s && *s != ';') {
|
|---|
| 368 | info = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
|---|
| 369 | # ifdef FORTIFY
|
|---|
| 370 | Fortify_SetOwner(info, 1);
|
|---|
| 371 | Fortify_SetScope(info, 1);
|
|---|
| 372 | # endif
|
|---|
| 373 | if (info) {
|
|---|
| 374 | info->path = xstrdup(s, pszSrcFile, __LINE__);
|
|---|
| 375 | if (!info->path)
|
|---|
| 376 | free(info);
|
|---|
| 377 | else {
|
|---|
| 378 | # ifdef FORTIFY
|
|---|
| 379 | Fortify_SetOwner(info->path, 1);
|
|---|
| 380 | Fortify_SetScope(info->path, 1);
|
|---|
| 381 | # endif
|
|---|
| 382 | info->next = NULL;
|
|---|
| 383 | if (!udirhead)
|
|---|
| 384 | udirhead = info;
|
|---|
| 385 | else
|
|---|
| 386 | last->next = info;
|
|---|
| 387 | last = info;
|
|---|
| 388 | }
|
|---|
| 389 | }
|
|---|
| 390 | }
|
|---|
| 391 | }
|
|---|
| 392 | fclose(fp);
|
|---|
| 393 | }
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | VOID save_udirs(VOID)
|
|---|
| 397 | {
|
|---|
| 398 | FILE *fp;
|
|---|
| 399 | LINKDIRS *info;
|
|---|
| 400 | CHAR s[CCHMAXPATH + 14];
|
|---|
| 401 |
|
|---|
| 402 | if (loadedudirs) {
|
|---|
| 403 | fUdirsChanged = FALSE;
|
|---|
| 404 | if (udirhead) {
|
|---|
| 405 | BldFullPathName(s, pFM2SaveDirectory, "USERDIRS.DAT");
|
|---|
| 406 | if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2)
|
|---|
| 407 | return; //already gave error msg
|
|---|
| 408 | fp = xfopen(s, "w", pszSrcFile, __LINE__);
|
|---|
| 409 | if (fp) {
|
|---|
| 410 | fputs(GetPString(IDS_USERDEFDIRSTEXT), fp);
|
|---|
| 411 | info = udirhead;
|
|---|
| 412 | while (info) {
|
|---|
| 413 | fprintf(fp, "%0.*s\n", CCHMAXPATH, info->path);
|
|---|
| 414 | info = info->next;
|
|---|
| 415 | }
|
|---|
| 416 | fclose(fp);
|
|---|
| 417 | }
|
|---|
| 418 | }
|
|---|
| 419 | }
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | /**
|
|---|
| 423 | * Add path to user directory list or last used directory list.
|
|---|
| 424 | * Callers need to check fUdirsChanged to know if user dirs change occured.
|
|---|
| 425 | * Callers need to check return code to know if last dirs change occured.
|
|---|
| 426 | * @param userdirs TRUE to process user directory list. Otherwise last used list.
|
|---|
| 427 | * @return TRUE if added, FALSE if already in list or error.
|
|---|
| 428 | */
|
|---|
| 429 |
|
|---|
| 430 | BOOL add_udir(BOOL userdirs, CHAR *inpath)
|
|---|
| 431 | {
|
|---|
| 432 | CHAR path[CCHMAXPATH];
|
|---|
| 433 | LINKDIRS *info;
|
|---|
| 434 | LINKDIRS *last = NULL;
|
|---|
| 435 | LINKDIRS *temp;
|
|---|
| 436 |
|
|---|
| 437 | if (inpath && *inpath) {
|
|---|
| 438 | if (DosQueryPathInfo(inpath, FIL_QUERYFULLNAME, path, sizeof(path)))
|
|---|
| 439 | strcpy(path, inpath);
|
|---|
| 440 | if (!userdirs && IsRoot(path))
|
|---|
| 441 | return FALSE;
|
|---|
| 442 | if (IsFullName(path)) {
|
|---|
| 443 | if (!loadedudirs)
|
|---|
| 444 | load_udirs();
|
|---|
| 445 | // Search user dir list first unless doing last dirs
|
|---|
| 446 | info = userdirs ? udirhead : ldirhead;
|
|---|
| 447 | while (info) {
|
|---|
| 448 | if (!stricmp(info->path, path))
|
|---|
| 449 | return FALSE; // Already in list
|
|---|
| 450 | last = info; // Remember append to location
|
|---|
| 451 | info = info->next;
|
|---|
| 452 | }
|
|---|
| 453 | // Search last dir list unless doing just last dirs
|
|---|
| 454 | if (!userdirs) {
|
|---|
| 455 | info = udirhead;
|
|---|
| 456 | while (info) {
|
|---|
| 457 | if (!stricmp(info->path, path))
|
|---|
| 458 | return FALSE;
|
|---|
| 459 | info = info->next;
|
|---|
| 460 | }
|
|---|
| 461 | }
|
|---|
| 462 | else {
|
|---|
| 463 | /* if adding manual directory, remove from auto list if present */
|
|---|
| 464 | info = ldirhead;
|
|---|
| 465 | temp = NULL;
|
|---|
| 466 | while (info) {
|
|---|
| 467 | if (!stricmp(info->path, path)) {
|
|---|
| 468 | if (temp)
|
|---|
| 469 | temp->next = info->next;
|
|---|
| 470 | else
|
|---|
| 471 | ldirhead = info->next;
|
|---|
| 472 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 473 | free(info);
|
|---|
| 474 | break;
|
|---|
| 475 | }
|
|---|
| 476 | temp = info;
|
|---|
| 477 | info = info->next;
|
|---|
| 478 | }
|
|---|
| 479 | }
|
|---|
| 480 | // Append entry to end of user dirs list
|
|---|
| 481 | info = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
|---|
| 482 | if (info) {
|
|---|
| 483 | # ifdef FORTIFY
|
|---|
| 484 | Fortify_SetScope(info, 1);
|
|---|
| 485 | # endif
|
|---|
| 486 | info->path = xstrdup(path, pszSrcFile, __LINE__);
|
|---|
| 487 | if (!info->path)
|
|---|
| 488 | free(info);
|
|---|
| 489 | else {
|
|---|
| 490 | # ifdef FORTIFY
|
|---|
| 491 | Fortify_SetScope(info->path, 1);
|
|---|
| 492 | # endif
|
|---|
| 493 | info->next = NULL;
|
|---|
| 494 | if (userdirs) {
|
|---|
| 495 | fUdirsChanged = TRUE;
|
|---|
| 496 | if (!udirhead)
|
|---|
| 497 | udirhead = info;
|
|---|
| 498 | else
|
|---|
| 499 | last->next = info;
|
|---|
| 500 | }
|
|---|
| 501 | else {
|
|---|
| 502 | if (!ldirhead)
|
|---|
| 503 | ldirhead = info;
|
|---|
| 504 | else
|
|---|
| 505 | last->next = info;
|
|---|
| 506 | }
|
|---|
| 507 | return TRUE;
|
|---|
| 508 | }
|
|---|
| 509 | }
|
|---|
| 510 | }
|
|---|
| 511 | }
|
|---|
| 512 | return FALSE;
|
|---|
| 513 | }
|
|---|
| 514 |
|
|---|
| 515 | //=== remove_udir - remove path from user dir list or last directory list ===
|
|---|
| 516 |
|
|---|
| 517 | BOOL remove_udir(CHAR * path)
|
|---|
| 518 | {
|
|---|
| 519 | LINKDIRS *info;
|
|---|
| 520 | LINKDIRS *last = NULL;
|
|---|
| 521 |
|
|---|
| 522 | if (path && *path) {
|
|---|
| 523 | if (!loadedudirs)
|
|---|
| 524 | load_udirs();
|
|---|
| 525 | info = udirhead;
|
|---|
| 526 | while (info) {
|
|---|
| 527 | if (!stricmp(info->path, path)) {
|
|---|
| 528 | if (last)
|
|---|
| 529 | last->next = info->next;
|
|---|
| 530 | else
|
|---|
| 531 | udirhead = info->next;
|
|---|
| 532 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 533 | free(info);
|
|---|
| 534 | fUdirsChanged = TRUE;
|
|---|
| 535 | return TRUE;
|
|---|
| 536 | }
|
|---|
| 537 | last = info;
|
|---|
| 538 | info = info->next;
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | info = ldirhead;
|
|---|
| 542 | last = NULL;
|
|---|
| 543 | while (info) {
|
|---|
| 544 | if (!stricmp(info->path, path)) {
|
|---|
| 545 | if (last)
|
|---|
| 546 | last->next = info->next;
|
|---|
| 547 | else
|
|---|
| 548 | ldirhead = info->next;
|
|---|
| 549 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 550 | free(info);
|
|---|
| 551 | return TRUE;
|
|---|
| 552 | }
|
|---|
| 553 | last = info;
|
|---|
| 554 | info = info->next;
|
|---|
| 555 | }
|
|---|
| 556 | }
|
|---|
| 557 | return FALSE;
|
|---|
| 558 | }
|
|---|
| 559 |
|
|---|
| 560 | BOOL remove_ldir(CHAR * path)
|
|---|
| 561 | {
|
|---|
| 562 | LINKDIRS *info;
|
|---|
| 563 | LINKDIRS *last = NULL;
|
|---|
| 564 |
|
|---|
| 565 | if (path && *path) {
|
|---|
| 566 | info = ldirhead;
|
|---|
| 567 | while (info) {
|
|---|
| 568 | if (!stricmp(info->path, path)) {
|
|---|
| 569 | if (last)
|
|---|
| 570 | last->next = info->next;
|
|---|
| 571 | else
|
|---|
| 572 | ldirhead = info->next;
|
|---|
| 573 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 574 | free(info);
|
|---|
| 575 | return TRUE;
|
|---|
| 576 | }
|
|---|
| 577 | last = info;
|
|---|
| 578 | info = info->next;
|
|---|
| 579 | }
|
|---|
| 580 | }
|
|---|
| 581 | return FALSE;
|
|---|
| 582 | }
|
|---|
| 583 |
|
|---|
| 584 | # ifdef FORTIFY
|
|---|
| 585 |
|
|---|
| 586 | VOID free_ldir(VOID)
|
|---|
| 587 | {
|
|---|
| 588 | LINKDIRS *info, *next;
|
|---|
| 589 |
|
|---|
| 590 | info = ldirhead;
|
|---|
| 591 | while (info) {
|
|---|
| 592 | next = info->next;
|
|---|
| 593 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 594 | free(info);
|
|---|
| 595 | info = next;
|
|---|
| 596 | }
|
|---|
| 597 | ldirhead = NULL;
|
|---|
| 598 | }
|
|---|
| 599 |
|
|---|
| 600 | # endif
|
|---|
| 601 |
|
|---|
| 602 | VOID free_udirs(VOID)
|
|---|
| 603 | {
|
|---|
| 604 | LINKDIRS *info, *next;
|
|---|
| 605 |
|
|---|
| 606 | info = udirhead;
|
|---|
| 607 | while (info) {
|
|---|
| 608 | next = info->next;
|
|---|
| 609 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 610 | free(info);
|
|---|
| 611 | info = next;
|
|---|
| 612 | }
|
|---|
| 613 | udirhead = NULL;
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 | VOID FillPathListBox(HWND hwnd, HWND hwnddrive, HWND hwnddir, CHAR * pszPath,
|
|---|
| 617 | BOOL nounwriteable)
|
|---|
| 618 | {
|
|---|
| 619 | /*
|
|---|
| 620 | * this function fills one or two list boxes with drive and directory
|
|---|
| 621 | * information showing all available drives and all directories off of
|
|---|
| 622 | * the directory represented by path. This works independently of the
|
|---|
| 623 | * current directory.
|
|---|
| 624 | */
|
|---|
| 625 |
|
|---|
| 626 | CHAR szDrive[] = " :", szTemp[1032];
|
|---|
| 627 | FILEFINDBUF3 findbuf;
|
|---|
| 628 | HDIR hDir = HDIR_CREATE;
|
|---|
| 629 | SHORT sDrive;
|
|---|
| 630 | ULONG ulDriveNum, ulSearchCount = 1, ulDriveMap;
|
|---|
| 631 |
|
|---|
| 632 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 633 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
|---|
| 634 | if (hwnddrive)
|
|---|
| 635 | WinSendMsg(hwnddrive, LM_DELETEALL, MPVOID, MPVOID);
|
|---|
| 636 | if (hwnddrive != hwnddir && hwnddir)
|
|---|
| 637 | WinSendMsg(hwnddir, LM_DELETEALL, MPVOID, MPVOID);
|
|---|
| 638 |
|
|---|
| 639 | if (hwnddrive) {
|
|---|
| 640 | // Fill drive listbox
|
|---|
| 641 | for (sDrive = 0; sDrive < 26; sDrive++) {
|
|---|
| 642 | if (ulDriveMap & (1 << sDrive)) {
|
|---|
| 643 | *szDrive = (CHAR) (sDrive + 'A');
|
|---|
| 644 | if ((!nounwriteable || !(driveflags[sDrive] & DRIVE_NOTWRITEABLE)) &&
|
|---|
| 645 | !(driveflags[sDrive] & (DRIVE_IGNORE | DRIVE_INVALID)))
|
|---|
| 646 | WinSendMsg(hwnddrive, LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
|
|---|
| 647 | MPFROMP(szDrive));
|
|---|
| 648 | }
|
|---|
| 649 | }
|
|---|
| 650 | if (hwnddrive != hwnddir && pszPath && isalpha(*pszPath)
|
|---|
| 651 | && pszPath[1] == ':') {
|
|---|
| 652 | *szDrive = toupper(*pszPath);
|
|---|
| 653 | WinSetWindowText(hwnddrive, szDrive);
|
|---|
| 654 | }
|
|---|
| 655 | }
|
|---|
| 656 |
|
|---|
| 657 | if (hwnddir) {
|
|---|
| 658 | // Fill directory listbox
|
|---|
| 659 | sprintf(szTemp,
|
|---|
| 660 | "%s%s*",
|
|---|
| 661 | pszPath, (pszPath[strlen(pszPath) - 1] == '\\') ? "" : "\\");
|
|---|
| 662 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 663 | if (!DosFindFirst(szTemp,
|
|---|
| 664 | &hDir,
|
|---|
| 665 | FILE_DIRECTORY | MUST_HAVE_DIRECTORY |
|
|---|
| 666 | FILE_READONLY | FILE_ARCHIVED | FILE_SYSTEM |
|
|---|
| 667 | FILE_HIDDEN,
|
|---|
| 668 | &findbuf,
|
|---|
| 669 | sizeof(FILEFINDBUF3), &ulSearchCount, FIL_STANDARD)) {
|
|---|
| 670 | do {
|
|---|
| 671 | if (findbuf.attrFile & FILE_DIRECTORY) {
|
|---|
| 672 | // Skip .. unless full path supplied
|
|---|
| 673 | if (strcmp(findbuf.achName, "..") ||
|
|---|
| 674 | strlen(pszPath) > 3 || pszPath[1] != ':') {
|
|---|
| 675 | // Skip . allow ..
|
|---|
| 676 | if (findbuf.achName[0] != '.' || findbuf.achName[1]) {
|
|---|
| 677 | WinSendMsg(hwnddir,
|
|---|
| 678 | LM_INSERTITEM,
|
|---|
| 679 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
|---|
| 680 | MPFROMP(findbuf.achName));
|
|---|
| 681 | }
|
|---|
| 682 | }
|
|---|
| 683 | }
|
|---|
| 684 | ulSearchCount = 1;
|
|---|
| 685 | } while (!DosFindNext(hDir,
|
|---|
| 686 | &findbuf, sizeof(FILEFINDBUF3), &ulSearchCount));
|
|---|
| 687 | DosFindClose(hDir);
|
|---|
| 688 | }
|
|---|
| 689 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 690 | }
|
|---|
| 691 | }
|
|---|
| 692 |
|
|---|
| 693 | MRESULT EXPENTRY TextSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 694 | {
|
|---|
| 695 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 696 |
|
|---|
| 697 | switch (msg) {
|
|---|
| 698 | case WM_CHAR:
|
|---|
| 699 | if (SHORT1FROMMP(mp1) & KC_KEYUP) {
|
|---|
| 700 | if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
|
|---|
| 701 | (SHORT1FROMMP(mp2) & 255) == '\r')
|
|---|
| 702 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND,
|
|---|
| 703 | MPFROM2SHORT(DID_OK, 0), MPVOID);
|
|---|
| 704 | }
|
|---|
| 705 | break;
|
|---|
| 706 | }
|
|---|
| 707 | return oldproc(hwnd, msg, mp1, mp2);
|
|---|
| 708 | }
|
|---|
| 709 |
|
|---|
| 710 | MRESULT EXPENTRY WalkDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 711 | {
|
|---|
| 712 | WALKER *wa;
|
|---|
| 713 | CHAR szBuff[CCHMAXPATH + 1], szBuffer[CCHMAXPATH + 1], *p;
|
|---|
| 714 | SHORT sSelect;
|
|---|
| 715 | static BOOL okay; /* avoid combobox selecting as filled */
|
|---|
| 716 | static CHAR lastdir[CCHMAXPATH + 1];
|
|---|
| 717 |
|
|---|
| 718 | switch (msg) {
|
|---|
| 719 | case UM_SETUP2:
|
|---|
| 720 | case WM_INITDLG:
|
|---|
| 721 | okay = FALSE;
|
|---|
| 722 | *lastdir = 0;
|
|---|
| 723 | if (!mp2) {
|
|---|
| 724 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
|---|
| 725 | WinDismissDlg(hwnd, 0);
|
|---|
| 726 | break;
|
|---|
| 727 | }
|
|---|
| 728 | wa = xmallocz(sizeof(WALKER), pszSrcFile, __LINE__);
|
|---|
| 729 | if (!wa) {
|
|---|
| 730 | WinDismissDlg(hwnd, 0);
|
|---|
| 731 | break;
|
|---|
| 732 | }
|
|---|
| 733 | wa->size = (USHORT) sizeof(WALKER);
|
|---|
| 734 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) wa);
|
|---|
| 735 | wa->szReturnPath = (CHAR *)mp2;
|
|---|
| 736 | {
|
|---|
| 737 | PFNWP oldproc;
|
|---|
| 738 |
|
|---|
| 739 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK_PATH),
|
|---|
| 740 | (PFNWP) TextSubProc);
|
|---|
| 741 | if (oldproc)
|
|---|
| 742 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK_PATH),
|
|---|
| 743 | QWL_USER, (PVOID) oldproc);
|
|---|
| 744 | WinSendDlgItemMsg(WinWindowFromID(hwnd, WALK_RECENT),
|
|---|
| 745 | CBID_EDIT,
|
|---|
| 746 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
|---|
| 747 | WinSendDlgItemMsg(WinWindowFromID(hwnd, WALK_RECENT),
|
|---|
| 748 | CBID_EDIT,
|
|---|
| 749 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
|
|---|
| 750 | }
|
|---|
| 751 | {
|
|---|
| 752 | SWP swp;
|
|---|
| 753 | ULONG size = sizeof(SWP);
|
|---|
| 754 |
|
|---|
| 755 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp, &size);
|
|---|
| 756 | WinSetWindowPos(hwnd,
|
|---|
| 757 | HWND_TOP,
|
|---|
| 758 | swp.x,
|
|---|
| 759 | swp.y,
|
|---|
| 760 | swp.cx,
|
|---|
| 761 | swp.cy,
|
|---|
| 762 | swp.fl);
|
|---|
| 763 | }
|
|---|
| 764 | PosOverOkay(hwnd);
|
|---|
| 765 | if (msg == UM_SETUP2)
|
|---|
| 766 | wa->nounwriteable = FALSE;
|
|---|
| 767 | else
|
|---|
| 768 | wa->nounwriteable = TRUE;
|
|---|
| 769 | if (!*wa->szReturnPath)
|
|---|
| 770 | strcpy(wa->szCurrentPath, pFM2SaveDirectory);
|
|---|
| 771 | else {
|
|---|
| 772 | strcpy(wa->szCurrentPath, wa->szReturnPath);
|
|---|
| 773 | MakeFullName(wa->szCurrentPath);
|
|---|
| 774 | }
|
|---|
| 775 | if (wa->nounwriteable &&
|
|---|
| 776 | (driveflags[toupper(*wa->szCurrentPath) - 'A'] &
|
|---|
| 777 | DRIVE_NOTWRITEABLE)) {
|
|---|
| 778 |
|
|---|
| 779 | ULONG bd;
|
|---|
| 780 |
|
|---|
| 781 | strcpy(wa->szCurrentPath, "C:\\");
|
|---|
| 782 | if (DosQuerySysInfo(QSV_BOOT_DRIVE,
|
|---|
| 783 | QSV_BOOT_DRIVE,
|
|---|
| 784 | (PVOID) & bd, (ULONG) sizeof(ULONG)))
|
|---|
| 785 | bd = 3;
|
|---|
| 786 | *wa->szCurrentPath = (CHAR) bd + '@';
|
|---|
| 787 | }
|
|---|
| 788 | WinSendDlgItemMsg(hwnd,
|
|---|
| 789 | WALK_PATH,
|
|---|
| 790 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
|---|
| 791 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 792 | if (!loadedudirs)
|
|---|
| 793 | load_udirs();
|
|---|
| 794 | { /* fill user list box */
|
|---|
| 795 | ULONG ulDriveNum, ulDriveMap;
|
|---|
| 796 | ULONG ulSearchCount;
|
|---|
| 797 | FILEFINDBUF3 findbuf;
|
|---|
| 798 | HDIR hDir;
|
|---|
| 799 | APIRET rc;
|
|---|
| 800 | LINKDIRS *info, *temp;
|
|---|
| 801 |
|
|---|
| 802 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 803 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
|---|
| 804 | info = udirhead;
|
|---|
| 805 | while (info) {
|
|---|
| 806 | if (IsFullName(info->path) &&
|
|---|
| 807 | !(driveflags[toupper(*info->path) - 'A'] &
|
|---|
| 808 | (DRIVE_IGNORE | DRIVE_INVALID))) {
|
|---|
| 809 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 810 | hDir = HDIR_CREATE;
|
|---|
| 811 | ulSearchCount = 1;
|
|---|
| 812 | if (!IsRoot(info->path))
|
|---|
| 813 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
|
|---|
| 814 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 815 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 816 | &findbuf, sizeof(FILEFINDBUF3),
|
|---|
| 817 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 818 | else {
|
|---|
| 819 | rc = 0;
|
|---|
| 820 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 821 | }
|
|---|
| 822 | if (!rc) {
|
|---|
| 823 | if (!IsRoot(info->path))
|
|---|
| 824 | DosFindClose(hDir);
|
|---|
| 825 | if (findbuf.attrFile & FILE_DIRECTORY)
|
|---|
| 826 | WinSendDlgItemMsg(hwnd, WALK_USERLIST, LM_INSERTITEM,
|
|---|
| 827 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
|---|
| 828 | MPFROMP(info->path));
|
|---|
| 829 | else {
|
|---|
| 830 | temp = info->next;
|
|---|
| 831 | remove_udir(info->path);
|
|---|
| 832 | info = temp;
|
|---|
| 833 | continue;
|
|---|
| 834 | }
|
|---|
| 835 | }
|
|---|
| 836 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
|---|
| 837 | temp = info->next;
|
|---|
| 838 | remove_udir(info->path);
|
|---|
| 839 | info = temp;
|
|---|
| 840 | continue;
|
|---|
| 841 | }
|
|---|
| 842 | }
|
|---|
| 843 | info = info->next;
|
|---|
| 844 | }
|
|---|
| 845 | info = ldirhead;
|
|---|
| 846 | while (info) {
|
|---|
| 847 | if (IsFullName(info->path) &&
|
|---|
| 848 | !(driveflags[toupper(*info->path) - 'A'] &
|
|---|
| 849 | (DRIVE_IGNORE | DRIVE_INVALID))) {
|
|---|
| 850 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 851 | hDir = HDIR_CREATE;
|
|---|
| 852 | ulSearchCount = 1;
|
|---|
| 853 | if (!IsRoot(info->path))
|
|---|
| 854 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
|
|---|
| 855 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 856 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 857 | &findbuf, sizeof(FILEFINDBUF3),
|
|---|
| 858 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 859 | else {
|
|---|
| 860 | rc = 0;
|
|---|
| 861 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 862 | }
|
|---|
| 863 | if (!rc) {
|
|---|
| 864 | if (!IsRoot(info->path))
|
|---|
| 865 | DosFindClose(hDir);
|
|---|
| 866 | if (findbuf.attrFile & FILE_DIRECTORY)
|
|---|
| 867 | WinSendDlgItemMsg(hwnd, WALK_RECENT, LM_INSERTITEM,
|
|---|
| 868 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
|---|
| 869 | MPFROMP(info->path));
|
|---|
| 870 | else {
|
|---|
| 871 | temp = info->next;
|
|---|
| 872 | remove_ldir(info->path);
|
|---|
| 873 | info = temp;
|
|---|
| 874 | continue;
|
|---|
| 875 | }
|
|---|
| 876 | WinSetDlgItemText(hwnd, WALK_RECENT,
|
|---|
| 877 | GetPString(IDS_WALKRECENTDIRSTEXT));
|
|---|
| 878 | }
|
|---|
| 879 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
|---|
| 880 | temp = info->next;
|
|---|
| 881 | remove_ldir(info->path);
|
|---|
| 882 | info = temp;
|
|---|
| 883 | continue;
|
|---|
| 884 | }
|
|---|
| 885 | }
|
|---|
| 886 | info = info->next;
|
|---|
| 887 | }
|
|---|
| 888 | }
|
|---|
| 889 | FillPathListBox(hwnd,
|
|---|
| 890 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 891 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 892 | wa->szCurrentPath, wa->nounwriteable);
|
|---|
| 893 | if (!PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID))
|
|---|
| 894 | okay = TRUE;
|
|---|
| 895 | {
|
|---|
| 896 | MRESULT ret;
|
|---|
| 897 |
|
|---|
| 898 | ret = WinDefDlgProc(hwnd, WM_INITDLG, mp1, mp2);
|
|---|
| 899 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
|---|
| 900 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
|---|
| 901 | return ret;
|
|---|
| 902 | }
|
|---|
| 903 |
|
|---|
| 904 | case UM_SETUP4:
|
|---|
| 905 | okay = TRUE;
|
|---|
| 906 | return 0;
|
|---|
| 907 |
|
|---|
| 908 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 909 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
|---|
| 910 | break;
|
|---|
| 911 |
|
|---|
| 912 | case UM_SETDIR:
|
|---|
| 913 | PaintRecessedWindow(WinWindowFromID(hwnd, WALK_HELP), (HPS) 0, FALSE,
|
|---|
| 914 | TRUE);
|
|---|
| 915 | return 0;
|
|---|
| 916 |
|
|---|
| 917 | case WM_PRESPARAMCHANGED:
|
|---|
| 918 | {
|
|---|
| 919 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
|---|
| 920 |
|
|---|
| 921 | cbRetLen = WinQueryPresParam(hwnd, (ULONG) mp1, 0, &AttrFound,
|
|---|
| 922 | (ULONG) sizeof(AttrValue), &AttrValue, 0);
|
|---|
| 923 | if (cbRetLen) {
|
|---|
| 924 | switch (AttrFound) {
|
|---|
| 925 | case PP_FONTNAMESIZE:
|
|---|
| 926 | PrfWriteProfileData(fmprof,
|
|---|
| 927 | appname,
|
|---|
| 928 | "WalkFont", (PVOID) AttrValue, cbRetLen);
|
|---|
| 929 | *WalkFont = 0;
|
|---|
| 930 | WalkFontSize = sizeof(WalkFont);
|
|---|
| 931 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
|---|
| 932 | break;
|
|---|
| 933 | }
|
|---|
| 934 | }
|
|---|
| 935 | }
|
|---|
| 936 | break;
|
|---|
| 937 |
|
|---|
| 938 | case UM_SETUP3:
|
|---|
| 939 | save_udirs();
|
|---|
| 940 | if (hwndMain)
|
|---|
| 941 | PostMsg(hwndMain, UM_FILLUSERLIST, MPVOID, MPVOID);
|
|---|
| 942 | return 0;
|
|---|
| 943 |
|
|---|
| 944 | case UM_SETUP:
|
|---|
| 945 | {
|
|---|
| 946 | INT x;
|
|---|
| 947 | USHORT id[] = { WALK_PATH, WALK_DIRLIST, WALK_USERLIST,
|
|---|
| 948 | WALK_RECENT, 0
|
|---|
| 949 | };
|
|---|
| 950 |
|
|---|
| 951 | if (*WalkFont ||
|
|---|
| 952 | (PrfQueryProfileData(fmprof,
|
|---|
| 953 | appname,
|
|---|
| 954 | "WalkFont",
|
|---|
| 955 | (PVOID) WalkFont,
|
|---|
| 956 | &WalkFontSize) && WalkFontSize)) {
|
|---|
| 957 | for (x = 0; id[x]; x++)
|
|---|
| 958 | WinSetPresParam(WinWindowFromID(hwnd, id[x]),
|
|---|
| 959 | PP_FONTNAMESIZE, WalkFontSize, (PVOID) WalkFont);
|
|---|
| 960 | }
|
|---|
| 961 | }
|
|---|
| 962 | return 0;
|
|---|
| 963 |
|
|---|
| 964 | case UM_CONTROL:
|
|---|
| 965 | case WM_CONTROL:
|
|---|
| 966 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 967 | if (SHORT1FROMMP(mp1) == WALK_DRIVELIST ||
|
|---|
| 968 | SHORT1FROMMP(mp1) == WALK_DIRLIST ||
|
|---|
| 969 | SHORT1FROMMP(mp1) == WALK_USERLIST ||
|
|---|
| 970 | SHORT1FROMMP(mp1) == WALK_RECENT) {
|
|---|
| 971 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 972 | SHORT1FROMMP(mp1),
|
|---|
| 973 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
|---|
| 974 | *szBuffer = 0;
|
|---|
| 975 | if (sSelect >= 0)
|
|---|
| 976 | WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
|
|---|
| 977 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
|---|
| 978 | MPFROMP(szBuffer));
|
|---|
| 979 | }
|
|---|
| 980 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 981 | case WALK_PATH:
|
|---|
| 982 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
|---|
| 983 | WinSetDlgItemText(hwnd, WALK_HELP, GetPString(IDS_WALKCURRDIRTEXT));
|
|---|
| 984 | else if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
|---|
| 985 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 986 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
|---|
| 987 | break;
|
|---|
| 988 |
|
|---|
| 989 | case WALK_RECENT:
|
|---|
| 990 | if (okay && SHORT2FROMMP(mp1) == CBN_LBSELECT) {
|
|---|
| 991 |
|
|---|
| 992 | ULONG ulSearchCount;
|
|---|
| 993 | FILEFINDBUF3 findbuf;
|
|---|
| 994 | HDIR hDir;
|
|---|
| 995 | APIRET rc;
|
|---|
| 996 |
|
|---|
| 997 | // *szBuffer = 0;
|
|---|
| 998 | // WinQueryDlgItemText(hwnd,WALK_RECENT,CCHMAXPATH,szBuffer);
|
|---|
| 999 | if (!*szBuffer)
|
|---|
| 1000 | break;
|
|---|
| 1001 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1002 | hDir = HDIR_CREATE;
|
|---|
| 1003 | ulSearchCount = 1;
|
|---|
| 1004 | if (!IsRoot(szBuffer)) {
|
|---|
| 1005 | rc = DosFindFirst(szBuffer, &hDir, FILE_DIRECTORY |
|
|---|
| 1006 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1007 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1008 | &findbuf, sizeof(FILEFINDBUF3),
|
|---|
| 1009 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1010 | if (!rc)
|
|---|
| 1011 | DosFindClose(hDir);
|
|---|
| 1012 | }
|
|---|
| 1013 | else {
|
|---|
| 1014 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1015 | rc = 0;
|
|---|
| 1016 | }
|
|---|
| 1017 | if (rc)
|
|---|
| 1018 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
|---|
| 1019 | "xDosFindFirst");
|
|---|
| 1020 | else if (~findbuf.attrFile & FILE_DIRECTORY)
|
|---|
| 1021 | Runtime_Error(pszSrcFile, __LINE__, "not a directory");
|
|---|
| 1022 | else {
|
|---|
| 1023 | strcpy(wa->szCurrentPath, szBuffer);
|
|---|
| 1024 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1025 | WinSetDlgItemText(hwnd, WALK_RECENT, wa->szCurrentPath);
|
|---|
| 1026 | FillPathListBox(hwnd,
|
|---|
| 1027 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1028 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1029 | wa->szCurrentPath, FALSE);
|
|---|
| 1030 | }
|
|---|
| 1031 | }
|
|---|
| 1032 | else if (SHORT2FROMMP(mp1) == CBN_ENTER)
|
|---|
| 1033 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
|---|
| 1034 | else if (SHORT2FROMMP(mp1) == CBN_SHOWLIST)
|
|---|
| 1035 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1036 | GetPString(IDS_WALKRECENTDIRSHELPTEXT));
|
|---|
| 1037 | break;
|
|---|
| 1038 |
|
|---|
| 1039 | case WALK_USERLIST:
|
|---|
| 1040 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_SELECT) {
|
|---|
| 1041 |
|
|---|
| 1042 | ULONG ulSearchCount;
|
|---|
| 1043 | FILEFINDBUF3 findbuf;
|
|---|
| 1044 | HDIR hDir;
|
|---|
| 1045 | APIRET rc;
|
|---|
| 1046 |
|
|---|
| 1047 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1048 | hDir = HDIR_CREATE;
|
|---|
| 1049 | ulSearchCount = 1;
|
|---|
| 1050 | if (!IsRoot(szBuffer)) {
|
|---|
| 1051 | rc = DosFindFirst(szBuffer,
|
|---|
| 1052 | &hDir,
|
|---|
| 1053 | FILE_DIRECTORY |
|
|---|
| 1054 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1055 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1056 | &findbuf,
|
|---|
| 1057 | sizeof(FILEFINDBUF3),
|
|---|
| 1058 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1059 | if (!rc)
|
|---|
| 1060 | DosFindClose(hDir);
|
|---|
| 1061 | }
|
|---|
| 1062 | else {
|
|---|
| 1063 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1064 | rc = 0;
|
|---|
| 1065 | }
|
|---|
| 1066 | if (rc)
|
|---|
| 1067 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
|---|
| 1068 | "xDosFindFirst");
|
|---|
| 1069 | else if (~findbuf.attrFile & FILE_DIRECTORY)
|
|---|
| 1070 | Runtime_Error(pszSrcFile, __LINE__, "not a directory");
|
|---|
| 1071 | else {
|
|---|
| 1072 | strcpy(wa->szCurrentPath, szBuffer);
|
|---|
| 1073 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1074 | FillPathListBox(hwnd,
|
|---|
| 1075 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1076 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1077 | wa->szCurrentPath, FALSE);
|
|---|
| 1078 | }
|
|---|
| 1079 | }
|
|---|
| 1080 | else if (SHORT2FROMMP(mp1) == LN_ENTER)
|
|---|
| 1081 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
|---|
| 1082 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
|---|
| 1083 | WinSetDlgItemText(hwnd,
|
|---|
| 1084 | WALK_HELP, GetPString(IDS_WALKUSERDIRSHELPTEXT));
|
|---|
| 1085 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
|---|
| 1086 | WinSetDlgItemText(hwnd,
|
|---|
| 1087 | WALK_HELP, GetPString(IDS_WALKDEFAULTHELPTEXT));
|
|---|
| 1088 | break;
|
|---|
| 1089 |
|
|---|
| 1090 | case WALK_DRIVELIST:
|
|---|
| 1091 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1092 |
|
|---|
| 1093 | ULONG ulDirLen = CCHMAXPATH;
|
|---|
| 1094 | APIRET rc;
|
|---|
| 1095 |
|
|---|
| 1096 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
|---|
| 1097 | if (!rc) {
|
|---|
| 1098 | strcpy(wa->szCurrentPath, "C:\\");
|
|---|
| 1099 | *wa->szCurrentPath = toupper(*szBuffer);
|
|---|
| 1100 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1101 | FillPathListBox(hwnd,
|
|---|
| 1102 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1103 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1104 | wa->szCurrentPath, FALSE);
|
|---|
| 1105 | }
|
|---|
| 1106 | }
|
|---|
| 1107 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
|---|
| 1108 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1109 | GetPString(IDS_WALKDRIVELISTHELPTEXT));
|
|---|
| 1110 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
|---|
| 1111 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1112 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
|---|
| 1113 | break;
|
|---|
| 1114 |
|
|---|
| 1115 | case WALK_DIRLIST:
|
|---|
| 1116 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1117 |
|
|---|
| 1118 | ULONG ulSearchCount;
|
|---|
| 1119 | FILEFINDBUF3 findbuf;
|
|---|
| 1120 | HDIR hDir;
|
|---|
| 1121 | APIRET rc;
|
|---|
| 1122 |
|
|---|
| 1123 | bstrip(szBuffer);
|
|---|
| 1124 | if (*szBuffer) {
|
|---|
| 1125 | strcpy(szBuff, wa->szCurrentPath);
|
|---|
| 1126 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
|---|
| 1127 | strcat(szBuff, "\\");
|
|---|
| 1128 | strcat(szBuff, szBuffer);
|
|---|
| 1129 | MakeFullName(szBuff);
|
|---|
| 1130 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1131 | hDir = HDIR_CREATE;
|
|---|
| 1132 | ulSearchCount = 1;
|
|---|
| 1133 | if (!IsRoot(szBuff)) {
|
|---|
| 1134 | rc = DosFindFirst(szBuff,
|
|---|
| 1135 | &hDir,
|
|---|
| 1136 | FILE_DIRECTORY |
|
|---|
| 1137 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1138 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1139 | &findbuf,
|
|---|
| 1140 | sizeof(FILEFINDBUF3),
|
|---|
| 1141 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1142 | if (!rc)
|
|---|
| 1143 | DosFindClose(hDir);
|
|---|
| 1144 | }
|
|---|
| 1145 | else {
|
|---|
| 1146 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1147 | rc = 0;
|
|---|
| 1148 | }
|
|---|
| 1149 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
|---|
| 1150 | strcpy(wa->szCurrentPath, szBuff);
|
|---|
| 1151 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1152 | FillPathListBox(hwnd,
|
|---|
| 1153 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1154 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1155 | wa->szCurrentPath, FALSE);
|
|---|
| 1156 | }
|
|---|
| 1157 | }
|
|---|
| 1158 | }
|
|---|
| 1159 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
|---|
| 1160 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1161 | GetPString(IDS_WALKDIRLISTHELPTEXT));
|
|---|
| 1162 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
|---|
| 1163 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1164 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
|---|
| 1165 | break;
|
|---|
| 1166 | }
|
|---|
| 1167 | return 0;
|
|---|
| 1168 |
|
|---|
| 1169 | case WM_COMMAND:
|
|---|
| 1170 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 1171 | if (!wa)
|
|---|
| 1172 | WinDismissDlg(hwnd, 0);
|
|---|
| 1173 | *szBuff = 0;
|
|---|
| 1174 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1175 | bstrip(szBuff);
|
|---|
| 1176 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1177 | *p = '\\';
|
|---|
| 1178 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
|---|
| 1179 | szBuff[strlen(szBuff) - 1] = 0;
|
|---|
| 1180 | MakeFullName(szBuff);
|
|---|
| 1181 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
|---|
| 1182 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1183 | QW_OWNER), hwnd, szBuff, 0))
|
|---|
| 1184 | strcpy(wa->szCurrentPath, szBuff);
|
|---|
| 1185 | else
|
|---|
| 1186 | return 0;
|
|---|
| 1187 | }
|
|---|
| 1188 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1189 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1190 | case WALK_ADD:
|
|---|
| 1191 | *szBuff = 0;
|
|---|
| 1192 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1193 | bstrip(szBuff);
|
|---|
| 1194 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1195 | *p = '\\';
|
|---|
| 1196 | if (*szBuff && !IsFile(szBuff)) {
|
|---|
| 1197 | MakeFullName(szBuff);
|
|---|
| 1198 | add_udir(TRUE, szBuff);
|
|---|
| 1199 | if (fUdirsChanged) {
|
|---|
| 1200 | WinSendDlgItemMsg(hwnd,
|
|---|
| 1201 | WALK_USERLIST,
|
|---|
| 1202 | LM_INSERTITEM,
|
|---|
| 1203 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
|---|
| 1204 | MPFROMP(szBuff));
|
|---|
| 1205 | wa->changed = 1;
|
|---|
| 1206 | }
|
|---|
| 1207 | }
|
|---|
| 1208 | break;
|
|---|
| 1209 |
|
|---|
| 1210 | case WALK_DELETE:
|
|---|
| 1211 | *szBuff = 0;
|
|---|
| 1212 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1213 | bstrip(szBuff);
|
|---|
| 1214 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1215 | *p = '\\';
|
|---|
| 1216 | if (*szBuff && !IsFile(szBuff)) {
|
|---|
| 1217 | MakeFullName(szBuff);
|
|---|
| 1218 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 1219 | WALK_USERLIST,
|
|---|
| 1220 | LM_SEARCHSTRING,
|
|---|
| 1221 | MPFROM2SHORT(0, LIT_FIRST),
|
|---|
| 1222 | MPFROMP(szBuff));
|
|---|
| 1223 | if (sSelect >= 0) {
|
|---|
| 1224 | WinSendDlgItemMsg(hwnd,
|
|---|
| 1225 | WALK_USERLIST,
|
|---|
| 1226 | LM_DELETEITEM, MPFROM2SHORT(sSelect, 0), MPVOID);
|
|---|
| 1227 | remove_udir(szBuff);
|
|---|
| 1228 | wa->changed = 1;
|
|---|
| 1229 | }
|
|---|
| 1230 | }
|
|---|
| 1231 | break;
|
|---|
| 1232 |
|
|---|
| 1233 | case DID_OK:
|
|---|
| 1234 | if (*wa->szCurrentPath) {
|
|---|
| 1235 | strcpy(wa->szReturnPath, wa->szCurrentPath);
|
|---|
| 1236 | MakeValidDir(wa->szReturnPath);
|
|---|
| 1237 | if (fAutoAddAllDirs)
|
|---|
| 1238 | add_udir(FALSE, wa->szReturnPath);
|
|---|
| 1239 | if (fChangeTarget) {
|
|---|
| 1240 | strcpy(targetdir, wa->szReturnPath);
|
|---|
| 1241 | PrfWriteProfileString(fmprof, appname, "Targetdir", targetdir);
|
|---|
| 1242 | }
|
|---|
| 1243 | }
|
|---|
| 1244 | {
|
|---|
| 1245 | SWP swp;
|
|---|
| 1246 | ULONG size = sizeof(SWP);
|
|---|
| 1247 |
|
|---|
| 1248 | WinQueryWindowPos(hwnd, &swp);
|
|---|
| 1249 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
|---|
| 1250 | size);
|
|---|
| 1251 | }
|
|---|
| 1252 | if (wa->changed)
|
|---|
| 1253 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
|---|
| 1254 | WinDismissDlg(hwnd, 1);
|
|---|
| 1255 | break;
|
|---|
| 1256 |
|
|---|
| 1257 | case IDM_HELP:
|
|---|
| 1258 | if (hwndHelp)
|
|---|
| 1259 | WinSendMsg(hwndHelp,
|
|---|
| 1260 | HM_DISPLAY_HELP,
|
|---|
| 1261 | MPFROM2SHORT(HELP_WALKEM, 0), MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 1262 | break;
|
|---|
| 1263 |
|
|---|
| 1264 | case DID_CANCEL:
|
|---|
| 1265 | {
|
|---|
| 1266 | SWP swp;
|
|---|
| 1267 | ULONG size = sizeof(SWP);
|
|---|
| 1268 |
|
|---|
| 1269 | WinQueryWindowPos(hwnd, &swp);
|
|---|
| 1270 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
|---|
| 1271 | size);
|
|---|
| 1272 | }
|
|---|
| 1273 | if (wa->changed)
|
|---|
| 1274 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
|---|
| 1275 | free(wa);
|
|---|
| 1276 | WinDismissDlg(hwnd, 0);
|
|---|
| 1277 | break;
|
|---|
| 1278 | }
|
|---|
| 1279 | return 0;
|
|---|
| 1280 |
|
|---|
| 1281 | case WM_CLOSE:
|
|---|
| 1282 | break;
|
|---|
| 1283 | }
|
|---|
| 1284 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1285 | }
|
|---|
| 1286 |
|
|---|
| 1287 | MRESULT EXPENTRY WalkAllDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1288 | {
|
|---|
| 1289 | switch (msg) {
|
|---|
| 1290 | case WM_INITDLG:
|
|---|
| 1291 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1292 | }
|
|---|
| 1293 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1294 | }
|
|---|
| 1295 |
|
|---|
| 1296 | MRESULT EXPENTRY WalkCopyDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1297 | {
|
|---|
| 1298 | switch (msg) {
|
|---|
| 1299 | case WM_INITDLG:
|
|---|
| 1300 | WinSetWindowText(hwnd, GetPString(IDS_WALKCOPYDLGTEXT));
|
|---|
| 1301 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1302 | }
|
|---|
| 1303 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1304 | }
|
|---|
| 1305 |
|
|---|
| 1306 | MRESULT EXPENTRY WalkMoveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1307 | {
|
|---|
| 1308 | switch (msg) {
|
|---|
| 1309 | case WM_INITDLG:
|
|---|
| 1310 | WinSetWindowText(hwnd, GetPString(IDS_WALKMOVEDLGTEXT));
|
|---|
| 1311 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1312 | }
|
|---|
| 1313 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1314 | }
|
|---|
| 1315 |
|
|---|
| 1316 | MRESULT EXPENTRY WalkExtractDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 1317 | MPARAM mp2)
|
|---|
| 1318 | {
|
|---|
| 1319 | switch (msg) {
|
|---|
| 1320 | case WM_INITDLG:
|
|---|
| 1321 | WinSetWindowText(hwnd, GetPString(IDS_WALKEXTRACTDLGTEXT));
|
|---|
| 1322 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1323 | }
|
|---|
| 1324 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1325 | }
|
|---|
| 1326 |
|
|---|
| 1327 | MRESULT EXPENTRY WalkTargetDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 1328 | MPARAM mp2)
|
|---|
| 1329 | {
|
|---|
| 1330 | switch (msg) {
|
|---|
| 1331 | case WM_INITDLG:
|
|---|
| 1332 | {
|
|---|
| 1333 | char s[CCHMAXPATH + 32];
|
|---|
| 1334 |
|
|---|
| 1335 | sprintf(s,
|
|---|
| 1336 | GetPString(IDS_WALKTARGETDLGTEXT),
|
|---|
| 1337 | (*targetdir) ?
|
|---|
| 1338 | NullStr :
|
|---|
| 1339 | " (",
|
|---|
| 1340 | (*targetdir) ?
|
|---|
| 1341 | NullStr : GetPString(IDS_NONE), (*targetdir) ? NullStr : ")");
|
|---|
| 1342 | WinSetWindowText(hwnd, s);
|
|---|
| 1343 | }
|
|---|
| 1344 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1345 | }
|
|---|
| 1346 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1347 | }
|
|---|
| 1348 |
|
|---|
| 1349 | MRESULT EXPENTRY WalkTwoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1350 | {
|
|---|
| 1351 | WALK2 *wa;
|
|---|
| 1352 | CHAR szBuff[CCHMAXPATH + 1], szBuffer[CCHMAXPATH + 1], *p;
|
|---|
| 1353 | SHORT sSelect;
|
|---|
| 1354 | static BOOL okay; /* avoid combobox selecting as filled */
|
|---|
| 1355 |
|
|---|
| 1356 | switch (msg) {
|
|---|
| 1357 | case UM_SETUP2:
|
|---|
| 1358 | case WM_INITDLG:
|
|---|
| 1359 | okay = FALSE;
|
|---|
| 1360 | if (!mp2) {
|
|---|
| 1361 | WinDismissDlg(hwnd, 0);
|
|---|
| 1362 | break;
|
|---|
| 1363 | }
|
|---|
| 1364 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
|---|
| 1365 | wa = mp2;
|
|---|
| 1366 | {
|
|---|
| 1367 | PFNWP oldproc;
|
|---|
| 1368 |
|
|---|
| 1369 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK_PATH),
|
|---|
| 1370 | (PFNWP) TextSubProc);
|
|---|
| 1371 | if (oldproc)
|
|---|
| 1372 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK_PATH),
|
|---|
| 1373 | QWL_USER, (PVOID) oldproc);
|
|---|
| 1374 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK2_PATH),
|
|---|
| 1375 | (PFNWP) TextSubProc);
|
|---|
| 1376 | if (oldproc)
|
|---|
| 1377 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK2_PATH),
|
|---|
| 1378 | QWL_USER, (PVOID) oldproc);
|
|---|
| 1379 | }
|
|---|
| 1380 | {
|
|---|
| 1381 | SWP swp;
|
|---|
| 1382 | ULONG size = sizeof(SWP);
|
|---|
| 1383 |
|
|---|
| 1384 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp, &size);
|
|---|
| 1385 | WinSetWindowPos(hwnd,
|
|---|
| 1386 | HWND_TOP,
|
|---|
| 1387 | swp.x,
|
|---|
| 1388 | swp.y,
|
|---|
| 1389 | swp.cx,
|
|---|
| 1390 | swp.cy,
|
|---|
| 1391 | swp.fl);
|
|---|
| 1392 | }
|
|---|
| 1393 | if (!*wa->szCurrentPath1)
|
|---|
| 1394 | strcpy(wa->szCurrentPath1, pFM2SaveDirectory);
|
|---|
| 1395 | MakeFullName(wa->szCurrentPath1);
|
|---|
| 1396 | if (!*wa->szCurrentPath2)
|
|---|
| 1397 | strcpy(wa->szCurrentPath2, pFM2SaveDirectory);
|
|---|
| 1398 | MakeFullName(wa->szCurrentPath2);
|
|---|
| 1399 | WinSendDlgItemMsg(hwnd,
|
|---|
| 1400 | WALK_PATH,
|
|---|
| 1401 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
|---|
| 1402 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
|---|
| 1403 | WinSendDlgItemMsg(hwnd, WALK2_PATH, EM_SETTEXTLIMIT,
|
|---|
| 1404 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
|---|
| 1405 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
|---|
| 1406 | FillPathListBox(hwnd,
|
|---|
| 1407 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1408 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1409 | wa->szCurrentPath1, FALSE);
|
|---|
| 1410 | FillPathListBox(hwnd,
|
|---|
| 1411 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
|---|
| 1412 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
|---|
| 1413 | wa->szCurrentPath2, FALSE);
|
|---|
| 1414 | if (!PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID))
|
|---|
| 1415 | okay = TRUE;
|
|---|
| 1416 | {
|
|---|
| 1417 | MRESULT ret;
|
|---|
| 1418 |
|
|---|
| 1419 | ret = WinDefDlgProc(hwnd, WM_INITDLG, mp1, mp2);
|
|---|
| 1420 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
|---|
| 1421 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
|---|
| 1422 | WinInvalidateRect(WinWindowFromID(hwnd, WALK2_PATH), NULL, TRUE);
|
|---|
| 1423 | return ret;
|
|---|
| 1424 | }
|
|---|
| 1425 |
|
|---|
| 1426 | case UM_SETUP4:
|
|---|
| 1427 | okay = TRUE;
|
|---|
| 1428 | return 0;
|
|---|
| 1429 |
|
|---|
| 1430 | case WM_PRESPARAMCHANGED:
|
|---|
| 1431 | {
|
|---|
| 1432 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
|---|
| 1433 |
|
|---|
| 1434 | cbRetLen = WinQueryPresParam(hwnd, (ULONG) mp1, 0, &AttrFound,
|
|---|
| 1435 | (ULONG) sizeof(AttrValue), &AttrValue, 0);
|
|---|
| 1436 | if (cbRetLen) {
|
|---|
| 1437 | switch (AttrFound) {
|
|---|
| 1438 | case PP_FONTNAMESIZE:
|
|---|
| 1439 | PrfWriteProfileData(fmprof,
|
|---|
| 1440 | appname,
|
|---|
| 1441 | "WalkFont", (PVOID) AttrValue, cbRetLen);
|
|---|
| 1442 | *WalkFont = 0;
|
|---|
| 1443 | WalkFontSize = sizeof(WalkFont);
|
|---|
| 1444 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
|---|
| 1445 | break;
|
|---|
| 1446 | }
|
|---|
| 1447 | }
|
|---|
| 1448 | }
|
|---|
| 1449 | break;
|
|---|
| 1450 |
|
|---|
| 1451 | case UM_SETUP:
|
|---|
| 1452 | {
|
|---|
| 1453 | INT x;
|
|---|
| 1454 | USHORT id[] = { WALK_PATH, WALK_DIRLIST,
|
|---|
| 1455 | WALK2_PATH, WALK2_DIRLIST, 0
|
|---|
| 1456 | };
|
|---|
| 1457 |
|
|---|
| 1458 | if (*WalkFont ||
|
|---|
| 1459 | (PrfQueryProfileData(fmprof,
|
|---|
| 1460 | appname,
|
|---|
| 1461 | "WalkFont",
|
|---|
| 1462 | (PVOID) WalkFont,
|
|---|
| 1463 | &WalkFontSize) && WalkFontSize)) {
|
|---|
| 1464 | for (x = 0; id[x]; x++)
|
|---|
| 1465 | WinSetPresParam(WinWindowFromID(hwnd, id[x]),
|
|---|
| 1466 | PP_FONTNAMESIZE, WalkFontSize, (PVOID) WalkFont);
|
|---|
| 1467 | }
|
|---|
| 1468 | }
|
|---|
| 1469 | return 0;
|
|---|
| 1470 |
|
|---|
| 1471 | case UM_CONTROL:
|
|---|
| 1472 | case WM_CONTROL:
|
|---|
| 1473 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 1474 | if (SHORT1FROMMP(mp1) == WALK_DRIVELIST ||
|
|---|
| 1475 | SHORT1FROMMP(mp1) == WALK_DIRLIST ||
|
|---|
| 1476 | SHORT1FROMMP(mp1) == WALK2_DRIVELIST ||
|
|---|
| 1477 | SHORT1FROMMP(mp1) == WALK2_DIRLIST) {
|
|---|
| 1478 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 1479 | SHORT1FROMMP(mp1),
|
|---|
| 1480 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
|---|
| 1481 | *szBuffer = 0;
|
|---|
| 1482 | if (sSelect >= 0)
|
|---|
| 1483 | WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
|
|---|
| 1484 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
|---|
| 1485 | MPFROMP(szBuffer));
|
|---|
| 1486 | }
|
|---|
| 1487 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1488 | case WALK_DRIVELIST:
|
|---|
| 1489 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1490 |
|
|---|
| 1491 | ULONG ulDirLen = CCHMAXPATH;
|
|---|
| 1492 | APIRET rc;
|
|---|
| 1493 |
|
|---|
| 1494 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
|---|
| 1495 | if (!rc) {
|
|---|
| 1496 | strcpy(wa->szCurrentPath1, "C:\\");
|
|---|
| 1497 | *wa->szCurrentPath1 = toupper(*szBuffer);
|
|---|
| 1498 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
|---|
| 1499 | FillPathListBox(hwnd,
|
|---|
| 1500 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1501 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1502 | wa->szCurrentPath1, FALSE);
|
|---|
| 1503 | }
|
|---|
| 1504 | }
|
|---|
| 1505 | break;
|
|---|
| 1506 |
|
|---|
| 1507 | case WALK_DIRLIST:
|
|---|
| 1508 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1509 |
|
|---|
| 1510 | ULONG ulSearchCount;
|
|---|
| 1511 | FILEFINDBUF3 findbuf;
|
|---|
| 1512 | HDIR hDir;
|
|---|
| 1513 | APIRET rc;
|
|---|
| 1514 |
|
|---|
| 1515 | bstrip(szBuffer);
|
|---|
| 1516 | if (*szBuffer) {
|
|---|
| 1517 | strcpy(szBuff, wa->szCurrentPath1);
|
|---|
| 1518 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
|---|
| 1519 | strcat(szBuff, "\\");
|
|---|
| 1520 | strcat(szBuff, szBuffer);
|
|---|
| 1521 | MakeFullName(szBuff);
|
|---|
| 1522 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1523 | hDir = HDIR_CREATE;
|
|---|
| 1524 | ulSearchCount = 1;
|
|---|
| 1525 | if (!IsRoot(szBuff)) {
|
|---|
| 1526 | rc = DosFindFirst(szBuff,
|
|---|
| 1527 | &hDir,
|
|---|
| 1528 | FILE_DIRECTORY |
|
|---|
| 1529 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1530 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1531 | &findbuf,
|
|---|
| 1532 | sizeof(FILEFINDBUF3),
|
|---|
| 1533 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1534 | if (!rc)
|
|---|
| 1535 | DosFindClose(hDir);
|
|---|
| 1536 | }
|
|---|
| 1537 | else {
|
|---|
| 1538 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1539 | rc = 0;
|
|---|
| 1540 | }
|
|---|
| 1541 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
|---|
| 1542 | strcpy(wa->szCurrentPath1, szBuff);
|
|---|
| 1543 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
|---|
| 1544 | FillPathListBox(hwnd,
|
|---|
| 1545 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1546 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1547 | wa->szCurrentPath1, FALSE);
|
|---|
| 1548 | }
|
|---|
| 1549 | }
|
|---|
| 1550 | }
|
|---|
| 1551 | break;
|
|---|
| 1552 |
|
|---|
| 1553 | case WALK2_DRIVELIST:
|
|---|
| 1554 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1555 |
|
|---|
| 1556 | ULONG ulDirLen = CCHMAXPATH;
|
|---|
| 1557 | APIRET rc;
|
|---|
| 1558 |
|
|---|
| 1559 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
|---|
| 1560 | if (!rc) {
|
|---|
| 1561 | strcpy(wa->szCurrentPath2, "C:\\");
|
|---|
| 1562 | *wa->szCurrentPath2 = toupper(*szBuffer);
|
|---|
| 1563 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
|---|
| 1564 | FillPathListBox(hwnd,
|
|---|
| 1565 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
|---|
| 1566 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
|---|
| 1567 | wa->szCurrentPath2, FALSE);
|
|---|
| 1568 | }
|
|---|
| 1569 | }
|
|---|
| 1570 | break;
|
|---|
| 1571 |
|
|---|
| 1572 | case WALK2_DIRLIST:
|
|---|
| 1573 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1574 |
|
|---|
| 1575 | ULONG ulSearchCount;
|
|---|
| 1576 | FILEFINDBUF3 findbuf;
|
|---|
| 1577 | HDIR hDir;
|
|---|
| 1578 | APIRET rc;
|
|---|
| 1579 |
|
|---|
| 1580 | bstrip(szBuffer);
|
|---|
| 1581 | if (*szBuffer) {
|
|---|
| 1582 | strcpy(szBuff, wa->szCurrentPath2);
|
|---|
| 1583 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
|---|
| 1584 | strcat(szBuff, "\\");
|
|---|
| 1585 | strcat(szBuff, szBuffer);
|
|---|
| 1586 | MakeFullName(szBuff);
|
|---|
| 1587 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1588 | hDir = HDIR_CREATE;
|
|---|
| 1589 | ulSearchCount = 1;
|
|---|
| 1590 | if (!IsRoot(szBuff)) {
|
|---|
| 1591 | rc = DosFindFirst(szBuff,
|
|---|
| 1592 | &hDir,
|
|---|
| 1593 | FILE_DIRECTORY |
|
|---|
| 1594 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1595 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1596 | &findbuf,
|
|---|
| 1597 | sizeof(FILEFINDBUF3),
|
|---|
| 1598 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1599 | if (!rc)
|
|---|
| 1600 | DosFindClose(hDir);
|
|---|
| 1601 | }
|
|---|
| 1602 | else {
|
|---|
| 1603 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1604 | rc = 0;
|
|---|
| 1605 | }
|
|---|
| 1606 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
|---|
| 1607 | strcpy(wa->szCurrentPath2, szBuff);
|
|---|
| 1608 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
|---|
| 1609 | FillPathListBox(hwnd,
|
|---|
| 1610 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
|---|
| 1611 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
|---|
| 1612 | wa->szCurrentPath2, FALSE);
|
|---|
| 1613 | }
|
|---|
| 1614 | }
|
|---|
| 1615 | }
|
|---|
| 1616 | break;
|
|---|
| 1617 | }
|
|---|
| 1618 | return 0;
|
|---|
| 1619 |
|
|---|
| 1620 | case WM_COMMAND:
|
|---|
| 1621 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 1622 | if (!wa)
|
|---|
| 1623 | WinDismissDlg(hwnd, 0);
|
|---|
| 1624 | *szBuff = 0;
|
|---|
| 1625 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1626 | bstrip(szBuff);
|
|---|
| 1627 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1628 | *p = '\\';
|
|---|
| 1629 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
|---|
| 1630 | szBuff[strlen(szBuff) - 1] = 0;
|
|---|
| 1631 | MakeFullName(szBuff);
|
|---|
| 1632 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath1) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
|---|
| 1633 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1634 | QW_OWNER), hwnd, szBuff, 0))
|
|---|
| 1635 | strcpy(wa->szCurrentPath1, szBuff);
|
|---|
| 1636 | else
|
|---|
| 1637 | return 0;
|
|---|
| 1638 | }
|
|---|
| 1639 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
|---|
| 1640 | *szBuff = 0;
|
|---|
| 1641 | WinQueryDlgItemText(hwnd, WALK2_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1642 | bstrip(szBuff);
|
|---|
| 1643 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1644 | *p = '\\';
|
|---|
| 1645 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
|---|
| 1646 | szBuff[strlen(szBuff) - 1] = 0;
|
|---|
| 1647 | MakeFullName(szBuff);
|
|---|
| 1648 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath2) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
|---|
| 1649 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1650 | QW_OWNER), hwnd, szBuff, 0))
|
|---|
| 1651 | strcpy(wa->szCurrentPath2, szBuff);
|
|---|
| 1652 | else
|
|---|
| 1653 | return 0;
|
|---|
| 1654 | }
|
|---|
| 1655 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
|---|
| 1656 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1657 | case DID_OK:
|
|---|
| 1658 | {
|
|---|
| 1659 | SWP swp;
|
|---|
| 1660 | ULONG size = sizeof(SWP);
|
|---|
| 1661 |
|
|---|
| 1662 | WinQueryWindowPos(hwnd, &swp);
|
|---|
| 1663 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
|
|---|
| 1664 | size);
|
|---|
| 1665 | }
|
|---|
| 1666 | WinDismissDlg(hwnd, 1);
|
|---|
| 1667 | break;
|
|---|
| 1668 |
|
|---|
| 1669 | case IDM_HELP:
|
|---|
| 1670 | if (hwndHelp)
|
|---|
| 1671 | WinSendMsg(hwndHelp,
|
|---|
| 1672 | HM_DISPLAY_HELP,
|
|---|
| 1673 | MPFROM2SHORT(HELP_WALKEM2, 0), MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 1674 | break;
|
|---|
| 1675 |
|
|---|
| 1676 | case DID_CANCEL:
|
|---|
| 1677 | {
|
|---|
| 1678 | SWP swp;
|
|---|
| 1679 | ULONG size = sizeof(SWP);
|
|---|
| 1680 |
|
|---|
| 1681 | WinQueryWindowPos(hwnd, &swp);
|
|---|
| 1682 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
|
|---|
| 1683 | size);
|
|---|
| 1684 | }
|
|---|
| 1685 | WinDismissDlg(hwnd, 0);
|
|---|
| 1686 | break;
|
|---|
| 1687 | }
|
|---|
| 1688 | return 0;
|
|---|
| 1689 |
|
|---|
| 1690 | case WM_CLOSE:
|
|---|
| 1691 | break;
|
|---|
| 1692 | }
|
|---|
| 1693 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1694 | }
|
|---|
| 1695 |
|
|---|
| 1696 | MRESULT EXPENTRY WalkTwoCmpDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 1697 | MPARAM mp2)
|
|---|
| 1698 | {
|
|---|
| 1699 | switch (msg) {
|
|---|
| 1700 | case WM_INITDLG:
|
|---|
| 1701 | WinSetWindowText(hwnd, GetPString(IDS_WALKCOMPAREDLGTEXT));
|
|---|
| 1702 | return WalkTwoDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1703 | }
|
|---|
| 1704 | return WalkTwoDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1705 | }
|
|---|
| 1706 |
|
|---|
| 1707 | MRESULT EXPENTRY WalkTwoSetDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 1708 | MPARAM mp2)
|
|---|
| 1709 | {
|
|---|
| 1710 | switch (msg) {
|
|---|
| 1711 | case WM_INITDLG:
|
|---|
| 1712 | WinSetWindowText(hwnd, GetPString(IDS_WALKSETDIRSDLGTEXT));
|
|---|
| 1713 | return WalkTwoDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1714 | }
|
|---|
| 1715 | return WalkTwoDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1716 | }
|
|---|
| 1717 |
|
|---|
| 1718 | #pragma alloc_text(WALKER,FillPathListBox,WalkDlgProc,TextSubProc)
|
|---|
| 1719 | #pragma alloc_text(WALKER,WalkAllDlgProc,WalkCopyDlgProc)
|
|---|
| 1720 | #pragma alloc_text(WALKER,WalkMoveDlgProc,WalkExtractDlgProc,WalkTargetDlgProc)
|
|---|
| 1721 | #pragma alloc_text(WALK2,WalkTwoDlgProc,WalkTwoCmpDlgProc,WalkTwoSetDlgProc)
|
|---|
| 1722 | #pragma alloc_text(UDIRS,add_udir,remove_udir,remove_ldir,load_udirs)
|
|---|
| 1723 | #pragma alloc_text(UDIRS,save_udirs,load_setups,save_setups,add_setups)
|
|---|
| 1724 | #pragma alloc_text(UDIRS,remove_setup)
|
|---|