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