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