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