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