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