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