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