| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: undel.c 847 2007-09-29 18:45:16Z gyoung $ | 
|---|
| 5 |  | 
|---|
| 6 | Copyright (c) 1993-98 M. Kimes | 
|---|
| 7 | Copyright (c) 2004, 2006 Steven H. Levine | 
|---|
| 8 |  | 
|---|
| 9 | 01 Aug 04 SHL Rework lstrip/rstrip usage | 
|---|
| 10 | 24 May 05 SHL Rework Win_Error usage | 
|---|
| 11 | 17 Jul 06 SHL Use Runtime_Error | 
|---|
| 12 | 29 Jul 06 SHL Use xfgets_bstripcr | 
|---|
| 13 | 03 Nov 06 SHL Count thread usage | 
|---|
| 14 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148) | 
|---|
| 15 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| 16 |  | 
|---|
| 17 | ***********************************************************************/ | 
|---|
| 18 |  | 
|---|
| 19 | #define INCL_DOSERRORS | 
|---|
| 20 | #define INCL_DOS | 
|---|
| 21 | #define INCL_WIN | 
|---|
| 22 | #define INCL_LONGLONG | 
|---|
| 23 | #include <os2.h> | 
|---|
| 24 |  | 
|---|
| 25 | #include <stdlib.h> | 
|---|
| 26 | #include <stdio.h> | 
|---|
| 27 | #include <string.h> | 
|---|
| 28 | #include <time.h> | 
|---|
| 29 | #include <ctype.h> | 
|---|
| 30 | #include <process.h>                    // _beginthread | 
|---|
| 31 |  | 
|---|
| 32 | #include "fm3dll.h" | 
|---|
| 33 | #include "fm3dlg.h" | 
|---|
| 34 | #include "fm3str.h" | 
|---|
| 35 |  | 
|---|
| 36 | #pragma data_seg(DATA2) | 
|---|
| 37 |  | 
|---|
| 38 | static PSZ pszSrcFile = __FILE__; | 
|---|
| 39 |  | 
|---|
| 40 | struct tempstruct | 
|---|
| 41 | { | 
|---|
| 42 | HWND hwnd; | 
|---|
| 43 | CHAR path[CCHMAXPATH]; | 
|---|
| 44 | BOOL inclsubdirs; | 
|---|
| 45 | }; | 
|---|
| 46 |  | 
|---|
| 47 | static VOID FillUndelListThread(VOID * arg) | 
|---|
| 48 | { | 
|---|
| 49 | HWND hwnd; | 
|---|
| 50 | CHAR s[CCHMAXPATH * 2]; | 
|---|
| 51 | CHAR *path; | 
|---|
| 52 | HAB thab; | 
|---|
| 53 | HMQ thmq; | 
|---|
| 54 | FILE *fp; | 
|---|
| 55 | HFILE oldstdout, newstdout; | 
|---|
| 56 | struct tempstruct *undelinfo; | 
|---|
| 57 | BOOL killme = FALSE; | 
|---|
| 58 | FILESTATUS3 fsa; | 
|---|
| 59 |  | 
|---|
| 60 | undelinfo = (struct tempstruct *)arg; | 
|---|
| 61 | hwnd = undelinfo->hwnd; | 
|---|
| 62 | path = undelinfo->path; | 
|---|
| 63 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 64 |  | 
|---|
| 65 | thab = WinInitialize(0); | 
|---|
| 66 | thmq = WinCreateMsgQueue(thab, 0); | 
|---|
| 67 | if (thab && thmq) { | 
|---|
| 68 | WinCancelShutdown(thmq, TRUE); | 
|---|
| 69 | IncrThreadUsage(); | 
|---|
| 70 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID); | 
|---|
| 71 | unlinkf("%s", "$UDELETE.#$#"); | 
|---|
| 72 | fp = xfopen("$UDELETE.#$#", "w", pszSrcFile, __LINE__); | 
|---|
| 73 | if (!fp) { | 
|---|
| 74 | Win_Error(NULLHANDLE, hwnd, pszSrcFile, __LINE__, | 
|---|
| 75 | GetPString(IDS_REDIRECTERRORTEXT)); | 
|---|
| 76 | killme = TRUE; | 
|---|
| 77 | goto Abort; | 
|---|
| 78 | } | 
|---|
| 79 | else { | 
|---|
| 80 | newstdout = -1; | 
|---|
| 81 | if (DosDupHandle(fileno(stdout), &newstdout)) { | 
|---|
| 82 | saymsg(MB_CANCEL, | 
|---|
| 83 | hwnd, | 
|---|
| 84 | GetPString(IDS_MAYDAYTEXT), GetPString(IDS_REDIRECTERRORTEXT)); | 
|---|
| 85 | fclose(fp); | 
|---|
| 86 | killme = TRUE; | 
|---|
| 87 | goto Abort; | 
|---|
| 88 | } | 
|---|
| 89 | oldstdout = fileno(stdout); | 
|---|
| 90 | DosDupHandle(fileno(fp), &oldstdout); | 
|---|
| 91 | runemf2(SEPARATE | INVISIBLE | WINDOWED | BACKGROUND | WAIT, | 
|---|
| 92 | hwnd, | 
|---|
| 93 | NULL, | 
|---|
| 94 | NULL, | 
|---|
| 95 | "UNDELETE.COM %s /L%s", | 
|---|
| 96 | path, (undelinfo->inclsubdirs) ? " /S" : NullStr); | 
|---|
| 97 | oldstdout = fileno(stdout); | 
|---|
| 98 | DosDupHandle(newstdout, &oldstdout); | 
|---|
| 99 | DosClose(newstdout); | 
|---|
| 100 | fclose(fp); | 
|---|
| 101 | } | 
|---|
| 102 | fp = xfopen("$UDELETE.#$#", "r", pszSrcFile, __LINE__); | 
|---|
| 103 | if (fp) { | 
|---|
| 104 | xfgets(s, sizeof(s), fp, pszSrcFile, __LINE__);   // Skip 1st line | 
|---|
| 105 | while (!feof(fp)) { | 
|---|
| 106 | strset(s, 0); | 
|---|
| 107 | if (!xfgets_bstripcr(s, CCHMAXPATH + 2, fp, pszSrcFile, __LINE__)) | 
|---|
| 108 | break; | 
|---|
| 109 | if (*s) { | 
|---|
| 110 | if (!strnicmp(s, "SYS3194: ", 9)) { | 
|---|
| 111 |  | 
|---|
| 112 | APIRET temp; | 
|---|
| 113 |  | 
|---|
| 114 | strcat(s, " "); | 
|---|
| 115 | xfgets(&s[strlen(s)], CCHMAXPATH + 128 - strlen(s), fp, | 
|---|
| 116 | pszSrcFile, __LINE__); | 
|---|
| 117 | fclose(fp); | 
|---|
| 118 | s[CCHMAXPATH + 128] = 0; | 
|---|
| 119 | stripcr(s); | 
|---|
| 120 | rstrip(s); | 
|---|
| 121 | strcat(s, GetPString(IDS_ASKABOUTUNDELETEHELPTEXT)); | 
|---|
| 122 | temp = saymsg(MB_YESNOCANCEL | MB_ICONEXCLAMATION, | 
|---|
| 123 | hwnd, GetPString(IDS_ERRORTEXT), "%s", s); | 
|---|
| 124 | if (temp == MBID_YES) | 
|---|
| 125 | runemf2(BACKGROUND | INVISIBLE | SEPARATE | WINDOWED, | 
|---|
| 126 | hwnd, | 
|---|
| 127 | NULL, NULL, "%s /C HELP UNDELETE", GetCmdSpec(FALSE)); | 
|---|
| 128 | if (temp == MBID_CANCEL) | 
|---|
| 129 | killme = TRUE; | 
|---|
| 130 | goto Abort; | 
|---|
| 131 | } | 
|---|
| 132 | else if (s[1] != ':') | 
|---|
| 133 | continue; | 
|---|
| 134 | else if ((SHORT) | 
|---|
| 135 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_SEARCHSTRING, | 
|---|
| 136 | MPFROM2SHORT(0, LIT_FIRST), | 
|---|
| 137 | MPFROMP(s)) < 0 | 
|---|
| 138 | && DosQueryPathInfo(s, FIL_STANDARD, &fsa, | 
|---|
| 139 | (ULONG) sizeof(fsa))) | 
|---|
| 140 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_INSERTITEM, | 
|---|
| 141 | MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s)); | 
|---|
| 142 | } | 
|---|
| 143 | } | 
|---|
| 144 | fclose(fp); | 
|---|
| 145 | } | 
|---|
| 146 | Abort: | 
|---|
| 147 | ; | 
|---|
| 148 | } | 
|---|
| 149 | DosForceDelete("$UDELETE.#$#"); | 
|---|
| 150 | if (undelinfo) | 
|---|
| 151 | free(undelinfo); | 
|---|
| 152 | if (thmq) { | 
|---|
| 153 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID); | 
|---|
| 154 | if (killme) | 
|---|
| 155 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); | 
|---|
| 156 | WinDestroyMsgQueue(thmq); | 
|---|
| 157 | } | 
|---|
| 158 | if (thab) { | 
|---|
| 159 | DecrThreadUsage(); | 
|---|
| 160 | WinTerminate(thab); | 
|---|
| 161 | } | 
|---|
| 162 | } | 
|---|
| 163 |  | 
|---|
| 164 | MRESULT EXPENTRY UndeleteDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 165 | { | 
|---|
| 166 | SHORT sSelect; | 
|---|
| 167 | static BOOL listdone, changed = FALSE, refresh = FALSE; | 
|---|
| 168 | static HPOINTER hptrIcon = (HPOINTER) 0; | 
|---|
| 169 |  | 
|---|
| 170 | switch (msg) { | 
|---|
| 171 | case WM_INITDLG: | 
|---|
| 172 | listdone = TRUE; | 
|---|
| 173 | if (!mp2 || !*(CHAR *) mp2) { | 
|---|
| 174 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); | 
|---|
| 175 | WinDismissDlg(hwnd, 0); | 
|---|
| 176 | break; | 
|---|
| 177 | } | 
|---|
| 178 | hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, UNDEL_FRAME); | 
|---|
| 179 | WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptrIcon), MPVOID); | 
|---|
| 180 | WinSendDlgItemMsg(hwnd, UNDEL_ENTRY, EM_SETTEXTLIMIT, | 
|---|
| 181 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID); | 
|---|
| 182 | { | 
|---|
| 183 | CHAR s[CCHMAXPATH]; | 
|---|
| 184 |  | 
|---|
| 185 | strcpy(s, (CHAR *) mp2); | 
|---|
| 186 | if (s[strlen(s) - 1] != '\\') | 
|---|
| 187 | strcat(s, "\\"); | 
|---|
| 188 | strcat(s, "*"); | 
|---|
| 189 | WinSetDlgItemText(hwnd, UNDEL_ENTRY, s); | 
|---|
| 190 | WinCheckButton(hwnd, UNDEL_SUBDIRS, TRUE); | 
|---|
| 191 | FillPathListBox(hwnd, WinWindowFromID(hwnd, UNDEL_DRIVELIST), (HWND) 0, | 
|---|
| 192 | s, TRUE); | 
|---|
| 193 | } | 
|---|
| 194 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 195 | break; | 
|---|
| 196 |  | 
|---|
| 197 | case UM_SETUP: | 
|---|
| 198 | if (listdone) { | 
|---|
| 199 |  | 
|---|
| 200 | struct tempstruct *undelinfo; | 
|---|
| 201 | CHAR s[CCHMAXPATH]; | 
|---|
| 202 |  | 
|---|
| 203 | listdone = FALSE; | 
|---|
| 204 | undelinfo = xmallocz(sizeof(struct tempstruct), pszSrcFile, __LINE__); | 
|---|
| 205 | if (!undelinfo) { | 
|---|
| 206 | listdone = TRUE; | 
|---|
| 207 | WinDismissDlg(hwnd, 0); | 
|---|
| 208 | } | 
|---|
| 209 | else { | 
|---|
| 210 | undelinfo->hwnd = hwnd; | 
|---|
| 211 | WinQueryDlgItemText(hwnd, | 
|---|
| 212 | UNDEL_ENTRY, | 
|---|
| 213 | sizeof(undelinfo->path), undelinfo->path); | 
|---|
| 214 | bstrip(undelinfo->path); | 
|---|
| 215 | MakeFullName(undelinfo->path); | 
|---|
| 216 | undelinfo->inclsubdirs = WinQueryButtonCheckstate(hwnd, | 
|---|
| 217 | UNDEL_SUBDIRS); | 
|---|
| 218 | sprintf(s, | 
|---|
| 219 | GetPString(IDS_UNDELETETITLETEXT), toupper(*undelinfo->path)); | 
|---|
| 220 | WinSetWindowText(hwnd, s); | 
|---|
| 221 | if (_beginthread(FillUndelListThread, NULL, 65536, (PVOID) undelinfo) | 
|---|
| 222 | == -1) { | 
|---|
| 223 | Runtime_Error(pszSrcFile, __LINE__, | 
|---|
| 224 | GetPString(IDS_COULDNTSTARTTHREADTEXT)); | 
|---|
| 225 | free(undelinfo); | 
|---|
| 226 | listdone = TRUE; | 
|---|
| 227 | WinDismissDlg(hwnd, 0); | 
|---|
| 228 | } | 
|---|
| 229 | else | 
|---|
| 230 | DosSleep(100);//05 Aug 07 GKY 500 | 
|---|
| 231 | } | 
|---|
| 232 | refresh = FALSE; | 
|---|
| 233 | } | 
|---|
| 234 | else | 
|---|
| 235 | refresh = TRUE; | 
|---|
| 236 | changed = FALSE; | 
|---|
| 237 | return 0; | 
|---|
| 238 |  | 
|---|
| 239 | case UM_CONTAINER_FILLED: | 
|---|
| 240 | listdone = TRUE; | 
|---|
| 241 | { | 
|---|
| 242 | CHAR s[33]; | 
|---|
| 243 |  | 
|---|
| 244 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, | 
|---|
| 245 | UNDEL_LISTBOX, | 
|---|
| 246 | LM_QUERYITEMCOUNT, MPVOID, MPVOID); | 
|---|
| 247 | sprintf(s, "%d", sSelect); | 
|---|
| 248 | WinSetDlgItemText(hwnd, UNDEL_COUNT, s); | 
|---|
| 249 | if (refresh) | 
|---|
| 250 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 251 | refresh = FALSE; | 
|---|
| 252 | } | 
|---|
| 253 | return 0; | 
|---|
| 254 |  | 
|---|
| 255 | case WM_CONTROL: | 
|---|
| 256 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 257 | case UNDEL_SUBDIRS: | 
|---|
| 258 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 259 | break; | 
|---|
| 260 |  | 
|---|
| 261 | case UNDEL_ENTRY: | 
|---|
| 262 | switch (SHORT2FROMMP(mp1)) { | 
|---|
| 263 | case EN_CHANGE: | 
|---|
| 264 | changed = TRUE; | 
|---|
| 265 | break; | 
|---|
| 266 | case EN_KILLFOCUS: | 
|---|
| 267 | if (changed) | 
|---|
| 268 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 269 | break; | 
|---|
| 270 | } | 
|---|
| 271 | break; | 
|---|
| 272 |  | 
|---|
| 273 | case UNDEL_DRIVELIST: | 
|---|
| 274 | if (!listdone) { | 
|---|
| 275 | Runtime_Error(pszSrcFile, __LINE__, "not listdone"); | 
|---|
| 276 | break; | 
|---|
| 277 | } | 
|---|
| 278 | switch (SHORT2FROMMP(mp1)) { | 
|---|
| 279 | case CBN_ENTER: | 
|---|
| 280 | { | 
|---|
| 281 | CHAR s[CCHMAXPATH], drive, *p; | 
|---|
| 282 |  | 
|---|
| 283 | strset(s, 0); | 
|---|
| 284 | WinQueryDlgItemText(hwnd, UNDEL_DRIVELIST, 3, s); | 
|---|
| 285 | if (!isalpha(*s)) { | 
|---|
| 286 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT); | 
|---|
| 287 | } | 
|---|
| 288 | else { | 
|---|
| 289 | drive = toupper(*s); | 
|---|
| 290 | WinQueryDlgItemText(hwnd, UNDEL_ENTRY, sizeof(s), s); | 
|---|
| 291 | *s = drive; | 
|---|
| 292 | s[1] = ':'; | 
|---|
| 293 | s[2] = '\\'; | 
|---|
| 294 | p = strrchr(s + 2, '\\'); | 
|---|
| 295 | if (p) { | 
|---|
| 296 | p++; | 
|---|
| 297 | if (*p) | 
|---|
| 298 | memmove(s + 3, p, strlen(p) + 1); | 
|---|
| 299 | else { | 
|---|
| 300 | s[3] = '*'; | 
|---|
| 301 | s[4] = 0; | 
|---|
| 302 | } | 
|---|
| 303 | } | 
|---|
| 304 | else { | 
|---|
| 305 | s[3] = '*'; | 
|---|
| 306 | s[4] = 0; | 
|---|
| 307 | } | 
|---|
| 308 | s[CCHMAXPATH - 1] = 0; | 
|---|
| 309 | WinSetDlgItemText(hwnd, UNDEL_ENTRY, s); | 
|---|
| 310 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 311 | } | 
|---|
| 312 | } | 
|---|
| 313 | break; | 
|---|
| 314 | } | 
|---|
| 315 | break; | 
|---|
| 316 |  | 
|---|
| 317 | case UNDEL_LISTBOX: | 
|---|
| 318 | switch (SHORT2FROMMP(mp2)) { | 
|---|
| 319 | case LN_ENTER: | 
|---|
| 320 | WinSendDlgItemMsg(hwnd, DID_OK, BM_CLICK, MPFROMSHORT(TRUE), MPVOID); | 
|---|
| 321 | break; | 
|---|
| 322 | } | 
|---|
| 323 | break; | 
|---|
| 324 |  | 
|---|
| 325 | default: | 
|---|
| 326 | break; | 
|---|
| 327 | } | 
|---|
| 328 | return 0; | 
|---|
| 329 |  | 
|---|
| 330 | case WM_ADJUSTWINDOWPOS: | 
|---|
| 331 | PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID); | 
|---|
| 332 | break; | 
|---|
| 333 |  | 
|---|
| 334 | case UM_STRETCH: | 
|---|
| 335 | { | 
|---|
| 336 | SWP swpC, swp, swpM, swpD, swpL, swpE; | 
|---|
| 337 |  | 
|---|
| 338 | WinQueryWindowPos(hwnd, &swp); | 
|---|
| 339 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) { | 
|---|
| 340 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_LISTBOX), &swpC); | 
|---|
| 341 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_MASKHDR), &swpM); | 
|---|
| 342 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_DRVHDR), &swpD); | 
|---|
| 343 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_DRIVELIST), &swpL); | 
|---|
| 344 | WinQueryWindowPos(WinWindowFromID(hwnd, UNDEL_ENTRY), &swpE); | 
|---|
| 345 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_LISTBOX), HWND_TOP, | 
|---|
| 346 | SysVal(SV_CXSIZEBORDER), | 
|---|
| 347 | swpC.y, | 
|---|
| 348 | swp.cx - (SysVal(SV_CXSIZEBORDER) * 2), | 
|---|
| 349 | (swp.cy - swpC.y) - (SysVal(SV_CYTITLEBAR) + | 
|---|
| 350 | SysVal(SV_CYSIZEBORDER) + | 
|---|
| 351 | swpM.cy + 16), | 
|---|
| 352 | SWP_MOVE | SWP_SIZE); | 
|---|
| 353 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_MASKHDR), HWND_TOP, | 
|---|
| 354 | swpM.x, | 
|---|
| 355 | (swp.cy - swpM.cy) - (SysVal(SV_CYTITLEBAR) + | 
|---|
| 356 | SysVal(SV_CYSIZEBORDER) + 8), | 
|---|
| 357 | swpM.cx, swpM.cy, SWP_MOVE | SWP_SIZE); | 
|---|
| 358 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_DRVHDR), HWND_TOP, | 
|---|
| 359 | swpD.x, | 
|---|
| 360 | (swp.cy - swpM.cy) - (SysVal(SV_CYTITLEBAR) + | 
|---|
| 361 | SysVal(SV_CYSIZEBORDER) + 8), | 
|---|
| 362 | swpD.cx, swpM.cy, SWP_MOVE | SWP_SIZE); | 
|---|
| 363 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_DRIVELIST), HWND_TOP, | 
|---|
| 364 | swpL.x, | 
|---|
| 365 | SysVal(SV_CYSIZEBORDER), | 
|---|
| 366 | swpL.cx, | 
|---|
| 367 | swp.cy - (SysVal(SV_CYTITLEBAR) + | 
|---|
| 368 | (SysVal(SV_CYSIZEBORDER) * 2) + 6), | 
|---|
| 369 | SWP_MOVE | SWP_SIZE); | 
|---|
| 370 | WinSetWindowPos(WinWindowFromID(hwnd, UNDEL_ENTRY), HWND_TOP, | 
|---|
| 371 | swpM.x + swpM.cx + 4, | 
|---|
| 372 | (swp.cy - swpM.cy) - (SysVal(SV_CYTITLEBAR) + | 
|---|
| 373 | SysVal(SV_CYSIZEBORDER) + 8), | 
|---|
| 374 | swp.cx - ((swpM.x + swpM.cx + 4) + | 
|---|
| 375 | (SysVal(SV_CXSIZEBORDER) + 8)), | 
|---|
| 376 | swpM.cy + 2, SWP_MOVE | SWP_SIZE); | 
|---|
| 377 | WinInvalidateRect(WinWindowFromID(hwnd, UNDEL_ENTRY), NULL, FALSE); | 
|---|
| 378 | } | 
|---|
| 379 | } | 
|---|
| 380 | return 0; | 
|---|
| 381 |  | 
|---|
| 382 | case WM_COMMAND: | 
|---|
| 383 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 384 | case UNDEL_DEL: | 
|---|
| 385 | case DID_OK: | 
|---|
| 386 | if (changed || !listdone) { | 
|---|
| 387 | Runtime_Error(pszSrcFile, __LINE__, "not done"); | 
|---|
| 388 | } | 
|---|
| 389 | else { | 
|---|
| 390 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, | 
|---|
| 391 | LM_QUERYSELECTION, | 
|---|
| 392 | MPFROMSHORT(LIT_FIRST), MPVOID); | 
|---|
| 393 | if (sSelect >= 0) { | 
|---|
| 394 |  | 
|---|
| 395 | FILE *fp; | 
|---|
| 396 | CHAR s[CCHMAXPATH + 1]; | 
|---|
| 397 |  | 
|---|
| 398 | DosForceDelete("\\FMUNDEL.CMD"); | 
|---|
| 399 | fp = xfopen("\\FMUNDEL.CMD", "w", pszSrcFile, __LINE__); | 
|---|
| 400 | if (fp) { | 
|---|
| 401 | while (sSelect >= 0) { | 
|---|
| 402 | *s = 0; | 
|---|
| 403 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_QUERYITEMTEXT, | 
|---|
| 404 | MPFROM2SHORT(sSelect, CCHMAXPATH), | 
|---|
| 405 | MPFROMP(s)); | 
|---|
| 406 | if (SHORT1FROMMP(mp1) == UNDEL_DEL) | 
|---|
| 407 | WinSendDlgItemMsg(hwnd, UNDEL_LISTBOX, LM_DELETEITEM, | 
|---|
| 408 | MPFROM2SHORT(sSelect, 0), MPVOID); | 
|---|
| 409 | if (*s) { | 
|---|
| 410 | if (SHORT1FROMMP(mp1) == DID_OK) | 
|---|
| 411 | fprintf(fp, | 
|---|
| 412 | "IF NOT EXIST \"%s\" UNDELETE.COM \"%s\" /A\n", | 
|---|
| 413 | s, s); | 
|---|
| 414 | else | 
|---|
| 415 | fprintf(fp, "UNDELETE.COM \"%s\" /F /A\n", s); | 
|---|
| 416 | } | 
|---|
| 417 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd, | 
|---|
| 418 | UNDEL_LISTBOX, | 
|---|
| 419 | LM_QUERYSELECTION, | 
|---|
| 420 | (SHORT1FROMMP(mp1) == | 
|---|
| 421 | DID_OK) ? | 
|---|
| 422 | MPFROMSHORT(sSelect) : | 
|---|
| 423 | MPFROMSHORT(LIT_FIRST), | 
|---|
| 424 | MPVOID); | 
|---|
| 425 | } | 
|---|
| 426 | fprintf(fp, "DEL \\FMUNDEL.CMD /F\n"); | 
|---|
| 427 | fclose(fp); | 
|---|
| 428 | runemf2(WINDOWED | BACKGROUND | SEPARATE | INVISIBLE, | 
|---|
| 429 | hwnd, | 
|---|
| 430 | NULL, NULL, "%s /C \\FMUNDEL.CMD", GetCmdSpec(FALSE)); | 
|---|
| 431 | } | 
|---|
| 432 | } | 
|---|
| 433 | if (SHORT1FROMMP(mp1) == DID_OK) | 
|---|
| 434 | WinDismissDlg(hwnd, 0); | 
|---|
| 435 | { | 
|---|
| 436 | CHAR s[33]; | 
|---|
| 437 |  | 
|---|
| 438 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, | 
|---|
| 439 | UNDEL_LISTBOX, | 
|---|
| 440 | LM_QUERYITEMCOUNT, | 
|---|
| 441 | MPVOID, MPVOID); | 
|---|
| 442 | sprintf(s, "%d", sSelect); | 
|---|
| 443 | WinSetDlgItemText(hwnd, UNDEL_COUNT, s); | 
|---|
| 444 | } | 
|---|
| 445 | } | 
|---|
| 446 | break; | 
|---|
| 447 |  | 
|---|
| 448 | case DID_CANCEL: | 
|---|
| 449 | if (!listdone) | 
|---|
| 450 | Runtime_Error(pszSrcFile, __LINE__, "is busy"); | 
|---|
| 451 | else | 
|---|
| 452 | WinDismissDlg(hwnd, 0); | 
|---|
| 453 | break; | 
|---|
| 454 |  | 
|---|
| 455 | case IDM_HELP: | 
|---|
| 456 | saymsg(MB_ENTER | MB_ICONASTERISK, | 
|---|
| 457 | hwnd, | 
|---|
| 458 | GetPString(IDS_UNDELETEHELPTITLETEXT), | 
|---|
| 459 | GetPString(IDS_UNDELETEHELPTEXT)); | 
|---|
| 460 | break; | 
|---|
| 461 | } | 
|---|
| 462 | return 0; | 
|---|
| 463 |  | 
|---|
| 464 | case WM_CLOSE: | 
|---|
| 465 | if (!listdone) { | 
|---|
| 466 | Runtime_Error(pszSrcFile, __LINE__, "not listdone"); | 
|---|
| 467 | return 0; | 
|---|
| 468 | } | 
|---|
| 469 | break; | 
|---|
| 470 |  | 
|---|
| 471 | case WM_DESTROY: | 
|---|
| 472 | if (hptrIcon) | 
|---|
| 473 | WinDestroyPointer(hptrIcon); | 
|---|
| 474 | hptrIcon = (HPOINTER) 0; | 
|---|
| 475 | break; | 
|---|
| 476 | } | 
|---|
| 477 | return WinDefDlgProc(hwnd, msg, mp1, mp2); | 
|---|
| 478 | } | 
|---|
| 479 |  | 
|---|
| 480 | #pragma alloc_text(UNDELETE,FillUndelListThread,UndeleteDlgProc) | 
|---|