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