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