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