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