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