| 1 |
|
|---|
| 2 | /***********************************************************************
|
|---|
| 3 |
|
|---|
| 4 | $Id: walkem.c 1228 2008-09-13 23:13:40Z jbs $
|
|---|
| 5 |
|
|---|
| 6 | Misc persistent lists support
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
|---|
| 9 | Copyright (c) 2005, 2008 Steven H. Levine
|
|---|
| 10 |
|
|---|
| 11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
|---|
| 12 | 05 Jun 05 SHL Use QWL_USER
|
|---|
| 13 | 13 Aug 05 SHL Run through indent
|
|---|
| 14 | 13 Aug 05 SHL remove_udir - avoid corrupting last dirs list
|
|---|
| 15 | 17 Jul 06 SHL Use Runtime_Error
|
|---|
| 16 | 29 Jul 06 SHL Use xfgets
|
|---|
| 17 | 20 Oct 06 SHL Correct . .. check
|
|---|
| 18 | 06 Nov 06 SHL Oops - need to allow .. here
|
|---|
| 19 | 14 Nov 06 SHL Correct FillPathListBox regression
|
|---|
| 20 | 22 Mar 07 GKY Use QWL_USER
|
|---|
| 21 | 20 Apr 07 SHL Avoid spurious add_udir error reports
|
|---|
| 22 | 16 Aug 07 SHL Update add_setups for ticket# 109
|
|---|
| 23 | 19 Aug 07 SHL Correct load_setups error reporting
|
|---|
| 24 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
|---|
| 25 | 25 Aug 07 SHL Correct #pragma alloc_text typos
|
|---|
| 26 | 11 Nov 07 GKY Cancel now directly closes dialog even if directory path text has changed
|
|---|
| 27 | 20 Jan 08 GKY Walk & walk2 dialogs now save and restore size and position
|
|---|
| 28 | 19 Feb 08 JBS Add "State at last FM/2 close" to the states combo box
|
|---|
| 29 | 29 Feb 08 GKY Use xfree where appropriate
|
|---|
| 30 | 29 Feb 08 GKY Refactor global command line variables to notebook.h
|
|---|
| 31 | 19 Jun 08 JBS Ticket 227: Allow temporary saving/deleting of the shutdown state of directory containers
|
|---|
| 32 | 22 Jun 08 GKY Add free_?dir for fortify testing
|
|---|
| 33 | 18 Jul 08 SHL More Fortify support
|
|---|
| 34 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory and use BldFullPathName
|
|---|
| 35 | 24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
|
|---|
| 36 |
|
|---|
| 37 | ***********************************************************************/
|
|---|
| 38 |
|
|---|
| 39 | #include <stdlib.h>
|
|---|
| 40 | #include <string.h>
|
|---|
| 41 | #include <ctype.h>
|
|---|
| 42 | #include <share.h>
|
|---|
| 43 |
|
|---|
| 44 | #define INCL_WIN
|
|---|
| 45 | #define INCL_DOS
|
|---|
| 46 | #define INCL_DOSERRORS
|
|---|
| 47 | #define INCL_SHLERRORS // PMERR_NOT_IN_IDX
|
|---|
| 48 | #define INCL_LONGLONG
|
|---|
| 49 |
|
|---|
| 50 | #include "fm3dll.h"
|
|---|
| 51 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
|---|
| 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)
|
|---|
| 56 | #include "fm3dlg.h"
|
|---|
| 57 | #include "fm3str.h"
|
|---|
| 58 | #include "errutil.h" // Dos_Error...
|
|---|
| 59 | #include "strutil.h" // GetPString
|
|---|
| 60 | #include "notebook.h" // targetdirectory
|
|---|
| 61 | #include "pathutil.h" // BldFullPathName
|
|---|
| 62 | #include "walkem.h"
|
|---|
| 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
|
|---|
| 70 | #include "fortify.h"
|
|---|
| 71 |
|
|---|
| 72 | typedef struct
|
|---|
| 73 | {
|
|---|
| 74 | USHORT size;
|
|---|
| 75 | USHORT changed;
|
|---|
| 76 | BOOL nounwriteable;
|
|---|
| 77 | CHAR szCurrentPath[CCHMAXPATH];
|
|---|
| 78 | CHAR *szReturnPath;
|
|---|
| 79 | }
|
|---|
| 80 | WALKER;
|
|---|
| 81 |
|
|---|
| 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__;
|
|---|
| 90 | static CHAR WalkFont[CCHMAXPATH] = "";
|
|---|
| 91 | static ULONG WalkFontSize = sizeof(WalkFont);
|
|---|
| 92 |
|
|---|
| 93 | /**
|
|---|
| 94 | * States names management
|
|---|
| 95 | */
|
|---|
| 96 |
|
|---|
| 97 | static BOOL fSetupsLoaded;
|
|---|
| 98 | static LINKDIRS *pFirstSetup;
|
|---|
| 99 | static const PSZ pszLastSetups = "LastSetups";
|
|---|
| 100 | // 18 Aug 07 SHL fixme to stop supporting old style 1 year from now?
|
|---|
| 101 | static const ULONG ulOldSetupsBytes = 100 * 13; // Prior to 3.0.7
|
|---|
| 102 |
|
|---|
| 103 | #pragma data_seg(GLOBAL1)
|
|---|
| 104 | BOOL fUdirsChanged;
|
|---|
| 105 | BOOL loadedudirs;
|
|---|
| 106 |
|
|---|
| 107 | #pragma data_seg(GLOBAL2)
|
|---|
| 108 | LINKDIRS *ldirhead;
|
|---|
| 109 | LINKDIRS *udirhead;
|
|---|
| 110 |
|
|---|
| 111 | /**
|
|---|
| 112 | * Fill States drop down list with known state names
|
|---|
| 113 | */
|
|---|
| 114 |
|
|---|
| 115 | VOID fill_setups_list(VOID)
|
|---|
| 116 | {
|
|---|
| 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 | }
|
|---|
| 131 |
|
|---|
| 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 |
|
|---|
| 142 | static INT lookup_setup(PSZ name, UINT action)
|
|---|
| 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;
|
|---|
| 161 | xfree(pld->path, pszSrcFile, __LINE__);
|
|---|
| 162 | free(pld);
|
|---|
| 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) {
|
|---|
| 176 | free(pld);
|
|---|
| 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
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | /**
|
|---|
| 189 | * Load state names from ini
|
|---|
| 190 | * Support old/new style storage method
|
|---|
| 191 | */
|
|---|
| 192 |
|
|---|
| 193 | VOID load_setups(VOID)
|
|---|
| 194 | {
|
|---|
| 195 | ULONG ulDataBytes;
|
|---|
| 196 | ULONG l;
|
|---|
| 197 | PSZ pszBuf;
|
|---|
| 198 | PSZ psz;
|
|---|
| 199 | LINKDIRS *pld;
|
|---|
| 200 |
|
|---|
| 201 | if (fSetupsLoaded)
|
|---|
| 202 | return;
|
|---|
| 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) {
|
|---|
| 208 | // Get error info back
|
|---|
| 209 | PrfQueryProfileSize(fmprof, FM3Str, pszLastSetups, &ulDataBytes);
|
|---|
| 210 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, "PrfQueryProfileSize");
|
|---|
| 211 | }
|
|---|
| 212 | else
|
|---|
| 213 | fSetupsLoaded = TRUE; // Nothing saved
|
|---|
| 214 | return;
|
|---|
| 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");
|
|---|
| 228 | free(pszBuf);
|
|---|
| 229 | return;
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | if (ulDataBytes != l) {
|
|---|
| 233 | Runtime_Error(pszSrcFile, __LINE__, "PrfQueryProfileData reported %u expected %u", l, ulDataBytes);
|
|---|
| 234 | free(pszBuf);
|
|---|
| 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) {
|
|---|
| 247 | free(pszBuf);
|
|---|
| 248 | return;
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | # ifdef FORTIFY
|
|---|
| 252 | Fortify_SetOwner(pld, 1);
|
|---|
| 253 | Fortify_SetScope(pld, 1);
|
|---|
| 254 | # endif
|
|---|
| 255 |
|
|---|
| 256 | pld->path = xstrdup(psz, pszSrcFile, __LINE__);
|
|---|
| 257 | if (!pld->path) {
|
|---|
| 258 | free(pszBuf);
|
|---|
| 259 | free(pld);
|
|---|
| 260 | return;
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | # ifdef FORTIFY
|
|---|
| 264 | Fortify_SetOwner(pld->path, 1);
|
|---|
| 265 | Fortify_SetScope(pld->path, 1);
|
|---|
| 266 | # endif
|
|---|
| 267 |
|
|---|
| 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 |
|
|---|
| 279 | free(pszBuf);
|
|---|
| 280 |
|
|---|
| 281 | fSetupsLoaded = TRUE;
|
|---|
| 282 | }
|
|---|
| 283 |
|
|---|
| 284 | VOID save_setups(VOID)
|
|---|
| 285 | {
|
|---|
| 286 | ULONG ulBufBytes;
|
|---|
| 287 | ULONG ulFillBytes;
|
|---|
| 288 | ULONG l;
|
|---|
| 289 | PSZ pszBuf;
|
|---|
| 290 | PSZ psz;
|
|---|
| 291 | LINKDIRS *pld;
|
|---|
| 292 |
|
|---|
| 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;
|
|---|
| 318 | }
|
|---|
| 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);
|
|---|
| 331 | }
|
|---|
| 332 |
|
|---|
| 333 | /**
|
|---|
| 334 | * Add named state to setups list
|
|---|
| 335 | * @return same as lookup_setup
|
|---|
| 336 | */
|
|---|
| 337 |
|
|---|
| 338 | INT add_setup(PSZ 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 |
|
|---|
| 378 | if (udirhead)
|
|---|
| 379 | free_udirs();
|
|---|
| 380 | loadedudirs = TRUE;
|
|---|
| 381 | fUdirsChanged = FALSE;
|
|---|
| 382 | BldFullPathName(s, pFM2SaveDirectory, "USERDIRS.DAT");
|
|---|
| 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__);
|
|---|
| 392 | # ifdef FORTIFY
|
|---|
| 393 | Fortify_SetOwner(info, 1);
|
|---|
| 394 | Fortify_SetScope(info, 1);
|
|---|
| 395 | # endif
|
|---|
| 396 | if (info) {
|
|---|
| 397 | info->path = xstrdup(s, pszSrcFile, __LINE__);
|
|---|
| 398 | if (!info->path)
|
|---|
| 399 | free(info);
|
|---|
| 400 | else {
|
|---|
| 401 | # ifdef FORTIFY
|
|---|
| 402 | Fortify_SetOwner(info->path, 1);
|
|---|
| 403 | Fortify_SetScope(info->path, 1);
|
|---|
| 404 | # endif
|
|---|
| 405 | info->next = NULL;
|
|---|
| 406 | if (!udirhead)
|
|---|
| 407 | udirhead = info;
|
|---|
| 408 | else
|
|---|
| 409 | last->next = info;
|
|---|
| 410 | last = info;
|
|---|
| 411 | }
|
|---|
| 412 | }
|
|---|
| 413 | }
|
|---|
| 414 | }
|
|---|
| 415 | fclose(fp);
|
|---|
| 416 | }
|
|---|
| 417 | }
|
|---|
| 418 |
|
|---|
| 419 | VOID save_udirs(VOID)
|
|---|
| 420 | {
|
|---|
| 421 | FILE *fp;
|
|---|
| 422 | LINKDIRS *info;
|
|---|
| 423 | CHAR s[CCHMAXPATH + 14];
|
|---|
| 424 |
|
|---|
| 425 | if (loadedudirs) {
|
|---|
| 426 | fUdirsChanged = FALSE;
|
|---|
| 427 | if (udirhead) {
|
|---|
| 428 | BldFullPathName(s, pFM2SaveDirectory, "USERDIRS.DAT");
|
|---|
| 429 | if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2)
|
|---|
| 430 | return; //already gave error msg
|
|---|
| 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;
|
|---|
| 438 | }
|
|---|
| 439 | fclose(fp);
|
|---|
| 440 | }
|
|---|
| 441 | }
|
|---|
| 442 | }
|
|---|
| 443 | }
|
|---|
| 444 |
|
|---|
| 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 | */
|
|---|
| 452 |
|
|---|
| 453 | BOOL add_udir(BOOL userdirs, CHAR *inpath)
|
|---|
| 454 | {
|
|---|
| 455 | CHAR path[CCHMAXPATH];
|
|---|
| 456 | LINKDIRS *info;
|
|---|
| 457 | LINKDIRS *last = NULL;
|
|---|
| 458 | LINKDIRS *temp;
|
|---|
| 459 |
|
|---|
| 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))
|
|---|
| 481 | return FALSE;
|
|---|
| 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;
|
|---|
| 493 | else
|
|---|
| 494 | ldirhead = info->next;
|
|---|
| 495 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 496 | free(info);
|
|---|
| 497 | break;
|
|---|
| 498 | }
|
|---|
| 499 | temp = info;
|
|---|
| 500 | info = info->next;
|
|---|
| 501 | }
|
|---|
| 502 | }
|
|---|
| 503 | // Append entry to end of user dirs list
|
|---|
| 504 | info = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
|---|
| 505 | if (info) {
|
|---|
| 506 | # ifdef FORTIFY
|
|---|
| 507 | Fortify_SetScope(info, 1);
|
|---|
| 508 | # endif
|
|---|
| 509 | info->path = xstrdup(path, pszSrcFile, __LINE__);
|
|---|
| 510 | if (!info->path)
|
|---|
| 511 | free(info);
|
|---|
| 512 | else {
|
|---|
| 513 | # ifdef FORTIFY
|
|---|
| 514 | Fortify_SetScope(info->path, 1);
|
|---|
| 515 | # endif
|
|---|
| 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;
|
|---|
| 529 | }
|
|---|
| 530 | return TRUE;
|
|---|
| 531 | }
|
|---|
| 532 | }
|
|---|
| 533 | }
|
|---|
| 534 | }
|
|---|
| 535 | return FALSE;
|
|---|
| 536 | }
|
|---|
| 537 |
|
|---|
| 538 | //=== remove_udir - remove path from user dir list or last directory list ===
|
|---|
| 539 |
|
|---|
| 540 | BOOL remove_udir(CHAR * path)
|
|---|
| 541 | {
|
|---|
| 542 | LINKDIRS *info;
|
|---|
| 543 | LINKDIRS *last = NULL;
|
|---|
| 544 |
|
|---|
| 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;
|
|---|
| 555 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 556 | free(info);
|
|---|
| 557 | fUdirsChanged = TRUE;
|
|---|
| 558 | return TRUE;
|
|---|
| 559 | }
|
|---|
| 560 | last = info;
|
|---|
| 561 | info = info->next;
|
|---|
| 562 | }
|
|---|
| 563 |
|
|---|
| 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;
|
|---|
| 572 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 573 | free(info);
|
|---|
| 574 | return TRUE;
|
|---|
| 575 | }
|
|---|
| 576 | last = info;
|
|---|
| 577 | info = info->next;
|
|---|
| 578 | }
|
|---|
| 579 | }
|
|---|
| 580 | return FALSE;
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 | BOOL remove_ldir(CHAR * path)
|
|---|
| 584 | {
|
|---|
| 585 | LINKDIRS *info;
|
|---|
| 586 | LINKDIRS *last = NULL;
|
|---|
| 587 |
|
|---|
| 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;
|
|---|
| 596 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 597 | free(info);
|
|---|
| 598 | return TRUE;
|
|---|
| 599 | }
|
|---|
| 600 | last = info;
|
|---|
| 601 | info = info->next;
|
|---|
| 602 | }
|
|---|
| 603 | }
|
|---|
| 604 | return FALSE;
|
|---|
| 605 | }
|
|---|
| 606 |
|
|---|
| 607 | # ifdef FORTIFY
|
|---|
| 608 |
|
|---|
| 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__);
|
|---|
| 617 | free(info);
|
|---|
| 618 | info = next;
|
|---|
| 619 | }
|
|---|
| 620 | ldirhead = NULL;
|
|---|
| 621 | }
|
|---|
| 622 |
|
|---|
| 623 | # endif
|
|---|
| 624 |
|
|---|
| 625 | VOID free_udirs(VOID)
|
|---|
| 626 | {
|
|---|
| 627 | LINKDIRS *info, *next;
|
|---|
| 628 |
|
|---|
| 629 | info = udirhead;
|
|---|
| 630 | while (info) {
|
|---|
| 631 | next = info->next;
|
|---|
| 632 | xfree(info->path, pszSrcFile, __LINE__);
|
|---|
| 633 | free(info);
|
|---|
| 634 | info = next;
|
|---|
| 635 | }
|
|---|
| 636 | udirhead = NULL;
|
|---|
| 637 | }
|
|---|
| 638 |
|
|---|
| 639 | VOID FillPathListBox(HWND hwnd, HWND hwnddrive, HWND hwnddir, CHAR * pszPath,
|
|---|
| 640 | BOOL nounwriteable)
|
|---|
| 641 | {
|
|---|
| 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 | */
|
|---|
| 648 |
|
|---|
| 649 | CHAR szDrive[] = " :", szTemp[1032];
|
|---|
| 650 | FILEFINDBUF3 findbuf;
|
|---|
| 651 | HDIR hDir = HDIR_CREATE;
|
|---|
| 652 | SHORT sDrive;
|
|---|
| 653 | ULONG ulDriveNum, ulSearchCount = 1, ulDriveMap;
|
|---|
| 654 |
|
|---|
| 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);
|
|---|
| 661 |
|
|---|
| 662 | if (hwnddrive) {
|
|---|
| 663 | // Fill drive listbox
|
|---|
| 664 | for (sDrive = 0; sDrive < 26; sDrive++) {
|
|---|
| 665 | if (ulDriveMap & (1 << sDrive)) {
|
|---|
| 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 | }
|
|---|
| 672 | }
|
|---|
| 673 | if (hwnddrive != hwnddir && pszPath && isalpha(*pszPath)
|
|---|
| 674 | && pszPath[1] == ':') {
|
|---|
| 675 | *szDrive = toupper(*pszPath);
|
|---|
| 676 | WinSetWindowText(hwnddrive, szDrive);
|
|---|
| 677 | }
|
|---|
| 678 | }
|
|---|
| 679 |
|
|---|
| 680 | if (hwnddir) {
|
|---|
| 681 | // Fill directory listbox
|
|---|
| 682 | sprintf(szTemp,
|
|---|
| 683 | "%s%s*",
|
|---|
| 684 | pszPath, (pszPath[strlen(pszPath) - 1] == '\\') ? "" : "\\");
|
|---|
| 685 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 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)) {
|
|---|
| 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 | }
|
|---|
| 706 | }
|
|---|
| 707 | ulSearchCount = 1;
|
|---|
| 708 | } while (!DosFindNext(hDir,
|
|---|
| 709 | &findbuf, sizeof(FILEFINDBUF3), &ulSearchCount));
|
|---|
| 710 | DosFindClose(hDir);
|
|---|
| 711 | }
|
|---|
| 712 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 713 | }
|
|---|
| 714 | }
|
|---|
| 715 |
|
|---|
| 716 | MRESULT EXPENTRY TextSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 717 | {
|
|---|
| 718 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 719 |
|
|---|
| 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);
|
|---|
| 727 | }
|
|---|
| 728 | break;
|
|---|
| 729 | }
|
|---|
| 730 | return oldproc(hwnd, msg, mp1, mp2);
|
|---|
| 731 | }
|
|---|
| 732 |
|
|---|
| 733 | MRESULT EXPENTRY WalkDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 734 | {
|
|---|
| 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];
|
|---|
| 740 |
|
|---|
| 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);
|
|---|
| 757 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) wa);
|
|---|
| 758 | wa->szReturnPath = (CHAR *)mp2;
|
|---|
| 759 | {
|
|---|
| 760 | PFNWP oldproc;
|
|---|
| 761 |
|
|---|
| 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 | }
|
|---|
| 774 | {
|
|---|
| 775 | SWP swp;
|
|---|
| 776 | ULONG size = sizeof(SWP);
|
|---|
| 777 |
|
|---|
| 778 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp, &size);
|
|---|
| 779 | WinSetWindowPos(hwnd,
|
|---|
| 780 | HWND_TOP,
|
|---|
| 781 | swp.x,
|
|---|
| 782 | swp.y,
|
|---|
| 783 | swp.cx,
|
|---|
| 784 | swp.cy,
|
|---|
| 785 | swp.fl);
|
|---|
| 786 | }
|
|---|
| 787 | PosOverOkay(hwnd);
|
|---|
| 788 | if (msg == UM_SETUP2)
|
|---|
| 789 | wa->nounwriteable = FALSE;
|
|---|
| 790 | else
|
|---|
| 791 | wa->nounwriteable = TRUE;
|
|---|
| 792 | if (!*wa->szReturnPath)
|
|---|
| 793 | strcpy(wa->szCurrentPath, pFM2SaveDirectory);
|
|---|
| 794 | else {
|
|---|
| 795 | strcpy(wa->szCurrentPath, wa->szReturnPath);
|
|---|
| 796 | MakeFullName(wa->szCurrentPath);
|
|---|
| 797 | }
|
|---|
| 798 | if (wa->nounwriteable &&
|
|---|
| 799 | (driveflags[toupper(*wa->szCurrentPath) - 'A'] &
|
|---|
| 800 | DRIVE_NOTWRITEABLE)) {
|
|---|
| 801 |
|
|---|
| 802 | ULONG bd;
|
|---|
| 803 |
|
|---|
| 804 | strcpy(wa->szCurrentPath, "C:\\");
|
|---|
| 805 | if (DosQuerySysInfo(QSV_BOOT_DRIVE,
|
|---|
| 806 | QSV_BOOT_DRIVE,
|
|---|
| 807 | (PVOID) & bd, (ULONG) sizeof(ULONG)))
|
|---|
| 808 | bd = 3;
|
|---|
| 809 | *wa->szCurrentPath = (CHAR) bd + '@';
|
|---|
| 810 | }
|
|---|
| 811 | WinSendDlgItemMsg(hwnd,
|
|---|
| 812 | WALK_PATH,
|
|---|
| 813 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
|---|
| 814 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 815 | if (!loadedudirs)
|
|---|
| 816 | load_udirs();
|
|---|
| 817 | { /* fill user list box */
|
|---|
| 818 | ULONG ulDriveNum, ulDriveMap;
|
|---|
| 819 | ULONG ulSearchCount;
|
|---|
| 820 | FILEFINDBUF3 findbuf;
|
|---|
| 821 | HDIR hDir;
|
|---|
| 822 | APIRET rc;
|
|---|
| 823 | LINKDIRS *info, *temp;
|
|---|
| 824 |
|
|---|
| 825 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 826 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
|---|
| 827 | info = udirhead;
|
|---|
| 828 | while (info) {
|
|---|
| 829 | if (IsFullName(info->path) &&
|
|---|
| 830 | !(driveflags[toupper(*info->path) - 'A'] &
|
|---|
| 831 | (DRIVE_IGNORE | DRIVE_INVALID))) {
|
|---|
| 832 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 833 | hDir = HDIR_CREATE;
|
|---|
| 834 | ulSearchCount = 1;
|
|---|
| 835 | if (!IsRoot(info->path))
|
|---|
| 836 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
|
|---|
| 837 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 838 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 839 | &findbuf, sizeof(FILEFINDBUF3),
|
|---|
| 840 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 841 | else {
|
|---|
| 842 | rc = 0;
|
|---|
| 843 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 844 | }
|
|---|
| 845 | if (!rc) {
|
|---|
| 846 | if (!IsRoot(info->path))
|
|---|
| 847 | DosFindClose(hDir);
|
|---|
| 848 | if (findbuf.attrFile & FILE_DIRECTORY)
|
|---|
| 849 | WinSendDlgItemMsg(hwnd, WALK_USERLIST, LM_INSERTITEM,
|
|---|
| 850 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
|---|
| 851 | MPFROMP(info->path));
|
|---|
| 852 | else {
|
|---|
| 853 | temp = info->next;
|
|---|
| 854 | remove_udir(info->path);
|
|---|
| 855 | info = temp;
|
|---|
| 856 | continue;
|
|---|
| 857 | }
|
|---|
| 858 | }
|
|---|
| 859 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
|---|
| 860 | temp = info->next;
|
|---|
| 861 | remove_udir(info->path);
|
|---|
| 862 | info = temp;
|
|---|
| 863 | continue;
|
|---|
| 864 | }
|
|---|
| 865 | }
|
|---|
| 866 | info = info->next;
|
|---|
| 867 | }
|
|---|
| 868 | info = ldirhead;
|
|---|
| 869 | while (info) {
|
|---|
| 870 | if (IsFullName(info->path) &&
|
|---|
| 871 | !(driveflags[toupper(*info->path) - 'A'] &
|
|---|
| 872 | (DRIVE_IGNORE | DRIVE_INVALID))) {
|
|---|
| 873 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 874 | hDir = HDIR_CREATE;
|
|---|
| 875 | ulSearchCount = 1;
|
|---|
| 876 | if (!IsRoot(info->path))
|
|---|
| 877 | rc = DosFindFirst(info->path, &hDir, FILE_DIRECTORY |
|
|---|
| 878 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 879 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 880 | &findbuf, sizeof(FILEFINDBUF3),
|
|---|
| 881 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 882 | else {
|
|---|
| 883 | rc = 0;
|
|---|
| 884 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 885 | }
|
|---|
| 886 | if (!rc) {
|
|---|
| 887 | if (!IsRoot(info->path))
|
|---|
| 888 | DosFindClose(hDir);
|
|---|
| 889 | if (findbuf.attrFile & FILE_DIRECTORY)
|
|---|
| 890 | WinSendDlgItemMsg(hwnd, WALK_RECENT, LM_INSERTITEM,
|
|---|
| 891 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
|---|
| 892 | MPFROMP(info->path));
|
|---|
| 893 | else {
|
|---|
| 894 | temp = info->next;
|
|---|
| 895 | remove_ldir(info->path);
|
|---|
| 896 | info = temp;
|
|---|
| 897 | continue;
|
|---|
| 898 | }
|
|---|
| 899 | WinSetDlgItemText(hwnd, WALK_RECENT,
|
|---|
| 900 | GetPString(IDS_WALKRECENTDIRSTEXT));
|
|---|
| 901 | }
|
|---|
| 902 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
|---|
| 903 | temp = info->next;
|
|---|
| 904 | remove_ldir(info->path);
|
|---|
| 905 | info = temp;
|
|---|
| 906 | continue;
|
|---|
| 907 | }
|
|---|
| 908 | }
|
|---|
| 909 | info = info->next;
|
|---|
| 910 | }
|
|---|
| 911 | }
|
|---|
| 912 | FillPathListBox(hwnd,
|
|---|
| 913 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 914 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 915 | wa->szCurrentPath, wa->nounwriteable);
|
|---|
| 916 | if (!PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID))
|
|---|
| 917 | okay = TRUE;
|
|---|
| 918 | {
|
|---|
| 919 | MRESULT ret;
|
|---|
| 920 |
|
|---|
| 921 | ret = WinDefDlgProc(hwnd, WM_INITDLG, mp1, mp2);
|
|---|
| 922 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
|---|
| 923 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
|---|
| 924 | return ret;
|
|---|
| 925 | }
|
|---|
| 926 |
|
|---|
| 927 | case UM_SETUP4:
|
|---|
| 928 | okay = TRUE;
|
|---|
| 929 | return 0;
|
|---|
| 930 |
|
|---|
| 931 | case WM_ADJUSTWINDOWPOS:
|
|---|
| 932 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
|---|
| 933 | break;
|
|---|
| 934 |
|
|---|
| 935 | case UM_SETDIR:
|
|---|
| 936 | PaintRecessedWindow(WinWindowFromID(hwnd, WALK_HELP), (HPS) 0, FALSE,
|
|---|
| 937 | TRUE);
|
|---|
| 938 | return 0;
|
|---|
| 939 |
|
|---|
| 940 | case WM_PRESPARAMCHANGED:
|
|---|
| 941 | {
|
|---|
| 942 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
|---|
| 943 |
|
|---|
| 944 | cbRetLen = WinQueryPresParam(hwnd, (ULONG) mp1, 0, &AttrFound,
|
|---|
| 945 | (ULONG) sizeof(AttrValue), &AttrValue, 0);
|
|---|
| 946 | if (cbRetLen) {
|
|---|
| 947 | switch (AttrFound) {
|
|---|
| 948 | case PP_FONTNAMESIZE:
|
|---|
| 949 | PrfWriteProfileData(fmprof,
|
|---|
| 950 | appname,
|
|---|
| 951 | "WalkFont", (PVOID) AttrValue, cbRetLen);
|
|---|
| 952 | *WalkFont = 0;
|
|---|
| 953 | WalkFontSize = sizeof(WalkFont);
|
|---|
| 954 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
|---|
| 955 | break;
|
|---|
| 956 | }
|
|---|
| 957 | }
|
|---|
| 958 | }
|
|---|
| 959 | break;
|
|---|
| 960 |
|
|---|
| 961 | case UM_SETUP3:
|
|---|
| 962 | save_udirs();
|
|---|
| 963 | if (hwndMain)
|
|---|
| 964 | PostMsg(hwndMain, UM_FILLUSERLIST, MPVOID, MPVOID);
|
|---|
| 965 | return 0;
|
|---|
| 966 |
|
|---|
| 967 | case UM_SETUP:
|
|---|
| 968 | {
|
|---|
| 969 | INT x;
|
|---|
| 970 | USHORT id[] = { WALK_PATH, WALK_DIRLIST, WALK_USERLIST,
|
|---|
| 971 | WALK_RECENT, 0
|
|---|
| 972 | };
|
|---|
| 973 |
|
|---|
| 974 | if (*WalkFont ||
|
|---|
| 975 | (PrfQueryProfileData(fmprof,
|
|---|
| 976 | appname,
|
|---|
| 977 | "WalkFont",
|
|---|
| 978 | (PVOID) WalkFont,
|
|---|
| 979 | &WalkFontSize) && WalkFontSize)) {
|
|---|
| 980 | for (x = 0; id[x]; x++)
|
|---|
| 981 | WinSetPresParam(WinWindowFromID(hwnd, id[x]),
|
|---|
| 982 | PP_FONTNAMESIZE, WalkFontSize, (PVOID) WalkFont);
|
|---|
| 983 | }
|
|---|
| 984 | }
|
|---|
| 985 | return 0;
|
|---|
| 986 |
|
|---|
| 987 | case UM_CONTROL:
|
|---|
| 988 | case WM_CONTROL:
|
|---|
| 989 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 990 | if (SHORT1FROMMP(mp1) == WALK_DRIVELIST ||
|
|---|
| 991 | SHORT1FROMMP(mp1) == WALK_DIRLIST ||
|
|---|
| 992 | SHORT1FROMMP(mp1) == WALK_USERLIST ||
|
|---|
| 993 | SHORT1FROMMP(mp1) == WALK_RECENT) {
|
|---|
| 994 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 995 | SHORT1FROMMP(mp1),
|
|---|
| 996 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
|---|
| 997 | *szBuffer = 0;
|
|---|
| 998 | if (sSelect >= 0)
|
|---|
| 999 | WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
|
|---|
| 1000 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
|---|
| 1001 | MPFROMP(szBuffer));
|
|---|
| 1002 | }
|
|---|
| 1003 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1004 | case WALK_PATH:
|
|---|
| 1005 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
|---|
| 1006 | WinSetDlgItemText(hwnd, WALK_HELP, GetPString(IDS_WALKCURRDIRTEXT));
|
|---|
| 1007 | else if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
|---|
| 1008 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1009 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
|---|
| 1010 | break;
|
|---|
| 1011 |
|
|---|
| 1012 | case WALK_RECENT:
|
|---|
| 1013 | if (okay && SHORT2FROMMP(mp1) == CBN_LBSELECT) {
|
|---|
| 1014 |
|
|---|
| 1015 | ULONG ulSearchCount;
|
|---|
| 1016 | FILEFINDBUF3 findbuf;
|
|---|
| 1017 | HDIR hDir;
|
|---|
| 1018 | APIRET rc;
|
|---|
| 1019 |
|
|---|
| 1020 | // *szBuffer = 0;
|
|---|
| 1021 | // WinQueryDlgItemText(hwnd,WALK_RECENT,CCHMAXPATH,szBuffer);
|
|---|
| 1022 | if (!*szBuffer)
|
|---|
| 1023 | break;
|
|---|
| 1024 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1025 | hDir = HDIR_CREATE;
|
|---|
| 1026 | ulSearchCount = 1;
|
|---|
| 1027 | if (!IsRoot(szBuffer)) {
|
|---|
| 1028 | rc = DosFindFirst(szBuffer, &hDir, FILE_DIRECTORY |
|
|---|
| 1029 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1030 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1031 | &findbuf, sizeof(FILEFINDBUF3),
|
|---|
| 1032 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1033 | if (!rc)
|
|---|
| 1034 | DosFindClose(hDir);
|
|---|
| 1035 | }
|
|---|
| 1036 | else {
|
|---|
| 1037 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1038 | rc = 0;
|
|---|
| 1039 | }
|
|---|
| 1040 | if (rc)
|
|---|
| 1041 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
|---|
| 1042 | "xDosFindFirst");
|
|---|
| 1043 | else if (~findbuf.attrFile & FILE_DIRECTORY)
|
|---|
| 1044 | Runtime_Error(pszSrcFile, __LINE__, "not a directory");
|
|---|
| 1045 | else {
|
|---|
| 1046 | strcpy(wa->szCurrentPath, szBuffer);
|
|---|
| 1047 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1048 | WinSetDlgItemText(hwnd, WALK_RECENT, wa->szCurrentPath);
|
|---|
| 1049 | FillPathListBox(hwnd,
|
|---|
| 1050 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1051 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1052 | wa->szCurrentPath, FALSE);
|
|---|
| 1053 | }
|
|---|
| 1054 | }
|
|---|
| 1055 | else if (SHORT2FROMMP(mp1) == CBN_ENTER)
|
|---|
| 1056 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
|---|
| 1057 | else if (SHORT2FROMMP(mp1) == CBN_SHOWLIST)
|
|---|
| 1058 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1059 | GetPString(IDS_WALKRECENTDIRSHELPTEXT));
|
|---|
| 1060 | break;
|
|---|
| 1061 |
|
|---|
| 1062 | case WALK_USERLIST:
|
|---|
| 1063 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_SELECT) {
|
|---|
| 1064 |
|
|---|
| 1065 | ULONG ulSearchCount;
|
|---|
| 1066 | FILEFINDBUF3 findbuf;
|
|---|
| 1067 | HDIR hDir;
|
|---|
| 1068 | APIRET rc;
|
|---|
| 1069 |
|
|---|
| 1070 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1071 | hDir = HDIR_CREATE;
|
|---|
| 1072 | ulSearchCount = 1;
|
|---|
| 1073 | if (!IsRoot(szBuffer)) {
|
|---|
| 1074 | rc = DosFindFirst(szBuffer,
|
|---|
| 1075 | &hDir,
|
|---|
| 1076 | FILE_DIRECTORY |
|
|---|
| 1077 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1078 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1079 | &findbuf,
|
|---|
| 1080 | sizeof(FILEFINDBUF3),
|
|---|
| 1081 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1082 | if (!rc)
|
|---|
| 1083 | DosFindClose(hDir);
|
|---|
| 1084 | }
|
|---|
| 1085 | else {
|
|---|
| 1086 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1087 | rc = 0;
|
|---|
| 1088 | }
|
|---|
| 1089 | if (rc)
|
|---|
| 1090 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
|---|
| 1091 | "xDosFindFirst");
|
|---|
| 1092 | else if (~findbuf.attrFile & FILE_DIRECTORY)
|
|---|
| 1093 | Runtime_Error(pszSrcFile, __LINE__, "not a directory");
|
|---|
| 1094 | else {
|
|---|
| 1095 | strcpy(wa->szCurrentPath, szBuffer);
|
|---|
| 1096 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1097 | FillPathListBox(hwnd,
|
|---|
| 1098 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1099 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1100 | wa->szCurrentPath, FALSE);
|
|---|
| 1101 | }
|
|---|
| 1102 | }
|
|---|
| 1103 | else if (SHORT2FROMMP(mp1) == LN_ENTER)
|
|---|
| 1104 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
|---|
| 1105 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
|---|
| 1106 | WinSetDlgItemText(hwnd,
|
|---|
| 1107 | WALK_HELP, GetPString(IDS_WALKUSERDIRSHELPTEXT));
|
|---|
| 1108 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
|---|
| 1109 | WinSetDlgItemText(hwnd,
|
|---|
| 1110 | WALK_HELP, GetPString(IDS_WALKDEFAULTHELPTEXT));
|
|---|
| 1111 | break;
|
|---|
| 1112 |
|
|---|
| 1113 | case WALK_DRIVELIST:
|
|---|
| 1114 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1115 |
|
|---|
| 1116 | ULONG ulDirLen = CCHMAXPATH;
|
|---|
| 1117 | APIRET rc;
|
|---|
| 1118 |
|
|---|
| 1119 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
|---|
| 1120 | if (!rc) {
|
|---|
| 1121 | strcpy(wa->szCurrentPath, "C:\\");
|
|---|
| 1122 | *wa->szCurrentPath = toupper(*szBuffer);
|
|---|
| 1123 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1124 | FillPathListBox(hwnd,
|
|---|
| 1125 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1126 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1127 | wa->szCurrentPath, FALSE);
|
|---|
| 1128 | }
|
|---|
| 1129 | }
|
|---|
| 1130 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
|---|
| 1131 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1132 | GetPString(IDS_WALKDRIVELISTHELPTEXT));
|
|---|
| 1133 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
|---|
| 1134 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1135 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
|---|
| 1136 | break;
|
|---|
| 1137 |
|
|---|
| 1138 | case WALK_DIRLIST:
|
|---|
| 1139 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1140 |
|
|---|
| 1141 | ULONG ulSearchCount;
|
|---|
| 1142 | FILEFINDBUF3 findbuf;
|
|---|
| 1143 | HDIR hDir;
|
|---|
| 1144 | APIRET rc;
|
|---|
| 1145 |
|
|---|
| 1146 | bstrip(szBuffer);
|
|---|
| 1147 | if (*szBuffer) {
|
|---|
| 1148 | strcpy(szBuff, wa->szCurrentPath);
|
|---|
| 1149 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
|---|
| 1150 | strcat(szBuff, "\\");
|
|---|
| 1151 | strcat(szBuff, szBuffer);
|
|---|
| 1152 | MakeFullName(szBuff);
|
|---|
| 1153 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1154 | hDir = HDIR_CREATE;
|
|---|
| 1155 | ulSearchCount = 1;
|
|---|
| 1156 | if (!IsRoot(szBuff)) {
|
|---|
| 1157 | rc = DosFindFirst(szBuff,
|
|---|
| 1158 | &hDir,
|
|---|
| 1159 | FILE_DIRECTORY |
|
|---|
| 1160 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1161 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1162 | &findbuf,
|
|---|
| 1163 | sizeof(FILEFINDBUF3),
|
|---|
| 1164 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1165 | if (!rc)
|
|---|
| 1166 | DosFindClose(hDir);
|
|---|
| 1167 | }
|
|---|
| 1168 | else {
|
|---|
| 1169 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1170 | rc = 0;
|
|---|
| 1171 | }
|
|---|
| 1172 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
|---|
| 1173 | strcpy(wa->szCurrentPath, szBuff);
|
|---|
| 1174 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1175 | FillPathListBox(hwnd,
|
|---|
| 1176 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1177 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1178 | wa->szCurrentPath, FALSE);
|
|---|
| 1179 | }
|
|---|
| 1180 | }
|
|---|
| 1181 | }
|
|---|
| 1182 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
|---|
| 1183 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1184 | GetPString(IDS_WALKDIRLISTHELPTEXT));
|
|---|
| 1185 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
|---|
| 1186 | WinSetDlgItemText(hwnd, WALK_HELP,
|
|---|
| 1187 | GetPString(IDS_WALKDEFAULTHELPTEXT));
|
|---|
| 1188 | break;
|
|---|
| 1189 | }
|
|---|
| 1190 | return 0;
|
|---|
| 1191 |
|
|---|
| 1192 | case WM_COMMAND:
|
|---|
| 1193 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 1194 | if (!wa)
|
|---|
| 1195 | WinDismissDlg(hwnd, 0);
|
|---|
| 1196 | *szBuff = 0;
|
|---|
| 1197 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1198 | bstrip(szBuff);
|
|---|
| 1199 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1200 | *p = '\\';
|
|---|
| 1201 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
|---|
| 1202 | szBuff[strlen(szBuff) - 1] = 0;
|
|---|
| 1203 | MakeFullName(szBuff);
|
|---|
| 1204 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
|---|
| 1205 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1206 | QW_OWNER), hwnd, szBuff, 0))
|
|---|
| 1207 | strcpy(wa->szCurrentPath, szBuff);
|
|---|
| 1208 | else
|
|---|
| 1209 | return 0;
|
|---|
| 1210 | }
|
|---|
| 1211 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath);
|
|---|
| 1212 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 1213 | case WALK_ADD:
|
|---|
| 1214 | *szBuff = 0;
|
|---|
| 1215 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1216 | bstrip(szBuff);
|
|---|
| 1217 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1218 | *p = '\\';
|
|---|
| 1219 | if (*szBuff && !IsFile(szBuff)) {
|
|---|
| 1220 | MakeFullName(szBuff);
|
|---|
| 1221 | add_udir(TRUE, szBuff);
|
|---|
| 1222 | if (fUdirsChanged) {
|
|---|
| 1223 | WinSendDlgItemMsg(hwnd,
|
|---|
| 1224 | WALK_USERLIST,
|
|---|
| 1225 | LM_INSERTITEM,
|
|---|
| 1226 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
|---|
| 1227 | MPFROMP(szBuff));
|
|---|
| 1228 | wa->changed = 1;
|
|---|
| 1229 | }
|
|---|
| 1230 | }
|
|---|
| 1231 | break;
|
|---|
| 1232 |
|
|---|
| 1233 | case WALK_DELETE:
|
|---|
| 1234 | *szBuff = 0;
|
|---|
| 1235 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1236 | bstrip(szBuff);
|
|---|
| 1237 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1238 | *p = '\\';
|
|---|
| 1239 | if (*szBuff && !IsFile(szBuff)) {
|
|---|
| 1240 | MakeFullName(szBuff);
|
|---|
| 1241 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 1242 | WALK_USERLIST,
|
|---|
| 1243 | LM_SEARCHSTRING,
|
|---|
| 1244 | MPFROM2SHORT(0, LIT_FIRST),
|
|---|
| 1245 | MPFROMP(szBuff));
|
|---|
| 1246 | if (sSelect >= 0) {
|
|---|
| 1247 | WinSendDlgItemMsg(hwnd,
|
|---|
| 1248 | WALK_USERLIST,
|
|---|
| 1249 | LM_DELETEITEM, MPFROM2SHORT(sSelect, 0), MPVOID);
|
|---|
| 1250 | remove_udir(szBuff);
|
|---|
| 1251 | wa->changed = 1;
|
|---|
| 1252 | }
|
|---|
| 1253 | }
|
|---|
| 1254 | break;
|
|---|
| 1255 |
|
|---|
| 1256 | case DID_OK:
|
|---|
| 1257 | if (*wa->szCurrentPath) {
|
|---|
| 1258 | strcpy(wa->szReturnPath, wa->szCurrentPath);
|
|---|
| 1259 | MakeValidDir(wa->szReturnPath);
|
|---|
| 1260 | if (fAutoAddAllDirs)
|
|---|
| 1261 | add_udir(FALSE, wa->szReturnPath);
|
|---|
| 1262 | if (fChangeTarget) {
|
|---|
| 1263 | strcpy(targetdir, wa->szReturnPath);
|
|---|
| 1264 | PrfWriteProfileString(fmprof, appname, "Targetdir", targetdir);
|
|---|
| 1265 | }
|
|---|
| 1266 | }
|
|---|
| 1267 | {
|
|---|
| 1268 | SWP swp;
|
|---|
| 1269 | ULONG size = sizeof(SWP);
|
|---|
| 1270 |
|
|---|
| 1271 | WinQueryWindowPos(hwnd, &swp);
|
|---|
| 1272 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
|---|
| 1273 | size);
|
|---|
| 1274 | }
|
|---|
| 1275 | if (wa->changed)
|
|---|
| 1276 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
|---|
| 1277 | WinDismissDlg(hwnd, 1);
|
|---|
| 1278 | break;
|
|---|
| 1279 |
|
|---|
| 1280 | case IDM_HELP:
|
|---|
| 1281 | if (hwndHelp)
|
|---|
| 1282 | WinSendMsg(hwndHelp,
|
|---|
| 1283 | HM_DISPLAY_HELP,
|
|---|
| 1284 | MPFROM2SHORT(HELP_WALKEM, 0), MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 1285 | break;
|
|---|
| 1286 |
|
|---|
| 1287 | case DID_CANCEL:
|
|---|
| 1288 | {
|
|---|
| 1289 | SWP swp;
|
|---|
| 1290 | ULONG size = sizeof(SWP);
|
|---|
| 1291 |
|
|---|
| 1292 | WinQueryWindowPos(hwnd, &swp);
|
|---|
| 1293 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
|---|
| 1294 | size);
|
|---|
| 1295 | }
|
|---|
| 1296 | if (wa->changed)
|
|---|
| 1297 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
|---|
| 1298 | free(wa);
|
|---|
| 1299 | WinDismissDlg(hwnd, 0);
|
|---|
| 1300 | break;
|
|---|
| 1301 | }
|
|---|
| 1302 | return 0;
|
|---|
| 1303 |
|
|---|
| 1304 | case WM_CLOSE:
|
|---|
| 1305 | break;
|
|---|
| 1306 | }
|
|---|
| 1307 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1308 | }
|
|---|
| 1309 |
|
|---|
| 1310 | MRESULT EXPENTRY WalkAllDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1311 | {
|
|---|
| 1312 | switch (msg) {
|
|---|
| 1313 | case WM_INITDLG:
|
|---|
| 1314 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1315 | }
|
|---|
| 1316 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1317 | }
|
|---|
| 1318 |
|
|---|
| 1319 | MRESULT EXPENTRY WalkCopyDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1320 | {
|
|---|
| 1321 | switch (msg) {
|
|---|
| 1322 | case WM_INITDLG:
|
|---|
| 1323 | WinSetWindowText(hwnd, GetPString(IDS_WALKCOPYDLGTEXT));
|
|---|
| 1324 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1325 | }
|
|---|
| 1326 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1327 | }
|
|---|
| 1328 |
|
|---|
| 1329 | MRESULT EXPENTRY WalkMoveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1330 | {
|
|---|
| 1331 | switch (msg) {
|
|---|
| 1332 | case WM_INITDLG:
|
|---|
| 1333 | WinSetWindowText(hwnd, GetPString(IDS_WALKMOVEDLGTEXT));
|
|---|
| 1334 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1335 | }
|
|---|
| 1336 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1337 | }
|
|---|
| 1338 |
|
|---|
| 1339 | MRESULT EXPENTRY WalkExtractDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 1340 | MPARAM mp2)
|
|---|
| 1341 | {
|
|---|
| 1342 | switch (msg) {
|
|---|
| 1343 | case WM_INITDLG:
|
|---|
| 1344 | WinSetWindowText(hwnd, GetPString(IDS_WALKEXTRACTDLGTEXT));
|
|---|
| 1345 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1346 | }
|
|---|
| 1347 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1348 | }
|
|---|
| 1349 |
|
|---|
| 1350 | MRESULT EXPENTRY WalkTargetDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
|---|
| 1351 | MPARAM mp2)
|
|---|
| 1352 | {
|
|---|
| 1353 | switch (msg) {
|
|---|
| 1354 | case WM_INITDLG:
|
|---|
| 1355 | {
|
|---|
| 1356 | char s[CCHMAXPATH + 32];
|
|---|
| 1357 |
|
|---|
| 1358 | sprintf(s,
|
|---|
| 1359 | GetPString(IDS_WALKTARGETDLGTEXT),
|
|---|
| 1360 | (*targetdir) ?
|
|---|
| 1361 | NullStr :
|
|---|
| 1362 | " (",
|
|---|
| 1363 | (*targetdir) ?
|
|---|
| 1364 | NullStr : GetPString(IDS_NONE), (*targetdir) ? NullStr : ")");
|
|---|
| 1365 | WinSetWindowText(hwnd, s);
|
|---|
| 1366 | }
|
|---|
| 1367 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
|---|
| 1368 | }
|
|---|
| 1369 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 1370 | }
|
|---|
| 1371 |
|
|---|
| 1372 | MRESULT EXPENTRY WalkTwoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 1373 | {
|
|---|
| 1374 | WALK2 *wa;
|
|---|
| 1375 | CHAR szBuff[CCHMAXPATH + 1], szBuffer[CCHMAXPATH + 1], *p;
|
|---|
| 1376 | SHORT sSelect;
|
|---|
| 1377 | static BOOL okay; /* avoid combobox selecting as filled */
|
|---|
| 1378 |
|
|---|
| 1379 | switch (msg) {
|
|---|
| 1380 | case UM_SETUP2:
|
|---|
| 1381 | case WM_INITDLG:
|
|---|
| 1382 | okay = FALSE;
|
|---|
| 1383 | if (!mp2) {
|
|---|
| 1384 | WinDismissDlg(hwnd, 0);
|
|---|
| 1385 | break;
|
|---|
| 1386 | }
|
|---|
| 1387 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
|---|
| 1388 | wa = mp2;
|
|---|
| 1389 | {
|
|---|
| 1390 | PFNWP oldproc;
|
|---|
| 1391 |
|
|---|
| 1392 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK_PATH),
|
|---|
| 1393 | (PFNWP) TextSubProc);
|
|---|
| 1394 | if (oldproc)
|
|---|
| 1395 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK_PATH),
|
|---|
| 1396 | QWL_USER, (PVOID) oldproc);
|
|---|
| 1397 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK2_PATH),
|
|---|
| 1398 | (PFNWP) TextSubProc);
|
|---|
| 1399 | if (oldproc)
|
|---|
| 1400 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK2_PATH),
|
|---|
| 1401 | QWL_USER, (PVOID) oldproc);
|
|---|
| 1402 | }
|
|---|
| 1403 | {
|
|---|
| 1404 | SWP swp;
|
|---|
| 1405 | ULONG size = sizeof(SWP);
|
|---|
| 1406 |
|
|---|
| 1407 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp, &size);
|
|---|
| 1408 | WinSetWindowPos(hwnd,
|
|---|
| 1409 | HWND_TOP,
|
|---|
| 1410 | swp.x,
|
|---|
| 1411 | swp.y,
|
|---|
| 1412 | swp.cx,
|
|---|
| 1413 | swp.cy,
|
|---|
| 1414 | swp.fl);
|
|---|
| 1415 | }
|
|---|
| 1416 | if (!*wa->szCurrentPath1)
|
|---|
| 1417 | strcpy(wa->szCurrentPath1, pFM2SaveDirectory);
|
|---|
| 1418 | MakeFullName(wa->szCurrentPath1);
|
|---|
| 1419 | if (!*wa->szCurrentPath2)
|
|---|
| 1420 | strcpy(wa->szCurrentPath2, pFM2SaveDirectory);
|
|---|
| 1421 | MakeFullName(wa->szCurrentPath2);
|
|---|
| 1422 | WinSendDlgItemMsg(hwnd,
|
|---|
| 1423 | WALK_PATH,
|
|---|
| 1424 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
|---|
| 1425 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
|---|
| 1426 | WinSendDlgItemMsg(hwnd, WALK2_PATH, EM_SETTEXTLIMIT,
|
|---|
| 1427 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
|---|
| 1428 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
|---|
| 1429 | FillPathListBox(hwnd,
|
|---|
| 1430 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1431 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1432 | wa->szCurrentPath1, FALSE);
|
|---|
| 1433 | FillPathListBox(hwnd,
|
|---|
| 1434 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
|---|
| 1435 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
|---|
| 1436 | wa->szCurrentPath2, FALSE);
|
|---|
| 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) - '@', &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 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
|---|
| 1542 | strcat(szBuff, "\\");
|
|---|
| 1543 | strcat(szBuff, szBuffer);
|
|---|
| 1544 | MakeFullName(szBuff);
|
|---|
| 1545 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1546 | hDir = HDIR_CREATE;
|
|---|
| 1547 | ulSearchCount = 1;
|
|---|
| 1548 | if (!IsRoot(szBuff)) {
|
|---|
| 1549 | rc = DosFindFirst(szBuff,
|
|---|
| 1550 | &hDir,
|
|---|
| 1551 | FILE_DIRECTORY |
|
|---|
| 1552 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1553 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1554 | &findbuf,
|
|---|
| 1555 | sizeof(FILEFINDBUF3),
|
|---|
| 1556 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1557 | if (!rc)
|
|---|
| 1558 | DosFindClose(hDir);
|
|---|
| 1559 | }
|
|---|
| 1560 | else {
|
|---|
| 1561 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1562 | rc = 0;
|
|---|
| 1563 | }
|
|---|
| 1564 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
|---|
| 1565 | strcpy(wa->szCurrentPath1, szBuff);
|
|---|
| 1566 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
|---|
| 1567 | FillPathListBox(hwnd,
|
|---|
| 1568 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
|---|
| 1569 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
|---|
| 1570 | wa->szCurrentPath1, FALSE);
|
|---|
| 1571 | }
|
|---|
| 1572 | }
|
|---|
| 1573 | }
|
|---|
| 1574 | break;
|
|---|
| 1575 |
|
|---|
| 1576 | case WALK2_DRIVELIST:
|
|---|
| 1577 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1578 |
|
|---|
| 1579 | ULONG ulDirLen = CCHMAXPATH;
|
|---|
| 1580 | APIRET rc;
|
|---|
| 1581 |
|
|---|
| 1582 | rc = DosQCurDir(toupper(*szBuffer) - '@', &szBuff[3], &ulDirLen);
|
|---|
| 1583 | if (!rc) {
|
|---|
| 1584 | strcpy(wa->szCurrentPath2, "C:\\");
|
|---|
| 1585 | *wa->szCurrentPath2 = toupper(*szBuffer);
|
|---|
| 1586 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
|---|
| 1587 | FillPathListBox(hwnd,
|
|---|
| 1588 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
|---|
| 1589 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
|---|
| 1590 | wa->szCurrentPath2, FALSE);
|
|---|
| 1591 | }
|
|---|
| 1592 | }
|
|---|
| 1593 | break;
|
|---|
| 1594 |
|
|---|
| 1595 | case WALK2_DIRLIST:
|
|---|
| 1596 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
|---|
| 1597 |
|
|---|
| 1598 | ULONG ulSearchCount;
|
|---|
| 1599 | FILEFINDBUF3 findbuf;
|
|---|
| 1600 | HDIR hDir;
|
|---|
| 1601 | APIRET rc;
|
|---|
| 1602 |
|
|---|
| 1603 | bstrip(szBuffer);
|
|---|
| 1604 | if (*szBuffer) {
|
|---|
| 1605 | strcpy(szBuff, wa->szCurrentPath2);
|
|---|
| 1606 | if (szBuff[strlen(szBuff) - 1] != '\\')
|
|---|
| 1607 | strcat(szBuff, "\\");
|
|---|
| 1608 | strcat(szBuff, szBuffer);
|
|---|
| 1609 | MakeFullName(szBuff);
|
|---|
| 1610 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 1611 | hDir = HDIR_CREATE;
|
|---|
| 1612 | ulSearchCount = 1;
|
|---|
| 1613 | if (!IsRoot(szBuff)) {
|
|---|
| 1614 | rc = DosFindFirst(szBuff,
|
|---|
| 1615 | &hDir,
|
|---|
| 1616 | FILE_DIRECTORY |
|
|---|
| 1617 | MUST_HAVE_DIRECTORY | FILE_READONLY |
|
|---|
| 1618 | FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN,
|
|---|
| 1619 | &findbuf,
|
|---|
| 1620 | sizeof(FILEFINDBUF3),
|
|---|
| 1621 | &ulSearchCount, FIL_STANDARD);
|
|---|
| 1622 | if (!rc)
|
|---|
| 1623 | DosFindClose(hDir);
|
|---|
| 1624 | }
|
|---|
| 1625 | else {
|
|---|
| 1626 | findbuf.attrFile = FILE_DIRECTORY;
|
|---|
| 1627 | rc = 0;
|
|---|
| 1628 | }
|
|---|
| 1629 | if (!rc && (findbuf.attrFile & FILE_DIRECTORY)) {
|
|---|
| 1630 | strcpy(wa->szCurrentPath2, szBuff);
|
|---|
| 1631 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
|---|
| 1632 | FillPathListBox(hwnd,
|
|---|
| 1633 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
|---|
| 1634 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
|---|
| 1635 | wa->szCurrentPath2, FALSE);
|
|---|
| 1636 | }
|
|---|
| 1637 | }
|
|---|
| 1638 | }
|
|---|
| 1639 | break;
|
|---|
| 1640 | }
|
|---|
| 1641 | return 0;
|
|---|
| 1642 |
|
|---|
| 1643 | case WM_COMMAND:
|
|---|
| 1644 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 1645 | if (!wa)
|
|---|
| 1646 | WinDismissDlg(hwnd, 0);
|
|---|
| 1647 | *szBuff = 0;
|
|---|
| 1648 | WinQueryDlgItemText(hwnd, WALK_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1649 | bstrip(szBuff);
|
|---|
| 1650 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1651 | *p = '\\';
|
|---|
| 1652 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
|---|
| 1653 | szBuff[strlen(szBuff) - 1] = 0;
|
|---|
| 1654 | MakeFullName(szBuff);
|
|---|
| 1655 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath1) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
|---|
| 1656 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1657 | QW_OWNER), hwnd, szBuff, 0))
|
|---|
| 1658 | strcpy(wa->szCurrentPath1, szBuff);
|
|---|
| 1659 | else
|
|---|
| 1660 | return 0;
|
|---|
| 1661 | }
|
|---|
| 1662 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
|---|
| 1663 | *szBuff = 0;
|
|---|
| 1664 | WinQueryDlgItemText(hwnd, WALK2_PATH, CCHMAXPATH, szBuff);
|
|---|
| 1665 | bstrip(szBuff);
|
|---|
| 1666 | while ((p = strchr(szBuff, '/')) != NULL)
|
|---|
| 1667 | *p = '\\';
|
|---|
| 1668 | while (strlen(szBuff) > 3 && szBuff[strlen(szBuff) - 1] == '\\')
|
|---|
| 1669 | szBuff[strlen(szBuff) - 1] = 0;
|
|---|
| 1670 | MakeFullName(szBuff);
|
|---|
| 1671 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath2) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
|---|
| 1672 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
|---|
| 1673 | QW_OWNER), hwnd, szBuff, 0))
|
|---|
| 1674 | strcpy(wa->szCurrentPath2, szBuff);
|
|---|
| 1675 | else
|
|---|
| 1676 | return 0;
|
|---|
| 1677 | }
|
|---|
| 1678 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
|---|
| 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, 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, 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)
|
|---|