[123] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: walkem.c 1544 2010-09-30 13:00:59Z gyoung $
|
---|
| 5 |
|
---|
[1077] | 6 | Misc persistent lists support
|
---|
| 7 |
|
---|
[123] | 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1394] | 9 | Copyright (c) 2005, 2009 Steven H. Levine
|
---|
[123] | 10 |
|
---|
[186] | 11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 12 | 05 Jun 05 SHL Use QWL_USER
|
---|
[242] | 13 | 13 Aug 05 SHL Run through indent
|
---|
[259] | 14 | 13 Aug 05 SHL remove_udir - avoid corrupting last dirs list
|
---|
[328] | 15 | 17 Jul 06 SHL Use Runtime_Error
|
---|
[404] | 16 | 29 Jul 06 SHL Use xfgets
|
---|
[518] | 17 | 20 Oct 06 SHL Correct . .. check
|
---|
[544] | 18 | 06 Nov 06 SHL Oops - need to allow .. here
|
---|
| 19 | 14 Nov 06 SHL Correct FillPathListBox regression
|
---|
[574] | 20 | 22 Mar 07 GKY Use QWL_USER
|
---|
[617] | 21 | 20 Apr 07 SHL Avoid spurious add_udir error reports
|
---|
[787] | 22 | 16 Aug 07 SHL Update add_setups for ticket# 109
|
---|
[789] | 23 | 19 Aug 07 SHL Correct load_setups error reporting
|
---|
[794] | 24 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[807] | 25 | 25 Aug 07 SHL Correct #pragma alloc_text typos
|
---|
[864] | 26 | 11 Nov 07 GKY Cancel now directly closes dialog even if directory path text has changed
|
---|
[939] | 27 | 20 Jan 08 GKY Walk & walk2 dialogs now save and restore size and position
|
---|
[965] | 28 | 19 Feb 08 JBS Add "State at last FM/2 close" to the states combo box
|
---|
[985] | 29 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
| 30 | 29 Feb 08 GKY Refactor global command line variables to notebook.h
|
---|
[1027] | 31 | 19 Jun 08 JBS Ticket 227: Allow temporary saving/deleting of the shutdown state of directory containers
|
---|
[1029] | 32 | 22 Jun 08 GKY Add free_?dir for fortify testing
|
---|
[1078] | 33 | 18 Jul 08 SHL More Fortify support
|
---|
[1082] | 34 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory and use BldFullPathName
|
---|
[1119] | 35 | 24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
|
---|
[1438] | 36 | 28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
|
---|
[1471] | 37 | 06 Oct 09 SHL Ctrl-select selects Walk Dialog listbox entry, but suppresses action
|
---|
[1498] | 38 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
[123] | 39 |
|
---|
| 40 | ***********************************************************************/
|
---|
| 41 |
|
---|
[907] | 42 | #include <stdlib.h>
|
---|
| 43 | #include <string.h>
|
---|
| 44 | #include <ctype.h>
|
---|
| 45 | #include <share.h>
|
---|
| 46 |
|
---|
[2] | 47 | #define INCL_WIN
|
---|
| 48 | #define INCL_DOS
|
---|
| 49 | #define INCL_DOSERRORS
|
---|
[787] | 50 | #define INCL_SHLERRORS // PMERR_NOT_IN_IDX
|
---|
[841] | 51 | #define INCL_LONGLONG
|
---|
[2] | 52 |
|
---|
[1186] | 53 | #include "fm3dll.h"
|
---|
[1228] | 54 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1214] | 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)
|
---|
[2] | 59 | #include "fm3dlg.h"
|
---|
| 60 | #include "fm3str.h"
|
---|
[907] | 61 | #include "errutil.h" // Dos_Error...
|
---|
| 62 | #include "strutil.h" // GetPString
|
---|
[1077] | 63 | #include "notebook.h" // targetdirectory
|
---|
[1082] | 64 | #include "pathutil.h" // BldFullPathName
|
---|
[1162] | 65 | #include "walkem.h"
|
---|
[1186] | 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
|
---|
[1039] | 73 | #include "fortify.h"
|
---|
[2] | 74 |
|
---|
[242] | 75 | typedef struct
|
---|
| 76 | {
|
---|
[551] | 77 | USHORT size;
|
---|
| 78 | USHORT changed;
|
---|
| 79 | BOOL nounwriteable;
|
---|
| 80 | CHAR szCurrentPath[CCHMAXPATH];
|
---|
| 81 | CHAR *szReturnPath;
|
---|
| 82 | }
|
---|
| 83 | WALKER;
|
---|
[2] | 84 |
|
---|
[1214] | 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__;
|
---|
[242] | 93 | static CHAR WalkFont[CCHMAXPATH] = "";
|
---|
[2] | 94 | static ULONG WalkFontSize = sizeof(WalkFont);
|
---|
| 95 |
|
---|
[787] | 96 | /**
|
---|
| 97 | * States names management
|
---|
| 98 | */
|
---|
| 99 |
|
---|
| 100 | static BOOL fSetupsLoaded;
|
---|
| 101 | static LINKDIRS *pFirstSetup;
|
---|
| 102 | static const PSZ pszLastSetups = "LastSetups";
|
---|
[907] | 103 | // 18 Aug 07 SHL fixme to stop supporting old style 1 year from now?
|
---|
[787] | 104 | static const ULONG ulOldSetupsBytes = 100 * 13; // Prior to 3.0.7
|
---|
| 105 |
|
---|
[1214] | 106 | #pragma data_seg(GLOBAL1)
|
---|
| 107 | BOOL fUdirsChanged;
|
---|
| 108 | BOOL loadedudirs;
|
---|
| 109 |
|
---|
| 110 | #pragma data_seg(GLOBAL2)
|
---|
| 111 | LINKDIRS *ldirhead;
|
---|
| 112 | LINKDIRS *udirhead;
|
---|
| 113 |
|
---|
[787] | 114 | /**
|
---|
| 115 | * Fill States drop down list with known state names
|
---|
| 116 | */
|
---|
| 117 |
|
---|
| 118 | VOID fill_setups_list(VOID)
|
---|
[242] | 119 | {
|
---|
[787] | 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 | }
|
---|
[1498] | 131 | WinSetWindowText(hwndStatelist, (CHAR *) GetPString(IDS_STATETEXT));
|
---|
[787] | 132 | }
|
---|
| 133 | }
|
---|
[2] | 134 |
|
---|
[787] | 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 |
|
---|
[1394] | 145 | static INT lookup_setup(PCSZ name, UINT action)
|
---|
[787] | 146 | {
|
---|
| 147 | LINKDIRS *pld;
|
---|
| 148 | LINKDIRS *pldLast = NULL;
|
---|
| 149 |
|
---|
| 150 | if (!name || !*name) {
|
---|
[1398] | 151 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
[787] | 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;
|
---|
[1009] | 164 | xfree(pld->path, pszSrcFile, __LINE__);
|
---|
[1039] | 165 | free(pld);
|
---|
[787] | 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) {
|
---|
[1039] | 179 | free(pld);
|
---|
[787] | 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
|
---|
[2] | 189 | }
|
---|
| 190 |
|
---|
[787] | 191 | /**
|
---|
| 192 | * Load state names from ini
|
---|
| 193 | * Support old/new style storage method
|
---|
| 194 | */
|
---|
| 195 |
|
---|
| 196 | VOID load_setups(VOID)
|
---|
[242] | 197 | {
|
---|
[787] | 198 | ULONG ulDataBytes;
|
---|
| 199 | ULONG l;
|
---|
| 200 | PSZ pszBuf;
|
---|
| 201 | PSZ psz;
|
---|
| 202 | LINKDIRS *pld;
|
---|
| 203 |
|
---|
| 204 | if (fSetupsLoaded)
|
---|
[551] | 205 | return;
|
---|
[787] | 206 |
|
---|
[1505] | 207 | if (!PrfQueryProfileSize(fmprof, FM3Str, pszLastSetups, &ulDataBytes)) {
|
---|
[787] | 208 | // fixme to use generic hab
|
---|
| 209 | ERRORID eid = WinGetLastError((HAB)0);
|
---|
| 210 | if ((eid & 0xffff) != PMERR_NOT_IN_IDX) {
|
---|
[789] | 211 | // Get error info back
|
---|
[1505] | 212 | PrfQueryProfileSize(fmprof, FM3Str, pszLastSetups, &ulDataBytes);
|
---|
[1398] | 213 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_PRFQUERYPROFILESIZE);
|
---|
[787] | 214 | }
|
---|
[789] | 215 | else
|
---|
| 216 | fSetupsLoaded = TRUE; // Nothing saved
|
---|
| 217 | return;
|
---|
[787] | 218 | }
|
---|
| 219 |
|
---|
| 220 | if (ulDataBytes == 0) {
|
---|
[1398] | 221 | Runtime_Error(pszSrcFile, __LINE__, PCSZ_PRFQUERYPROFILESIZE);
|
---|
[787] | 222 | return;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | pszBuf = xmalloc(ulDataBytes + 1, pszSrcFile, __LINE__); // One extra for end marker
|
---|
| 226 | if (!pszBuf)
|
---|
| 227 | return;
|
---|
| 228 | l = ulDataBytes;
|
---|
[1505] | 229 | if (!PrfQueryProfileData(fmprof, FM3Str, pszLastSetups, pszBuf, &l)) {
|
---|
[1398] | 230 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, PCSZ_PRFQUERYPROFILEDATA);
|
---|
[1039] | 231 | free(pszBuf);
|
---|
[787] | 232 | return;
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | if (ulDataBytes != l) {
|
---|
| 236 | Runtime_Error(pszSrcFile, __LINE__, "PrfQueryProfileData reported %u expected %u", l, ulDataBytes);
|
---|
[1039] | 237 | free(pszBuf);
|
---|
[787] | 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) {
|
---|
[1039] | 250 | free(pszBuf);
|
---|
[787] | 251 | return;
|
---|
| 252 | }
|
---|
[1078] | 253 |
|
---|
| 254 | # ifdef FORTIFY
|
---|
| 255 | Fortify_SetOwner(pld, 1);
|
---|
| 256 | Fortify_SetScope(pld, 1);
|
---|
| 257 | # endif
|
---|
| 258 |
|
---|
[787] | 259 | pld->path = xstrdup(psz, pszSrcFile, __LINE__);
|
---|
| 260 | if (!pld->path) {
|
---|
[1039] | 261 | free(pszBuf);
|
---|
| 262 | free(pld);
|
---|
[787] | 263 | return;
|
---|
| 264 | }
|
---|
| 265 |
|
---|
[1078] | 266 | # ifdef FORTIFY
|
---|
| 267 | Fortify_SetOwner(pld->path, 1);
|
---|
| 268 | Fortify_SetScope(pld->path, 1);
|
---|
| 269 | # endif
|
---|
| 270 |
|
---|
[787] | 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 |
|
---|
[1039] | 282 | free(pszBuf);
|
---|
[787] | 283 |
|
---|
| 284 | fSetupsLoaded = TRUE;
|
---|
[2] | 285 | }
|
---|
| 286 |
|
---|
[787] | 287 | VOID save_setups(VOID)
|
---|
[242] | 288 | {
|
---|
[787] | 289 | ULONG ulBufBytes;
|
---|
| 290 | ULONG ulFillBytes;
|
---|
| 291 | ULONG l;
|
---|
| 292 | PSZ pszBuf;
|
---|
| 293 | PSZ psz;
|
---|
| 294 | LINKDIRS *pld;
|
---|
[2] | 295 |
|
---|
[787] | 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;
|
---|
[551] | 321 | }
|
---|
[787] | 322 |
|
---|
| 323 | if (!PrfWriteProfileData(fmprof,
|
---|
[1505] | 324 | FM3Str,
|
---|
[787] | 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
|
---|
[1505] | 332 | PrfWriteProfileData(fmprof, FM3Str, "LastSetup", NULL, 0);
|
---|
[2] | 333 | }
|
---|
| 334 |
|
---|
[787] | 335 | /**
|
---|
| 336 | * Add named state to setups list
|
---|
| 337 | * @return same as lookup_setup
|
---|
| 338 | */
|
---|
| 339 |
|
---|
[1394] | 340 | INT add_setup(PCSZ name)
|
---|
[242] | 341 | {
|
---|
[787] | 342 | return lookup_setup(name, LS_ADD);
|
---|
| 343 | }
|
---|
[2] | 344 |
|
---|
[787] | 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);
|
---|
[2] | 353 | }
|
---|
| 354 |
|
---|
[1077] | 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 |
|
---|
[242] | 371 | VOID load_udirs(VOID)
|
---|
| 372 | {
|
---|
[551] | 373 | /* load linked list of user directories from USERDIRS.DAT file */
|
---|
[2] | 374 |
|
---|
[551] | 375 | FILE *fp;
|
---|
| 376 | LINKDIRS *info;
|
---|
| 377 | LINKDIRS *last = NULL;
|
---|
| 378 | CHAR s[CCHMAXPATH + 24];
|
---|
[1544] | 379 | CHAR *moder = "r";
|
---|
[2] | 380 |
|
---|
[1034] | 381 | if (udirhead)
|
---|
| 382 | free_udirs();
|
---|
[551] | 383 | loadedudirs = TRUE;
|
---|
| 384 | fUdirsChanged = FALSE;
|
---|
[1398] | 385 | BldFullPathName(s, pFM2SaveDirectory, PCSZ_USERDIRSDAT);
|
---|
[1544] | 386 | fp = xfsopen(s, moder, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
|
---|
[551] | 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__);
|
---|
[1078] | 395 | # ifdef FORTIFY
|
---|
| 396 | Fortify_SetOwner(info, 1);
|
---|
| 397 | Fortify_SetScope(info, 1);
|
---|
| 398 | # endif
|
---|
[551] | 399 | if (info) {
|
---|
| 400 | info->path = xstrdup(s, pszSrcFile, __LINE__);
|
---|
| 401 | if (!info->path)
|
---|
[1039] | 402 | free(info);
|
---|
[551] | 403 | else {
|
---|
[1078] | 404 | # ifdef FORTIFY
|
---|
| 405 | Fortify_SetOwner(info->path, 1);
|
---|
| 406 | Fortify_SetScope(info->path, 1);
|
---|
| 407 | # endif
|
---|
[551] | 408 | info->next = NULL;
|
---|
| 409 | if (!udirhead)
|
---|
| 410 | udirhead = info;
|
---|
| 411 | else
|
---|
| 412 | last->next = info;
|
---|
| 413 | last = info;
|
---|
| 414 | }
|
---|
[242] | 415 | }
|
---|
[551] | 416 | }
|
---|
[2] | 417 | }
|
---|
[551] | 418 | fclose(fp);
|
---|
| 419 | }
|
---|
[2] | 420 | }
|
---|
| 421 |
|
---|
[242] | 422 | VOID save_udirs(VOID)
|
---|
| 423 | {
|
---|
[551] | 424 | FILE *fp;
|
---|
| 425 | LINKDIRS *info;
|
---|
| 426 | CHAR s[CCHMAXPATH + 14];
|
---|
[1544] | 427 | CHAR *modew = "w";
|
---|
[2] | 428 |
|
---|
[551] | 429 | if (loadedudirs) {
|
---|
| 430 | fUdirsChanged = FALSE;
|
---|
| 431 | if (udirhead) {
|
---|
[1398] | 432 | BldFullPathName(s, pFM2SaveDirectory, PCSZ_USERDIRSDAT);
|
---|
[1118] | 433 | if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2)
|
---|
[1394] | 434 | return; //already gave error msg
|
---|
[1544] | 435 | fp = xfopen(s, modew, pszSrcFile, __LINE__, FALSE);
|
---|
[551] | 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;
|
---|
[242] | 442 | }
|
---|
[551] | 443 | fclose(fp);
|
---|
| 444 | }
|
---|
[2] | 445 | }
|
---|
[551] | 446 | }
|
---|
[2] | 447 | }
|
---|
| 448 |
|
---|
[617] | 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 | */
|
---|
[259] | 456 |
|
---|
[617] | 457 | BOOL add_udir(BOOL userdirs, CHAR *inpath)
|
---|
[242] | 458 | {
|
---|
[551] | 459 | CHAR path[CCHMAXPATH];
|
---|
| 460 | LINKDIRS *info;
|
---|
| 461 | LINKDIRS *last = NULL;
|
---|
| 462 | LINKDIRS *temp;
|
---|
[2] | 463 |
|
---|
[551] | 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))
|
---|
[242] | 485 | return FALSE;
|
---|
[551] | 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;
|
---|
[242] | 497 | else
|
---|
[551] | 498 | ldirhead = info->next;
|
---|
[1009] | 499 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 500 | free(info);
|
---|
[551] | 501 | break;
|
---|
| 502 | }
|
---|
| 503 | temp = info;
|
---|
| 504 | info = info->next;
|
---|
[242] | 505 | }
|
---|
[551] | 506 | }
|
---|
| 507 | // Append entry to end of user dirs list
|
---|
| 508 | info = xmalloc(sizeof(LINKDIRS), pszSrcFile, __LINE__);
|
---|
| 509 | if (info) {
|
---|
[1078] | 510 | # ifdef FORTIFY
|
---|
| 511 | Fortify_SetScope(info, 1);
|
---|
| 512 | # endif
|
---|
[551] | 513 | info->path = xstrdup(path, pszSrcFile, __LINE__);
|
---|
| 514 | if (!info->path)
|
---|
[1039] | 515 | free(info);
|
---|
[551] | 516 | else {
|
---|
[1078] | 517 | # ifdef FORTIFY
|
---|
| 518 | Fortify_SetScope(info->path, 1);
|
---|
| 519 | # endif
|
---|
[551] | 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;
|
---|
[1077] | 533 | }
|
---|
[551] | 534 | return TRUE;
|
---|
| 535 | }
|
---|
| 536 | }
|
---|
[2] | 537 | }
|
---|
[551] | 538 | }
|
---|
| 539 | return FALSE;
|
---|
[2] | 540 | }
|
---|
| 541 |
|
---|
[259] | 542 | //=== remove_udir - remove path from user dir list or last directory list ===
|
---|
| 543 |
|
---|
[242] | 544 | BOOL remove_udir(CHAR * path)
|
---|
| 545 | {
|
---|
[551] | 546 | LINKDIRS *info;
|
---|
| 547 | LINKDIRS *last = NULL;
|
---|
[2] | 548 |
|
---|
[551] | 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;
|
---|
[1009] | 559 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 560 | free(info);
|
---|
[551] | 561 | fUdirsChanged = TRUE;
|
---|
| 562 | return TRUE;
|
---|
| 563 | }
|
---|
| 564 | last = info;
|
---|
| 565 | info = info->next;
|
---|
| 566 | }
|
---|
[259] | 567 |
|
---|
[551] | 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;
|
---|
[1009] | 576 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 577 | free(info);
|
---|
[551] | 578 | return TRUE;
|
---|
| 579 | }
|
---|
| 580 | last = info;
|
---|
| 581 | info = info->next;
|
---|
[2] | 582 | }
|
---|
[551] | 583 | }
|
---|
| 584 | return FALSE;
|
---|
[2] | 585 | }
|
---|
| 586 |
|
---|
[242] | 587 | BOOL remove_ldir(CHAR * path)
|
---|
| 588 | {
|
---|
[551] | 589 | LINKDIRS *info;
|
---|
| 590 | LINKDIRS *last = NULL;
|
---|
[2] | 591 |
|
---|
[551] | 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;
|
---|
[1009] | 600 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 601 | free(info);
|
---|
[551] | 602 | return TRUE;
|
---|
| 603 | }
|
---|
| 604 | last = info;
|
---|
| 605 | info = info->next;
|
---|
[2] | 606 | }
|
---|
[551] | 607 | }
|
---|
| 608 | return FALSE;
|
---|
[2] | 609 | }
|
---|
| 610 |
|
---|
[1082] | 611 | # ifdef FORTIFY
|
---|
| 612 |
|
---|
[1029] | 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__);
|
---|
[1039] | 621 | free(info);
|
---|
[1029] | 622 | info = next;
|
---|
| 623 | }
|
---|
| 624 | ldirhead = NULL;
|
---|
| 625 | }
|
---|
| 626 |
|
---|
[1082] | 627 | # endif
|
---|
| 628 |
|
---|
[1034] | 629 | VOID free_udirs(VOID)
|
---|
[1029] | 630 | {
|
---|
| 631 | LINKDIRS *info, *next;
|
---|
| 632 |
|
---|
| 633 | info = udirhead;
|
---|
| 634 | while (info) {
|
---|
| 635 | next = info->next;
|
---|
| 636 | xfree(info->path, pszSrcFile, __LINE__);
|
---|
[1039] | 637 | free(info);
|
---|
[1029] | 638 | info = next;
|
---|
| 639 | }
|
---|
| 640 | udirhead = NULL;
|
---|
| 641 | }
|
---|
| 642 |
|
---|
[551] | 643 | VOID FillPathListBox(HWND hwnd, HWND hwnddrive, HWND hwnddir, CHAR * pszPath,
|
---|
[242] | 644 | BOOL nounwriteable)
|
---|
| 645 | {
|
---|
[551] | 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 | */
|
---|
[2] | 652 |
|
---|
[551] | 653 | CHAR szDrive[] = " :", szTemp[1032];
|
---|
[847] | 654 | FILEFINDBUF3 findbuf;
|
---|
[551] | 655 | HDIR hDir = HDIR_CREATE;
|
---|
| 656 | SHORT sDrive;
|
---|
[766] | 657 | ULONG ulDriveNum, ulSearchCount = 1, ulDriveMap;
|
---|
[2] | 658 |
|
---|
[551] | 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);
|
---|
[2] | 665 |
|
---|
[551] | 666 | if (hwnddrive) {
|
---|
| 667 | // Fill drive listbox
|
---|
| 668 | for (sDrive = 0; sDrive < 26; sDrive++) {
|
---|
[766] | 669 | if (ulDriveMap & (1 << sDrive)) {
|
---|
[551] | 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 | }
|
---|
[2] | 676 | }
|
---|
[551] | 677 | if (hwnddrive != hwnddir && pszPath && isalpha(*pszPath)
|
---|
| 678 | && pszPath[1] == ':') {
|
---|
| 679 | *szDrive = toupper(*pszPath);
|
---|
| 680 | WinSetWindowText(hwnddrive, szDrive);
|
---|
| 681 | }
|
---|
| 682 | }
|
---|
[2] | 683 |
|
---|
[551] | 684 | if (hwnddir) {
|
---|
| 685 | // Fill directory listbox
|
---|
| 686 | sprintf(szTemp,
|
---|
| 687 | "%s%s*",
|
---|
[1438] | 688 | pszPath, (pszPath[strlen(pszPath) - 1] == '\\') ? NullStr : PCSZ_BACKSLASH);
|
---|
[551] | 689 | DosError(FERR_DISABLEHARDERR);
|
---|
[847] | 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)) {
|
---|
[551] | 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 | }
|
---|
[242] | 710 | }
|
---|
[766] | 711 | ulSearchCount = 1;
|
---|
[847] | 712 | } while (!DosFindNext(hDir,
|
---|
| 713 | &findbuf, sizeof(FILEFINDBUF3), &ulSearchCount));
|
---|
[551] | 714 | DosFindClose(hDir);
|
---|
[2] | 715 | }
|
---|
[551] | 716 | DosError(FERR_DISABLEHARDERR);
|
---|
| 717 | }
|
---|
[2] | 718 | }
|
---|
| 719 |
|
---|
[242] | 720 | MRESULT EXPENTRY TextSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 721 | {
|
---|
[574] | 722 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[2] | 723 |
|
---|
[551] | 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);
|
---|
[242] | 731 | }
|
---|
[551] | 732 | break;
|
---|
| 733 | }
|
---|
| 734 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
[2] | 735 | }
|
---|
| 736 |
|
---|
[242] | 737 | MRESULT EXPENTRY WalkDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 738 | {
|
---|
[551] | 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];
|
---|
[2] | 744 |
|
---|
[551] | 745 | switch (msg) {
|
---|
| 746 | case UM_SETUP2:
|
---|
| 747 | case WM_INITDLG:
|
---|
| 748 | okay = FALSE;
|
---|
| 749 | *lastdir = 0;
|
---|
| 750 | if (!mp2) {
|
---|
[1398] | 751 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
[551] | 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);
|
---|
[574] | 761 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) wa);
|
---|
[1009] | 762 | wa->szReturnPath = (CHAR *)mp2;
|
---|
[242] | 763 | {
|
---|
[551] | 764 | PFNWP oldproc;
|
---|
[2] | 765 |
|
---|
[551] | 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 | }
|
---|
[939] | 778 | {
|
---|
| 779 | SWP swp;
|
---|
| 780 | ULONG size = sizeof(SWP);
|
---|
| 781 |
|
---|
[1505] | 782 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp, &size);
|
---|
[1394] | 783 | swp.fl &= ~SWP_SIZE; // 04 Feb 09 SHL ignore saved size
|
---|
[939] | 784 | WinSetWindowPos(hwnd,
|
---|
[1077] | 785 | HWND_TOP,
|
---|
| 786 | swp.x,
|
---|
| 787 | swp.y,
|
---|
| 788 | swp.cx,
|
---|
| 789 | swp.cy,
|
---|
| 790 | swp.fl);
|
---|
[939] | 791 | }
|
---|
[551] | 792 | PosOverOkay(hwnd);
|
---|
| 793 | if (msg == UM_SETUP2)
|
---|
| 794 | wa->nounwriteable = FALSE;
|
---|
| 795 | else
|
---|
| 796 | wa->nounwriteable = TRUE;
|
---|
| 797 | if (!*wa->szReturnPath)
|
---|
[1104] | 798 | strcpy(wa->szCurrentPath, pFM2SaveDirectory);
|
---|
[551] | 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)) {
|
---|
[2] | 806 |
|
---|
[551] | 807 | ULONG bd;
|
---|
[2] | 808 |
|
---|
[551] | 809 | strcpy(wa->szCurrentPath, "C:\\");
|
---|
| 810 | if (DosQuerySysInfo(QSV_BOOT_DRIVE,
|
---|
| 811 | QSV_BOOT_DRIVE,
|
---|
| 812 | (PVOID) & bd, (ULONG) sizeof(ULONG)))
|
---|
[766] | 813 | bd = 3;
|
---|
[551] | 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;
|
---|
[847] | 825 | FILEFINDBUF3 findbuf;
|
---|
[551] | 826 | HDIR hDir;
|
---|
| 827 | APIRET rc;
|
---|
| 828 | LINKDIRS *info, *temp;
|
---|
[2] | 829 |
|
---|
[551] | 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;
|
---|
[766] | 839 | ulSearchCount = 1;
|
---|
[551] | 840 | if (!IsRoot(info->path))
|
---|
[847] | 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);
|
---|
[551] | 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;
|
---|
[242] | 862 | }
|
---|
[551] | 863 | }
|
---|
[766] | 864 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
---|
[551] | 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;
|
---|
[766] | 880 | ulSearchCount = 1;
|
---|
[551] | 881 | if (!IsRoot(info->path))
|
---|
[847] | 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);
|
---|
[551] | 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;
|
---|
[242] | 903 | }
|
---|
[551] | 904 | WinSetDlgItemText(hwnd, WALK_RECENT,
|
---|
[1498] | 905 | (CHAR *) GetPString(IDS_WALKRECENTDIRSTEXT));
|
---|
[551] | 906 | }
|
---|
[766] | 907 | else if (!(ulDriveMap & (1 << (toupper(*info->path) - 'A')))) {
|
---|
[551] | 908 | temp = info->next;
|
---|
| 909 | remove_ldir(info->path);
|
---|
| 910 | info = temp;
|
---|
| 911 | continue;
|
---|
| 912 | }
|
---|
[242] | 913 | }
|
---|
[551] | 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;
|
---|
[2] | 925 |
|
---|
[551] | 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 | }
|
---|
[2] | 931 |
|
---|
[551] | 932 | case UM_SETUP4:
|
---|
| 933 | okay = TRUE;
|
---|
| 934 | return 0;
|
---|
[2] | 935 |
|
---|
[551] | 936 | case WM_ADJUSTWINDOWPOS:
|
---|
| 937 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 938 | break;
|
---|
[2] | 939 |
|
---|
[551] | 940 | case UM_SETDIR:
|
---|
| 941 | PaintRecessedWindow(WinWindowFromID(hwnd, WALK_HELP), (HPS) 0, FALSE,
|
---|
| 942 | TRUE);
|
---|
| 943 | return 0;
|
---|
[2] | 944 |
|
---|
[551] | 945 | case WM_PRESPARAMCHANGED:
|
---|
| 946 | {
|
---|
| 947 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
---|
[2] | 948 |
|
---|
[551] | 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;
|
---|
[242] | 961 | }
|
---|
[551] | 962 | }
|
---|
| 963 | }
|
---|
| 964 | break;
|
---|
[2] | 965 |
|
---|
[551] | 966 | case UM_SETUP3:
|
---|
| 967 | save_udirs();
|
---|
| 968 | if (hwndMain)
|
---|
| 969 | PostMsg(hwndMain, UM_FILLUSERLIST, MPVOID, MPVOID);
|
---|
| 970 | return 0;
|
---|
[2] | 971 |
|
---|
[551] | 972 | case UM_SETUP:
|
---|
| 973 | {
|
---|
| 974 | INT x;
|
---|
| 975 | USHORT id[] = { WALK_PATH, WALK_DIRLIST, WALK_USERLIST,
|
---|
| 976 | WALK_RECENT, 0
|
---|
| 977 | };
|
---|
[2] | 978 |
|
---|
[551] | 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;
|
---|
[2] | 991 |
|
---|
[551] | 992 | case UM_CONTROL:
|
---|
| 993 | case WM_CONTROL:
|
---|
[574] | 994 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 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)
|
---|
[1498] | 1011 | WinSetDlgItemText(hwnd, WALK_HELP, (CHAR *) GetPString(IDS_WALKCURRDIRTEXT));
|
---|
[551] | 1012 | else if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
| 1013 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
[1498] | 1014 | (CHAR *) GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
[551] | 1015 | break;
|
---|
[2] | 1016 |
|
---|
[551] | 1017 | case WALK_RECENT:
|
---|
| 1018 | if (okay && SHORT2FROMMP(mp1) == CBN_LBSELECT) {
|
---|
[2] | 1019 |
|
---|
[551] | 1020 | ULONG ulSearchCount;
|
---|
[847] | 1021 | FILEFINDBUF3 findbuf;
|
---|
[551] | 1022 | HDIR hDir;
|
---|
| 1023 | APIRET rc;
|
---|
[2] | 1024 |
|
---|
[551] | 1025 | // *szBuffer = 0;
|
---|
| 1026 | // WinQueryDlgItemText(hwnd,WALK_RECENT,CCHMAXPATH,szBuffer);
|
---|
| 1027 | if (!*szBuffer)
|
---|
| 1028 | break;
|
---|
| 1029 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1030 | hDir = HDIR_CREATE;
|
---|
[766] | 1031 | ulSearchCount = 1;
|
---|
[551] | 1032 | if (!IsRoot(szBuffer)) {
|
---|
[847] | 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);
|
---|
[551] | 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__,
|
---|
[1400] | 1047 | "DosFindFirst");
|
---|
[551] | 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,
|
---|
[1498] | 1064 | (CHAR *) GetPString(IDS_WALKRECENTDIRSHELPTEXT));
|
---|
[551] | 1065 | break;
|
---|
[2] | 1066 |
|
---|
[551] | 1067 | case WALK_USERLIST:
|
---|
| 1068 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_SELECT) {
|
---|
[2] | 1069 |
|
---|
[551] | 1070 | ULONG ulSearchCount;
|
---|
[847] | 1071 | FILEFINDBUF3 findbuf;
|
---|
[551] | 1072 | HDIR hDir;
|
---|
| 1073 | APIRET rc;
|
---|
[2] | 1074 |
|
---|
[1471] | 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;
|
---|
[551] | 1079 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1080 | hDir = HDIR_CREATE;
|
---|
[766] | 1081 | ulSearchCount = 1;
|
---|
[551] | 1082 | if (!IsRoot(szBuffer)) {
|
---|
[847] | 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);
|
---|
[551] | 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__,
|
---|
[1400] | 1100 | "DosFindFirst");
|
---|
[551] | 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,
|
---|
[1498] | 1116 | WALK_HELP, (CHAR *) GetPString(IDS_WALKUSERDIRSHELPTEXT));
|
---|
[551] | 1117 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
| 1118 | WinSetDlgItemText(hwnd,
|
---|
[1498] | 1119 | WALK_HELP, (CHAR *) GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
[551] | 1120 | break;
|
---|
[2] | 1121 |
|
---|
[551] | 1122 | case WALK_DRIVELIST:
|
---|
| 1123 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1124 |
|
---|
[551] | 1125 | ULONG ulDirLen = CCHMAXPATH;
|
---|
| 1126 | APIRET rc;
|
---|
[2] | 1127 |
|
---|
[1321] | 1128 | rc = DosQCurDir(toupper(*szBuffer) - '@', (PBYTE)&szBuff[3], &ulDirLen);
|
---|
[551] | 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,
|
---|
[1498] | 1141 | (CHAR *) GetPString(IDS_WALKDRIVELISTHELPTEXT));
|
---|
[551] | 1142 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
| 1143 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
[1498] | 1144 | (CHAR *) GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
[551] | 1145 | break;
|
---|
[2] | 1146 |
|
---|
[551] | 1147 | case WALK_DIRLIST:
|
---|
| 1148 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1149 |
|
---|
[551] | 1150 | ULONG ulSearchCount;
|
---|
[847] | 1151 | FILEFINDBUF3 findbuf;
|
---|
[551] | 1152 | HDIR hDir;
|
---|
| 1153 | APIRET rc;
|
---|
[2] | 1154 |
|
---|
[551] | 1155 | bstrip(szBuffer);
|
---|
| 1156 | if (*szBuffer) {
|
---|
[1438] | 1157 | strcpy(szBuff, wa->szCurrentPath);
|
---|
| 1158 | AddBackslashToPath(szBuff);
|
---|
| 1159 | //if (szBuff[strlen(szBuff) - 1] != '\\')
|
---|
| 1160 | // strcat(szBuff, "\\");
|
---|
[551] | 1161 | strcat(szBuff, szBuffer);
|
---|
| 1162 | MakeFullName(szBuff);
|
---|
| 1163 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1164 | hDir = HDIR_CREATE;
|
---|
[766] | 1165 | ulSearchCount = 1;
|
---|
[551] | 1166 | if (!IsRoot(szBuff)) {
|
---|
[847] | 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);
|
---|
[551] | 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 | }
|
---|
[242] | 1190 | }
|
---|
[551] | 1191 | }
|
---|
| 1192 | else if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
---|
| 1193 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
[1498] | 1194 | (CHAR *) GetPString(IDS_WALKDIRLISTHELPTEXT));
|
---|
[551] | 1195 | else if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
| 1196 | WinSetDlgItemText(hwnd, WALK_HELP,
|
---|
[1498] | 1197 | (CHAR *) GetPString(IDS_WALKDEFAULTHELPTEXT));
|
---|
[551] | 1198 | break;
|
---|
| 1199 | }
|
---|
| 1200 | return 0;
|
---|
| 1201 |
|
---|
| 1202 | case WM_COMMAND:
|
---|
[574] | 1203 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 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);
|
---|
[864] | 1214 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
---|
[551] | 1215 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1216 | QW_OWNER), hwnd, szBuff, 0))
|
---|
| 1217 | strcpy(wa->szCurrentPath, szBuff);
|
---|
[865] | 1218 | else
|
---|
[242] | 1219 | return 0;
|
---|
[551] | 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);
|
---|
[617] | 1231 | add_udir(TRUE, szBuff);
|
---|
| 1232 | if (fUdirsChanged) {
|
---|
[551] | 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;
|
---|
[2] | 1242 |
|
---|
[551] | 1243 | case WALK_DELETE:
|
---|
[1471] | 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;
|
---|
[551] | 1255 | }
|
---|
| 1256 | break;
|
---|
[2] | 1257 |
|
---|
[551] | 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 | }
|
---|
[939] | 1269 | {
|
---|
[1077] | 1270 | SWP swp;
|
---|
| 1271 | ULONG size = sizeof(SWP);
|
---|
| 1272 | WinQueryWindowPos(hwnd, &swp);
|
---|
[1505] | 1273 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
---|
[1077] | 1274 | size);
|
---|
[939] | 1275 | }
|
---|
[551] | 1276 | if (wa->changed)
|
---|
| 1277 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
| 1278 | WinDismissDlg(hwnd, 1);
|
---|
| 1279 | break;
|
---|
[2] | 1280 |
|
---|
[551] | 1281 | case IDM_HELP:
|
---|
| 1282 | if (hwndHelp)
|
---|
| 1283 | WinSendMsg(hwndHelp,
|
---|
| 1284 | HM_DISPLAY_HELP,
|
---|
| 1285 | MPFROM2SHORT(HELP_WALKEM, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 1286 | break;
|
---|
[2] | 1287 |
|
---|
[551] | 1288 | case DID_CANCEL:
|
---|
[939] | 1289 | {
|
---|
[1077] | 1290 | SWP swp;
|
---|
| 1291 | ULONG size = sizeof(SWP);
|
---|
[939] | 1292 |
|
---|
[1077] | 1293 | WinQueryWindowPos(hwnd, &swp);
|
---|
[1505] | 1294 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir.Position", (PVOID) &swp,
|
---|
[1077] | 1295 | size);
|
---|
[939] | 1296 | }
|
---|
[551] | 1297 | if (wa->changed)
|
---|
[1077] | 1298 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
[1039] | 1299 | free(wa);
|
---|
[551] | 1300 | WinDismissDlg(hwnd, 0);
|
---|
| 1301 | break;
|
---|
| 1302 | }
|
---|
| 1303 | return 0;
|
---|
[2] | 1304 |
|
---|
[551] | 1305 | case WM_CLOSE:
|
---|
[1077] | 1306 | break;
|
---|
[551] | 1307 | }
|
---|
| 1308 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1309 | }
|
---|
| 1310 |
|
---|
[242] | 1311 | MRESULT EXPENTRY WalkAllDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 1312 | {
|
---|
[551] | 1313 | switch (msg) {
|
---|
| 1314 | case WM_INITDLG:
|
---|
| 1315 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1316 | }
|
---|
| 1317 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1318 | }
|
---|
| 1319 |
|
---|
[242] | 1320 | MRESULT EXPENTRY WalkCopyDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 1321 | {
|
---|
[551] | 1322 | switch (msg) {
|
---|
| 1323 | case WM_INITDLG:
|
---|
[1498] | 1324 | WinSetWindowText(hwnd, (CHAR *) GetPString(IDS_WALKCOPYDLGTEXT));
|
---|
[551] | 1325 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1326 | }
|
---|
| 1327 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1328 | }
|
---|
| 1329 |
|
---|
[242] | 1330 | MRESULT EXPENTRY WalkMoveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 1331 | {
|
---|
[551] | 1332 | switch (msg) {
|
---|
| 1333 | case WM_INITDLG:
|
---|
[1498] | 1334 | WinSetWindowText(hwnd, (CHAR *) GetPString(IDS_WALKMOVEDLGTEXT));
|
---|
[551] | 1335 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1336 | }
|
---|
| 1337 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1338 | }
|
---|
| 1339 |
|
---|
[242] | 1340 | MRESULT EXPENTRY WalkExtractDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1341 | MPARAM mp2)
|
---|
| 1342 | {
|
---|
[551] | 1343 | switch (msg) {
|
---|
| 1344 | case WM_INITDLG:
|
---|
[1498] | 1345 | WinSetWindowText(hwnd, (CHAR *) GetPString(IDS_WALKEXTRACTDLGTEXT));
|
---|
[551] | 1346 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1347 | }
|
---|
| 1348 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1349 | }
|
---|
| 1350 |
|
---|
[242] | 1351 | MRESULT EXPENTRY WalkTargetDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1352 | MPARAM mp2)
|
---|
| 1353 | {
|
---|
[551] | 1354 | switch (msg) {
|
---|
| 1355 | case WM_INITDLG:
|
---|
[242] | 1356 | {
|
---|
[551] | 1357 | char s[CCHMAXPATH + 32];
|
---|
[2] | 1358 |
|
---|
[551] | 1359 | sprintf(s,
|
---|
| 1360 | GetPString(IDS_WALKTARGETDLGTEXT),
|
---|
| 1361 | (*targetdir) ?
|
---|
| 1362 | NullStr :
|
---|
| 1363 | " (",
|
---|
| 1364 | (*targetdir) ?
|
---|
| 1365 | NullStr : GetPString(IDS_NONE), (*targetdir) ? NullStr : ")");
|
---|
| 1366 | WinSetWindowText(hwnd, s);
|
---|
[242] | 1367 | }
|
---|
[551] | 1368 | return WalkDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1369 | }
|
---|
| 1370 | return WalkDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1371 | }
|
---|
| 1372 |
|
---|
[242] | 1373 | MRESULT EXPENTRY WalkTwoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 1374 | {
|
---|
[551] | 1375 | WALK2 *wa;
|
---|
| 1376 | CHAR szBuff[CCHMAXPATH + 1], szBuffer[CCHMAXPATH + 1], *p;
|
---|
| 1377 | SHORT sSelect;
|
---|
| 1378 | static BOOL okay; /* avoid combobox selecting as filled */
|
---|
[2] | 1379 |
|
---|
[551] | 1380 | switch (msg) {
|
---|
| 1381 | case UM_SETUP2:
|
---|
| 1382 | case WM_INITDLG:
|
---|
| 1383 | okay = FALSE;
|
---|
| 1384 | if (!mp2) {
|
---|
| 1385 | WinDismissDlg(hwnd, 0);
|
---|
| 1386 | break;
|
---|
| 1387 | }
|
---|
[574] | 1388 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
[551] | 1389 | wa = mp2;
|
---|
[242] | 1390 | {
|
---|
[551] | 1391 | PFNWP oldproc;
|
---|
[2] | 1392 |
|
---|
[551] | 1393 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK_PATH),
|
---|
| 1394 | (PFNWP) TextSubProc);
|
---|
| 1395 | if (oldproc)
|
---|
| 1396 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK_PATH),
|
---|
| 1397 | QWL_USER, (PVOID) oldproc);
|
---|
| 1398 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, WALK2_PATH),
|
---|
| 1399 | (PFNWP) TextSubProc);
|
---|
| 1400 | if (oldproc)
|
---|
| 1401 | WinSetWindowPtr(WinWindowFromID(hwnd, WALK2_PATH),
|
---|
| 1402 | QWL_USER, (PVOID) oldproc);
|
---|
| 1403 | }
|
---|
[939] | 1404 | {
|
---|
| 1405 | SWP swp;
|
---|
| 1406 | ULONG size = sizeof(SWP);
|
---|
| 1407 |
|
---|
[1505] | 1408 | PrfQueryProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp, &size);
|
---|
[1394] | 1409 | swp.fl &= ~SWP_SIZE; // 04 Feb 09 SHL ignore saved size
|
---|
[939] | 1410 | WinSetWindowPos(hwnd,
|
---|
[1077] | 1411 | HWND_TOP,
|
---|
| 1412 | swp.x,
|
---|
| 1413 | swp.y,
|
---|
| 1414 | swp.cx,
|
---|
| 1415 | swp.cy,
|
---|
| 1416 | swp.fl);
|
---|
[939] | 1417 | }
|
---|
[551] | 1418 | if (!*wa->szCurrentPath1)
|
---|
[1104] | 1419 | strcpy(wa->szCurrentPath1, pFM2SaveDirectory);
|
---|
[551] | 1420 | MakeFullName(wa->szCurrentPath1);
|
---|
| 1421 | if (!*wa->szCurrentPath2)
|
---|
[1104] | 1422 | strcpy(wa->szCurrentPath2, pFM2SaveDirectory);
|
---|
[551] | 1423 | MakeFullName(wa->szCurrentPath2);
|
---|
| 1424 | WinSendDlgItemMsg(hwnd,
|
---|
| 1425 | WALK_PATH,
|
---|
| 1426 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 1427 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
| 1428 | WinSendDlgItemMsg(hwnd, WALK2_PATH, EM_SETTEXTLIMIT,
|
---|
| 1429 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 1430 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
| 1431 | FillPathListBox(hwnd,
|
---|
| 1432 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 1433 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 1434 | wa->szCurrentPath1, FALSE);
|
---|
| 1435 | FillPathListBox(hwnd,
|
---|
| 1436 | WinWindowFromID(hwnd, WALK2_DRIVELIST),
|
---|
| 1437 | WinWindowFromID(hwnd, WALK2_DIRLIST),
|
---|
| 1438 | wa->szCurrentPath2, FALSE);
|
---|
| 1439 | if (!PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID))
|
---|
| 1440 | okay = TRUE;
|
---|
| 1441 | {
|
---|
| 1442 | MRESULT ret;
|
---|
[2] | 1443 |
|
---|
[551] | 1444 | ret = WinDefDlgProc(hwnd, WM_INITDLG, mp1, mp2);
|
---|
| 1445 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 1446 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
| 1447 | WinInvalidateRect(WinWindowFromID(hwnd, WALK2_PATH), NULL, TRUE);
|
---|
| 1448 | return ret;
|
---|
| 1449 | }
|
---|
[2] | 1450 |
|
---|
[551] | 1451 | case UM_SETUP4:
|
---|
| 1452 | okay = TRUE;
|
---|
| 1453 | return 0;
|
---|
[2] | 1454 |
|
---|
[551] | 1455 | case WM_PRESPARAMCHANGED:
|
---|
| 1456 | {
|
---|
| 1457 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
---|
[2] | 1458 |
|
---|
[551] | 1459 | cbRetLen = WinQueryPresParam(hwnd, (ULONG) mp1, 0, &AttrFound,
|
---|
| 1460 | (ULONG) sizeof(AttrValue), &AttrValue, 0);
|
---|
| 1461 | if (cbRetLen) {
|
---|
| 1462 | switch (AttrFound) {
|
---|
| 1463 | case PP_FONTNAMESIZE:
|
---|
| 1464 | PrfWriteProfileData(fmprof,
|
---|
| 1465 | appname,
|
---|
| 1466 | "WalkFont", (PVOID) AttrValue, cbRetLen);
|
---|
| 1467 | *WalkFont = 0;
|
---|
| 1468 | WalkFontSize = sizeof(WalkFont);
|
---|
| 1469 | WinInvalidateRect(WinWindowFromID(hwnd, WALK_PATH), NULL, TRUE);
|
---|
| 1470 | break;
|
---|
[242] | 1471 | }
|
---|
[551] | 1472 | }
|
---|
| 1473 | }
|
---|
| 1474 | break;
|
---|
[2] | 1475 |
|
---|
[551] | 1476 | case UM_SETUP:
|
---|
| 1477 | {
|
---|
| 1478 | INT x;
|
---|
| 1479 | USHORT id[] = { WALK_PATH, WALK_DIRLIST,
|
---|
| 1480 | WALK2_PATH, WALK2_DIRLIST, 0
|
---|
| 1481 | };
|
---|
[2] | 1482 |
|
---|
[551] | 1483 | if (*WalkFont ||
|
---|
| 1484 | (PrfQueryProfileData(fmprof,
|
---|
| 1485 | appname,
|
---|
| 1486 | "WalkFont",
|
---|
| 1487 | (PVOID) WalkFont,
|
---|
| 1488 | &WalkFontSize) && WalkFontSize)) {
|
---|
| 1489 | for (x = 0; id[x]; x++)
|
---|
| 1490 | WinSetPresParam(WinWindowFromID(hwnd, id[x]),
|
---|
| 1491 | PP_FONTNAMESIZE, WalkFontSize, (PVOID) WalkFont);
|
---|
| 1492 | }
|
---|
| 1493 | }
|
---|
| 1494 | return 0;
|
---|
[2] | 1495 |
|
---|
[551] | 1496 | case UM_CONTROL:
|
---|
| 1497 | case WM_CONTROL:
|
---|
[574] | 1498 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 1499 | if (SHORT1FROMMP(mp1) == WALK_DRIVELIST ||
|
---|
| 1500 | SHORT1FROMMP(mp1) == WALK_DIRLIST ||
|
---|
| 1501 | SHORT1FROMMP(mp1) == WALK2_DRIVELIST ||
|
---|
| 1502 | SHORT1FROMMP(mp1) == WALK2_DIRLIST) {
|
---|
| 1503 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 1504 | SHORT1FROMMP(mp1),
|
---|
| 1505 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
---|
| 1506 | *szBuffer = 0;
|
---|
| 1507 | if (sSelect >= 0)
|
---|
| 1508 | WinSendDlgItemMsg(hwnd, SHORT1FROMMP(mp1), LM_QUERYITEMTEXT,
|
---|
| 1509 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
---|
| 1510 | MPFROMP(szBuffer));
|
---|
| 1511 | }
|
---|
| 1512 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1513 | case WALK_DRIVELIST:
|
---|
| 1514 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1515 |
|
---|
[551] | 1516 | ULONG ulDirLen = CCHMAXPATH;
|
---|
| 1517 | APIRET rc;
|
---|
[2] | 1518 |
|
---|
[1321] | 1519 | rc = DosQCurDir(toupper(*szBuffer) - '@', (PBYTE)&szBuff[3], &ulDirLen);
|
---|
[551] | 1520 | if (!rc) {
|
---|
| 1521 | strcpy(wa->szCurrentPath1, "C:\\");
|
---|
| 1522 | *wa->szCurrentPath1 = toupper(*szBuffer);
|
---|
| 1523 | WinSetDlgItemText(hwnd, WALK_PATH, wa->szCurrentPath1);
|
---|
| 1524 | FillPathListBox(hwnd,
|
---|
| 1525 | WinWindowFromID(hwnd, WALK_DRIVELIST),
|
---|
| 1526 | WinWindowFromID(hwnd, WALK_DIRLIST),
|
---|
| 1527 | wa->szCurrentPath1, FALSE);
|
---|
| 1528 | }
|
---|
| 1529 | }
|
---|
| 1530 | break;
|
---|
[2] | 1531 |
|
---|
[551] | 1532 | case WALK_DIRLIST:
|
---|
| 1533 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1534 |
|
---|
[551] | 1535 | ULONG ulSearchCount;
|
---|
[847] | 1536 | FILEFINDBUF3 findbuf;
|
---|
[551] | 1537 | HDIR hDir;
|
---|
| 1538 | APIRET rc;
|
---|
[2] | 1539 |
|
---|
[551] | 1540 | bstrip(szBuffer);
|
---|
| 1541 | if (*szBuffer) {
|
---|
[1438] | 1542 | strcpy(szBuff, wa->szCurrentPath1);
|
---|
| 1543 | AddBackslashToPath(szBuff);
|
---|
| 1544 | //if (szBuff[strlen(szBuff) - 1] != '\\')
|
---|
| 1545 | // strcat(szBuff, "\\");
|
---|
[551] | 1546 | strcat(szBuff, szBuffer);
|
---|
| 1547 | MakeFullName(szBuff);
|
---|
| 1548 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1549 | hDir = HDIR_CREATE;
|
---|
[766] | 1550 | ulSearchCount = 1;
|
---|
[551] | 1551 | if (!IsRoot(szBuff)) {
|
---|
[847] | 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);
|
---|
[551] | 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;
|
---|
[2] | 1578 |
|
---|
[551] | 1579 | case WALK2_DRIVELIST:
|
---|
| 1580 | if (okay && *szBuffer && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1581 |
|
---|
[551] | 1582 | ULONG ulDirLen = CCHMAXPATH;
|
---|
| 1583 | APIRET rc;
|
---|
[2] | 1584 |
|
---|
[1321] | 1585 | rc = DosQCurDir(toupper(*szBuffer) - '@', (PBYTE)&szBuff[3], &ulDirLen);
|
---|
[551] | 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;
|
---|
[2] | 1597 |
|
---|
[551] | 1598 | case WALK2_DIRLIST:
|
---|
| 1599 | if (okay && SHORT2FROMMP(mp1) == LN_ENTER) {
|
---|
[2] | 1600 |
|
---|
[551] | 1601 | ULONG ulSearchCount;
|
---|
[847] | 1602 | FILEFINDBUF3 findbuf;
|
---|
[551] | 1603 | HDIR hDir;
|
---|
| 1604 | APIRET rc;
|
---|
[2] | 1605 |
|
---|
[551] | 1606 | bstrip(szBuffer);
|
---|
| 1607 | if (*szBuffer) {
|
---|
[1438] | 1608 | strcpy(szBuff, wa->szCurrentPath2);
|
---|
| 1609 | AddBackslashToPath(szBuff);
|
---|
| 1610 | //if (szBuff[strlen(szBuff) - 1] != '\\')
|
---|
| 1611 | // strcat(szBuff, "\\");
|
---|
[551] | 1612 | strcat(szBuff, szBuffer);
|
---|
| 1613 | MakeFullName(szBuff);
|
---|
| 1614 | DosError(FERR_DISABLEHARDERR);
|
---|
| 1615 | hDir = HDIR_CREATE;
|
---|
[766] | 1616 | ulSearchCount = 1;
|
---|
[551] | 1617 | if (!IsRoot(szBuff)) {
|
---|
[847] | 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);
|
---|
[551] | 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 | }
|
---|
[242] | 1641 | }
|
---|
[551] | 1642 | }
|
---|
| 1643 | break;
|
---|
| 1644 | }
|
---|
| 1645 | return 0;
|
---|
| 1646 |
|
---|
| 1647 | case WM_COMMAND:
|
---|
[574] | 1648 | wa = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 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);
|
---|
[864] | 1659 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath1) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
---|
[551] | 1660 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1661 | QW_OWNER), hwnd, szBuff, 0))
|
---|
| 1662 | strcpy(wa->szCurrentPath1, szBuff);
|
---|
[865] | 1663 | else
|
---|
[242] | 1664 | return 0;
|
---|
[551] | 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);
|
---|
[864] | 1675 | if (*szBuff && stricmp(szBuff, wa->szCurrentPath2) && SHORT1FROMMP(mp1) != DID_CANCEL) {
|
---|
[551] | 1676 | if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1677 | QW_OWNER), hwnd, szBuff, 0))
|
---|
| 1678 | strcpy(wa->szCurrentPath2, szBuff);
|
---|
[865] | 1679 | else
|
---|
[551] | 1680 | return 0;
|
---|
| 1681 | }
|
---|
| 1682 | WinSetDlgItemText(hwnd, WALK2_PATH, wa->szCurrentPath2);
|
---|
| 1683 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1684 | case DID_OK:
|
---|
[939] | 1685 | {
|
---|
| 1686 | SWP swp;
|
---|
| 1687 | ULONG size = sizeof(SWP);
|
---|
| 1688 |
|
---|
| 1689 | WinQueryWindowPos(hwnd, &swp);
|
---|
[1505] | 1690 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
|
---|
[1077] | 1691 | size);
|
---|
[939] | 1692 | }
|
---|
[551] | 1693 | WinDismissDlg(hwnd, 1);
|
---|
| 1694 | break;
|
---|
[2] | 1695 |
|
---|
[551] | 1696 | case IDM_HELP:
|
---|
| 1697 | if (hwndHelp)
|
---|
| 1698 | WinSendMsg(hwndHelp,
|
---|
| 1699 | HM_DISPLAY_HELP,
|
---|
| 1700 | MPFROM2SHORT(HELP_WALKEM2, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 1701 | break;
|
---|
[2] | 1702 |
|
---|
[551] | 1703 | case DID_CANCEL:
|
---|
[939] | 1704 | {
|
---|
| 1705 | SWP swp;
|
---|
| 1706 | ULONG size = sizeof(SWP);
|
---|
| 1707 |
|
---|
| 1708 | WinQueryWindowPos(hwnd, &swp);
|
---|
[1505] | 1709 | PrfWriteProfileData(fmprof, FM3Str, "WalkDir2.Position", (PVOID) &swp,
|
---|
[1077] | 1710 | size);
|
---|
[939] | 1711 | }
|
---|
[551] | 1712 | WinDismissDlg(hwnd, 0);
|
---|
| 1713 | break;
|
---|
| 1714 | }
|
---|
| 1715 | return 0;
|
---|
[2] | 1716 |
|
---|
[551] | 1717 | case WM_CLOSE:
|
---|
| 1718 | break;
|
---|
| 1719 | }
|
---|
| 1720 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1721 | }
|
---|
| 1722 |
|
---|
[242] | 1723 | MRESULT EXPENTRY WalkTwoCmpDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1724 | MPARAM mp2)
|
---|
| 1725 | {
|
---|
[551] | 1726 | switch (msg) {
|
---|
| 1727 | case WM_INITDLG:
|
---|
[1498] | 1728 | WinSetWindowText(hwnd, (CHAR *) GetPString(IDS_WALKCOMPAREDLGTEXT));
|
---|
[551] | 1729 | return WalkTwoDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1730 | }
|
---|
| 1731 | return WalkTwoDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1732 | }
|
---|
| 1733 |
|
---|
[242] | 1734 | MRESULT EXPENTRY WalkTwoSetDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
| 1735 | MPARAM mp2)
|
---|
| 1736 | {
|
---|
[551] | 1737 | switch (msg) {
|
---|
| 1738 | case WM_INITDLG:
|
---|
[1498] | 1739 | WinSetWindowText(hwnd, (CHAR *) GetPString(IDS_WALKSETDIRSDLGTEXT));
|
---|
[551] | 1740 | return WalkTwoDlgProc(hwnd, UM_SETUP2, mp1, mp2);
|
---|
| 1741 | }
|
---|
| 1742 | return WalkTwoDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1743 | }
|
---|
[794] | 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)
|
---|
[807] | 1750 | #pragma alloc_text(UDIRS,save_udirs,load_setups,save_setups,add_setups)
|
---|
[794] | 1751 | #pragma alloc_text(UDIRS,remove_setup)
|
---|