1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: info.c 1544 2010-09-30 13:00:59Z gyoung $
|
---|
5 |
|
---|
6 | Info windows
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2001, 2010 Steven H. Levine
|
---|
10 |
|
---|
11 | 16 Oct 02 SHL Handle large partitions
|
---|
12 | 12 Feb 03 SHL FileInfoProc: standardize EA math
|
---|
13 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
14 | 23 May 05 SHL Use QWL_USER
|
---|
15 | 25 May 05 SHL Use ULONGLONG and CommaFmtULL
|
---|
16 | 05 Jun 05 SHL Use QWL_USER
|
---|
17 | 14 Jul 06 SHL Use Runtime_Error
|
---|
18 | 24 Mar 07 SHL Correct FileInfoProc binary file detect
|
---|
19 | 24 Mar 07 SHL Correct FileInfoProc/IconProc race crash
|
---|
20 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
|
---|
21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
22 | 25 Aug 07 SHL Drop list from FILESTUF - data not static
|
---|
23 | 25 Aug 07 SHL IconProc: do not use freed memory - random bad things happen
|
---|
24 | 27 Sep 07 SHL Correct ULONGLONG size formatting
|
---|
25 | 30 Dec 07 GKY Use CommaFmtULL
|
---|
26 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
27 | 25 Dec 08 GKY Add code to allow write verify to be turned off on a per drive basis
|
---|
28 | 25 Dec 08 GKY Add DRIVE_RSCANNED flag to monitor for the first recursive drive scan per session
|
---|
29 | to prevent duplicate directory names in tree following a copy before initial scan.
|
---|
30 | 11 Jan 08 GKY Add Write verify off and recures scan to drive info display when appropriate.
|
---|
31 | 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
|
---|
32 | 07 Feb 09 GKY Add *DateFormat functions to format dates based on locale
|
---|
33 | 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
|
---|
34 | 12 Jul 09 GKY Remove code to update recursive scan setting which isn't user setable
|
---|
35 | 22 Jul 09 GKY Check if drives support EAs add driveflag for this
|
---|
36 | 22 Jul 09 GKY Add LocalHD driveflag
|
---|
37 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
38 |
|
---|
39 | ***********************************************************************/
|
---|
40 |
|
---|
41 | #include <stdlib.h>
|
---|
42 | #include <string.h>
|
---|
43 | #include <ctype.h>
|
---|
44 | #include <share.h>
|
---|
45 |
|
---|
46 | #define INCL_DOS
|
---|
47 | #define INCL_WIN
|
---|
48 | #define INCL_GPI
|
---|
49 | #define INCL_LONGLONG
|
---|
50 |
|
---|
51 | #include "fm3dll.h"
|
---|
52 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
53 | #include "draglist.h" // Data declaration(s)
|
---|
54 | #include "notebook.h" // Data declaration(s)
|
---|
55 | #include "inis.h" // Data declaration(s)
|
---|
56 | #include "init.h" // Data declaration(s)
|
---|
57 | #include "mainwnd.h" // Data declaration(s)
|
---|
58 | #include "fm3dlg.h"
|
---|
59 | #include "fm3str.h"
|
---|
60 | #include "makelist.h" // AddToList
|
---|
61 | #include "errutil.h" // Dos_Error...
|
---|
62 | #include "strutil.h" // GetPString
|
---|
63 | #include "attribs.h" // AttrListDlgProc
|
---|
64 | #include "defview.h" // DefaultView
|
---|
65 | #include "info.h"
|
---|
66 | #include "valid.h" // CheckDrive, IsBinary
|
---|
67 | #include "seticon.h" // SetIconDlgProc
|
---|
68 | #include "droplist.h" // AcceptOneDrop, DropHelp, GetOneDrop
|
---|
69 | #include "eas.h" // DisplayEAsProc
|
---|
70 | #include "misc.h" // DrawTargetEmphasis
|
---|
71 | #include "notify.h" // Notify
|
---|
72 | #include "shadow.h" // OpenObject
|
---|
73 | #include "chklist.h" // PopupMenu
|
---|
74 | #include "presparm.h" // SetPresParams
|
---|
75 | #include "strips.h" // bstrip
|
---|
76 | #include "i18nutil.h" // CommaFmtULL
|
---|
77 | #include "wrappers.h" // xDosFindFirst
|
---|
78 | #include "fortify.h"
|
---|
79 |
|
---|
80 | // Data definitions
|
---|
81 | #pragma data_seg(DATA1)
|
---|
82 | static PSZ pszSrcFile = __FILE__;
|
---|
83 |
|
---|
84 | #pragma data_seg(GLOBAL1)
|
---|
85 | INT driveflags[26];
|
---|
86 |
|
---|
87 | CHAR *FlagMsg(CHAR drive, CHAR * buffer)
|
---|
88 | {
|
---|
89 | ULONG x;
|
---|
90 | BOOL once = FALSE;
|
---|
91 | register CHAR *p;
|
---|
92 |
|
---|
93 | if (buffer) {
|
---|
94 | *buffer = 0;
|
---|
95 | p = buffer;
|
---|
96 | if (isalpha(drive)) {
|
---|
97 | if (driveflags[toupper(drive) - 'A']) {
|
---|
98 | for (x = IDS_FLREMOVABLETEXT; x < IDS_FLRECURSESCANDONETEXT + 1; x++) {
|
---|
99 | if (driveflags[toupper(drive) - 'A'] &
|
---|
100 | (1 << (x - IDS_FLREMOVABLETEXT))) {
|
---|
101 | if (once) {
|
---|
102 | *p = ' ';
|
---|
103 | p++;
|
---|
104 | }
|
---|
105 | else
|
---|
106 | once = TRUE;
|
---|
107 | *p = '[';
|
---|
108 | p++;
|
---|
109 | strcpy(p, GetPString(x));
|
---|
110 | p += strlen(p);
|
---|
111 | *p = ']';
|
---|
112 | p++;
|
---|
113 | *p = 0;
|
---|
114 | }
|
---|
115 | }
|
---|
116 | }
|
---|
117 | else
|
---|
118 | strcpy(buffer, "[None]");
|
---|
119 | }
|
---|
120 | }
|
---|
121 | return buffer;
|
---|
122 | }
|
---|
123 |
|
---|
124 | MRESULT EXPENTRY DrvInfoProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
125 | {
|
---|
126 | CHAR *pszFileName;
|
---|
127 | CHAR szMB[20];
|
---|
128 | CHAR szKB[20];
|
---|
129 | CHAR szUnits[20];
|
---|
130 | APIRET rc;
|
---|
131 |
|
---|
132 | switch (msg) {
|
---|
133 | case WM_INITDLG:
|
---|
134 | if (mp2) {
|
---|
135 |
|
---|
136 | CHAR s[CCHMAXPATH * 2];
|
---|
137 | ULONG type;
|
---|
138 |
|
---|
139 | pszFileName = (CHAR *)mp2;
|
---|
140 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) pszFileName);
|
---|
141 | WinSendDlgItemMsg(hwnd,
|
---|
142 | INFO_LABEL,
|
---|
143 | EM_SETTEXTLIMIT,
|
---|
144 | MPFROM2SHORT(CCHMAXPATHCOMP, 0), MPVOID);
|
---|
145 | if (!(driveflags[toupper(*pszFileName) - 'A'] & DRIVE_NOSTATS)){
|
---|
146 | WinSendDlgItemMsg(hwnd,
|
---|
147 | INFO_FREE,
|
---|
148 | SLM_SETSLIDERINFO,
|
---|
149 | MPFROM2SHORT(SMA_SLIDERARMDIMENSIONS, 0),
|
---|
150 | MPFROM2SHORT(0, 0));
|
---|
151 | WinSendDlgItemMsg(hwnd,
|
---|
152 | INFO_USED,
|
---|
153 | SLM_SETSLIDERINFO,
|
---|
154 | MPFROM2SHORT(SMA_SLIDERARMDIMENSIONS, 0),
|
---|
155 | MPFROM2SHORT(0, 0));
|
---|
156 | }
|
---|
157 | if (driveflags[toupper(*pszFileName) - 'A'] & DRIVE_NOTWRITEABLE) {
|
---|
158 | WinSendDlgItemMsg(hwnd,
|
---|
159 | INFO_LABEL,
|
---|
160 | EM_SETREADONLY, MPFROM2SHORT(TRUE, 0), MPVOID);
|
---|
161 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, DID_OK));
|
---|
162 | }
|
---|
163 | if (IsFullName(pszFileName)) {
|
---|
164 |
|
---|
165 | CHAR FileSystem[CCHMAXPATH * 2];
|
---|
166 |
|
---|
167 | sprintf(FileSystem,
|
---|
168 | GetPString(IDS_DRIVEINFOTITLETEXT), toupper(*pszFileName));
|
---|
169 | WinSetWindowText(hwnd, FileSystem);
|
---|
170 | if (CheckDrive(toupper(*pszFileName), FileSystem, &type) != -1){
|
---|
171 |
|
---|
172 | FSALLOCATE fsa;
|
---|
173 |
|
---|
174 | if (type & (DRIVE_REMOTE | DRIVE_ZIPSTREAM | DRIVE_VIRTUAL)) {
|
---|
175 |
|
---|
176 | CHAR Path[3], *pfsn, *pfsd;
|
---|
177 | ULONG Size;
|
---|
178 | APIRET rc;
|
---|
179 | PFSQBUFFER2 pfsq;
|
---|
180 |
|
---|
181 | Path[0] = toupper(*pszFileName);
|
---|
182 | Path[1] = ':';
|
---|
183 | Path[2] = 0;
|
---|
184 | Size = sizeof(s);
|
---|
185 | DosError(FERR_DISABLEHARDERR);
|
---|
186 | rc = DosQueryFSAttach(Path,
|
---|
187 | 0, FSAIL_QUERYNAME, (PFSQBUFFER2) s, &Size);
|
---|
188 | if (!rc) {
|
---|
189 | pfsq = (PFSQBUFFER2) s;
|
---|
190 | pfsn = (PCHAR)(pfsq->szName) + pfsq->cbName + 1;
|
---|
191 | pfsd = pfsn + pfsq->cbFSDName + 1;
|
---|
192 | if (pfsq->cbFSAData && pfsd && *pfsd) {
|
---|
193 | sprintf(s, " (%s)", pfsd);
|
---|
194 | WinSetDlgItemText(hwnd, INFO_REALPATH, s);
|
---|
195 | }
|
---|
196 | }
|
---|
197 | }
|
---|
198 |
|
---|
199 | DosError(FERR_DISABLEHARDERR);
|
---|
200 | if (!DosQueryFSInfo(toupper(*pszFileName) - '@',
|
---|
201 | FSIL_ALLOC, &fsa, sizeof(FSALLOCATE))) {
|
---|
202 |
|
---|
203 | struct
|
---|
204 | {
|
---|
205 | ULONG serial;
|
---|
206 | CHAR volumelength;
|
---|
207 | CHAR volumelabel[CCHMAXPATH];
|
---|
208 | }
|
---|
209 | volser;
|
---|
210 | ULONG percentfree, percentused;
|
---|
211 |
|
---|
212 | memset(&volser, 0, sizeof(volser));
|
---|
213 | DosError(FERR_DISABLEHARDERR);
|
---|
214 | if (!DosQueryFSInfo(toupper(*pszFileName) - '@',
|
---|
215 | FSIL_VOLSER,
|
---|
216 | &volser, (ULONG) sizeof(volser))) {
|
---|
217 | WinSetDlgItemText(hwnd, INFO_FS, FileSystem);
|
---|
218 | WinSetDlgItemText(hwnd, INFO_LABEL, volser.volumelabel);
|
---|
219 | sprintf(s, "%lx", volser.serial);
|
---|
220 | WinSetDlgItemText(hwnd, INFO_SERIAL, s);
|
---|
221 | FlagMsg(*pszFileName, s);
|
---|
222 | WinSetDlgItemText(hwnd, INFO_FLAGS, s);
|
---|
223 | if (!(driveflags[toupper(*pszFileName) - 'A'] & DRIVE_NOSTATS)){
|
---|
224 | CommaFmtULL(szMB, sizeof(szMB),
|
---|
225 | (ULONGLONG) fsa.cUnit *
|
---|
226 | (fsa.cSectorUnit * fsa.cbSector), 'M');
|
---|
227 | CommaFmtULL(szKB, sizeof(szKB),
|
---|
228 | (ULONGLONG) fsa.cUnit *
|
---|
229 | (fsa.cSectorUnit * fsa.cbSector), 'K');
|
---|
230 | CommaFmtULL(szUnits, sizeof(szUnits),
|
---|
231 | (ULONGLONG) fsa.cUnit, ' ');
|
---|
232 | sprintf(s, "%s, %s, %s %s%s", szMB, szKB, szUnits, GetPString(IDS_UNITTEXT), &"s"[fsa.cUnit == 1L]); // hack cough
|
---|
233 | WinSetDlgItemText(hwnd, INFO_TOTAL, s);
|
---|
234 |
|
---|
235 | CommaFmtULL(szMB, sizeof(szMB),
|
---|
236 | (ULONGLONG) fsa.cUnitAvail *
|
---|
237 | (fsa.cSectorUnit * fsa.cbSector), 'M');
|
---|
238 | CommaFmtULL(szKB, sizeof(szKB),
|
---|
239 | (ULONGLONG) fsa.cUnitAvail *
|
---|
240 | (fsa.cSectorUnit * fsa.cbSector), 'K');
|
---|
241 | CommaFmtULL(szUnits, sizeof(szUnits),
|
---|
242 | (ULONGLONG) fsa.cUnitAvail, ' ');
|
---|
243 | sprintf(s, "%s, %s, %s %s%s",
|
---|
244 | szMB, szKB, szUnits,
|
---|
245 | GetPString(IDS_UNITTEXT), &"s"[fsa.cUnitAvail == 1L]);
|
---|
246 | WinSetDlgItemText(hwnd, INFO_AVAILABLE, s);
|
---|
247 | sprintf(s,
|
---|
248 | GetPString(IDS_SECTORSTEXT),
|
---|
249 | fsa.cbSector,
|
---|
250 | fsa.cSectorUnit, &"s"[fsa.cSectorUnit == 1L]);
|
---|
251 | WinSetDlgItemText(hwnd, INFO_ALLOCUNITS, s);
|
---|
252 |
|
---|
253 | percentfree = (fsa.cUnitAvail && fsa.cUnit) ?
|
---|
254 | ((ULONG) fsa.cUnitAvail * 100) / (ULONG) fsa.cUnit : 0;
|
---|
255 | if (!percentfree && fsa.cUnitAvail)
|
---|
256 | percentfree = 1;
|
---|
257 | percentused = 100 - percentfree;
|
---|
258 | WinSendDlgItemMsg(hwnd,
|
---|
259 | INFO_USED,
|
---|
260 | SLM_SETSLIDERINFO,
|
---|
261 | MPFROM2SHORT(SMA_SLIDERARMPOSITION,
|
---|
262 | SMA_INCREMENTVALUE),
|
---|
263 | MPFROMSHORT(percentused));
|
---|
264 | WinSendDlgItemMsg(hwnd,
|
---|
265 | INFO_FREE,
|
---|
266 | SLM_SETSLIDERINFO,
|
---|
267 | MPFROM2SHORT(SMA_SLIDERARMPOSITION,
|
---|
268 | SMA_INCREMENTVALUE),
|
---|
269 | MPFROMSHORT(percentfree));
|
---|
270 | sprintf(s, "%u%%", percentused);
|
---|
271 | WinSetDlgItemText(hwnd, INFO_USEDPERCENT, s);
|
---|
272 | sprintf(s, "%u%%", percentfree);
|
---|
273 | WinSetDlgItemText(hwnd, INFO_FREEPERCENT, s);
|
---|
274 | }
|
---|
275 | else
|
---|
276 | WinSetDlgItemText(hwnd, INFO_AVAILABLE, (CHAR *) GetPString(IDS_STATSMEANINGLESSTEXT));
|
---|
277 | }
|
---|
278 | else {
|
---|
279 | sprintf(FileSystem,
|
---|
280 | GetPString(IDS_CANTQUERYVOLTEXT),
|
---|
281 | toupper(*pszFileName));
|
---|
282 | Notify(FileSystem);
|
---|
283 | WinDismissDlg(hwnd, 0);
|
---|
284 | }
|
---|
285 | }
|
---|
286 | else {
|
---|
287 | sprintf(FileSystem,
|
---|
288 | GetPString(IDS_CANTQUERYALLOCTEXT),
|
---|
289 | toupper(*pszFileName));
|
---|
290 | Notify(FileSystem);
|
---|
291 | WinDismissDlg(hwnd, 0);
|
---|
292 | }
|
---|
293 | }
|
---|
294 | else {
|
---|
295 | FlagMsg(*pszFileName, s);
|
---|
296 | sprintf(FileSystem,
|
---|
297 | GetPString(IDS_DRIVEINACCESSIBLETEXT),
|
---|
298 | toupper(*pszFileName), s);
|
---|
299 | Notify(FileSystem);
|
---|
300 | WinDismissDlg(hwnd, 0);
|
---|
301 | }
|
---|
302 | }
|
---|
303 | else {
|
---|
304 | WinDismissDlg(hwnd, 0);
|
---|
305 | }
|
---|
306 | }
|
---|
307 | else
|
---|
308 | WinDismissDlg(hwnd, 0);
|
---|
309 | break;
|
---|
310 |
|
---|
311 | case WM_CONTROL:
|
---|
312 | return 0;
|
---|
313 |
|
---|
314 | case WM_COMMAND:
|
---|
315 | switch (SHORT1FROMMP(mp1)) {
|
---|
316 | case DID_CANCEL:
|
---|
317 | WinDismissDlg(hwnd, 0);
|
---|
318 | break;
|
---|
319 |
|
---|
320 | case IDM_HELP:
|
---|
321 | if (hwndHelp)
|
---|
322 | WinSendMsg(hwndHelp,
|
---|
323 | HM_DISPLAY_HELP,
|
---|
324 | MPFROM2SHORT(HELP_DRVINFO, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
325 | break;
|
---|
326 |
|
---|
327 | case DID_OK:
|
---|
328 | pszFileName = INSTDATA(hwnd);
|
---|
329 | if (!(driveflags[toupper(*pszFileName) - 'A'] & DRIVE_NOTWRITEABLE)) {
|
---|
330 |
|
---|
331 | CHAR s[CCHMAXPATHCOMP + 3];
|
---|
332 |
|
---|
333 | *s = 0;
|
---|
334 | WinQueryDlgItemText(hwnd, INFO_LABEL, CCHMAXPATHCOMP, s);
|
---|
335 | bstrip(s);
|
---|
336 | if (*s) {
|
---|
337 | struct
|
---|
338 | {
|
---|
339 | ULONG serial;
|
---|
340 | CHAR volumelength;
|
---|
341 | CHAR volumelabel[CCHMAXPATH];
|
---|
342 | }
|
---|
343 | volser;
|
---|
344 |
|
---|
345 | memset(&volser, 0, sizeof(volser));
|
---|
346 | DosError(FERR_DISABLEHARDERR);
|
---|
347 | if (!DosQueryFSInfo(toupper(*pszFileName) - '@',
|
---|
348 | FSIL_VOLSER,
|
---|
349 | &volser,
|
---|
350 | (ULONG) sizeof(volser)) &&
|
---|
351 | stricmp(s, volser.volumelabel)) {
|
---|
352 | memmove(s + 1, s, strlen(s) + 1);
|
---|
353 | *s = strlen(s + 1);
|
---|
354 | DosError(FERR_DISABLEHARDERR);
|
---|
355 | rc = DosSetFSInfo(toupper(*pszFileName) - '@',
|
---|
356 | 2L, (PVOID) s, (ULONG) sizeof(s));
|
---|
357 | if (rc) {
|
---|
358 | Dos_Error(MB_CANCEL, rc, hwnd, __FILE__, __LINE__,
|
---|
359 | "DosSetFSInfo failed");
|
---|
360 | }
|
---|
361 | }
|
---|
362 | }
|
---|
363 | }
|
---|
364 | WinDismissDlg(hwnd, 1);
|
---|
365 | break;
|
---|
366 | }
|
---|
367 | return 0;
|
---|
368 | }
|
---|
369 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
370 | }
|
---|
371 |
|
---|
372 | typedef struct {
|
---|
373 | USHORT size;
|
---|
374 | CHAR szFileName[CCHMAXPATH];
|
---|
375 | BOOL madechanges;
|
---|
376 | } FILESTUF;
|
---|
377 |
|
---|
378 | typedef struct {
|
---|
379 | USHORT size;
|
---|
380 | PFNWP oldproc;
|
---|
381 | FILESTUF *pfs;
|
---|
382 | HWND lasthwndMenu;
|
---|
383 | } ICONSTUF;
|
---|
384 |
|
---|
385 | /*
|
---|
386 | * subclass routine to allow changing a program's icon
|
---|
387 | */
|
---|
388 |
|
---|
389 | MRESULT EXPENTRY IconProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
390 | {
|
---|
391 | ICONSTUF *pis = (ICONSTUF *)WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
392 | MRESULT mr;
|
---|
393 | CHAR *p;
|
---|
394 |
|
---|
395 | static BOOL emphasized = FALSE;
|
---|
396 |
|
---|
397 | if (!pis) {
|
---|
398 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
399 | if (msg != WM_DESTROY)
|
---|
400 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
401 | }
|
---|
402 |
|
---|
403 | switch (msg) {
|
---|
404 | case DM_DRAGOVER:
|
---|
405 | if (!emphasized) {
|
---|
406 | emphasized = TRUE;
|
---|
407 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
408 | }
|
---|
409 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
410 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
411 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
412 |
|
---|
413 | case DM_DRAGLEAVE:
|
---|
414 | emphasized = FALSE;
|
---|
415 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
416 | break;
|
---|
417 |
|
---|
418 | case DM_DROPHELP:
|
---|
419 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_DROPCHGICONHELPTEXT));
|
---|
420 | return 0;
|
---|
421 |
|
---|
422 | case DM_DROP:
|
---|
423 | {
|
---|
424 | HPOINTER hptr;
|
---|
425 | CHAR szFrom[CCHMAXPATH + 2];
|
---|
426 | ICONINFO ici;
|
---|
427 |
|
---|
428 | emphasized = FALSE;
|
---|
429 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
430 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom))) {
|
---|
431 | memset(&ici, 0, sizeof(ICONINFO));
|
---|
432 | ici.cb = sizeof(ICONINFO);
|
---|
433 | ici.fFormat = ICON_FILE;
|
---|
434 | ici.pszFileName = szFrom;
|
---|
435 | if (!WinSetFileIcon((PSZ) pis->pfs->szFileName, (PICONINFO) & ici)) {
|
---|
436 | ici.fFormat = ICON_CLEAR;
|
---|
437 | WinSetFileIcon((PSZ) pis->pfs->szFileName, (PICONINFO) & ici);
|
---|
438 | }
|
---|
439 | hptr = WinLoadFileIcon(pis->pfs->szFileName, FALSE);
|
---|
440 | if (!hptr)
|
---|
441 | hptr = (!IsFile(pis->pfs->szFileName)) ? hptrDir : hptrFile;
|
---|
442 | if (pis && pis->oldproc) {
|
---|
443 | WinShowWindow(hwnd, FALSE);
|
---|
444 | pis->oldproc(hwnd, SM_SETHANDLE, MPFROMLONG(hptr), MPVOID);
|
---|
445 | WinShowWindow(hwnd, TRUE);
|
---|
446 | WinInvalidateRect(WinQueryWindow(hwnd, QW_PARENT), NULL, TRUE);
|
---|
447 | }
|
---|
448 | }
|
---|
449 | }
|
---|
450 | return 0;
|
---|
451 |
|
---|
452 | case WM_PAINT:
|
---|
453 | mr = pis->oldproc(hwnd, msg, mp1, mp2);
|
---|
454 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
|
---|
455 | return mr;
|
---|
456 | break;
|
---|
457 |
|
---|
458 | case WM_MENUEND:
|
---|
459 | if (pis->lasthwndMenu == (HWND)mp2)
|
---|
460 | WinDestroyWindow(pis->lasthwndMenu);
|
---|
461 | pis->lasthwndMenu = (HWND) 0;
|
---|
462 | break;
|
---|
463 |
|
---|
464 | case WM_CONTEXTMENU:
|
---|
465 | if (pis->lasthwndMenu)
|
---|
466 | WinDestroyWindow(pis->lasthwndMenu);
|
---|
467 | pis->lasthwndMenu = WinLoadMenu(hwnd, FM3ModHandle, FLE_FRAME);
|
---|
468 | if (pis->lasthwndMenu) {
|
---|
469 | p = strrchr(pis->pfs->szFileName, '.');
|
---|
470 | if (!p || (stricmp(p, PCSZ_DOTICO) && stricmp(p, PCSZ_DOTPTR)))
|
---|
471 | WinSendMsg(pis->lasthwndMenu,
|
---|
472 | MM_DELETEITEM,
|
---|
473 | MPFROM2SHORT(IDM_SELECTALL, TRUE), MPVOID);
|
---|
474 | PopupMenu(hwnd, hwnd, pis->lasthwndMenu);
|
---|
475 | }
|
---|
476 | break;
|
---|
477 |
|
---|
478 | case WM_COMMAND:
|
---|
479 | switch (SHORT1FROMMP(mp1)) {
|
---|
480 | case IDM_SELECTALL:
|
---|
481 | case IDM_DESELECTALL:
|
---|
482 | WinDlgBox(HWND_DESKTOP,
|
---|
483 | hwnd,
|
---|
484 | SetIconDlgProc,
|
---|
485 | FM3ModHandle,
|
---|
486 | SETICON_FRAME,
|
---|
487 | (PVOID) ((SHORT1FROMMP(mp1) == IDM_SELECTALL) ?
|
---|
488 | pis->pfs->szFileName : NULL));
|
---|
489 | break;
|
---|
490 | }
|
---|
491 | return 0;
|
---|
492 |
|
---|
493 | case WM_DESTROY:
|
---|
494 | emphasized = FALSE;
|
---|
495 | if (!pis)
|
---|
496 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
497 | else {
|
---|
498 | PFNWP oldproc = pis->oldproc;
|
---|
499 | if (pis->lasthwndMenu)
|
---|
500 | WinDestroyWindow(pis->lasthwndMenu);
|
---|
501 | free(pis);
|
---|
502 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
503 | }
|
---|
504 | break;
|
---|
505 | }
|
---|
506 |
|
---|
507 | return pis->oldproc(hwnd, msg, mp1, mp2);
|
---|
508 | }
|
---|
509 |
|
---|
510 | MRESULT EXPENTRY FileInfoProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
511 | {
|
---|
512 | FILESTUF *pfs;
|
---|
513 | ICONSTUF *pis;
|
---|
514 | CHAR **ppsz;
|
---|
515 |
|
---|
516 | switch (msg) {
|
---|
517 | case WM_INITDLG:
|
---|
518 | if (!mp2) {
|
---|
519 | WinDismissDlg(hwnd, 1);
|
---|
520 | break;
|
---|
521 | }
|
---|
522 | pfs = xmallocz(sizeof(FILESTUF), pszSrcFile, __LINE__);
|
---|
523 | if (!pfs) {
|
---|
524 | WinDismissDlg(hwnd, 1);
|
---|
525 | break;
|
---|
526 | }
|
---|
527 | pfs->size = sizeof(FILESTUF);
|
---|
528 | WinSetWindowPtr(hwnd, QWL_USER, pfs);
|
---|
529 | {
|
---|
530 | USHORT ids[] = { FLE_SIZES, FLE_SLACK, FLE_LASTWRITE, FLE_CREATE,
|
---|
531 | FLE_LASTACCESS, 0
|
---|
532 | };
|
---|
533 | INT x;
|
---|
534 | CHAR s[CCHMAXPATH];
|
---|
535 |
|
---|
536 | ppsz = (CHAR **)mp2;
|
---|
537 | for (x = 0; ppsz[x]; x++) {
|
---|
538 | if (DosQueryPathInfo(ppsz[x], FIL_QUERYFULLNAME, s, sizeof(s)))
|
---|
539 | strcpy(s, ppsz[x]);
|
---|
540 | WinSendDlgItemMsg(hwnd,
|
---|
541 | FLE_NAME,
|
---|
542 | LM_INSERTITEM,
|
---|
543 | MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(s));
|
---|
544 | }
|
---|
545 | if (!x) {
|
---|
546 | WinDismissDlg(hwnd, 1);
|
---|
547 | break;
|
---|
548 | }
|
---|
549 | WinSendDlgItemMsg(hwnd,
|
---|
550 | FLE_NAME,
|
---|
551 | LM_SELECTITEM, MPFROM2SHORT(0, 0), MPFROMSHORT(TRUE));
|
---|
552 | for (x = 0; ids[x]; x++)
|
---|
553 | SetPresParams(WinWindowFromID(hwnd, ids[x]),
|
---|
554 | &RGBGREY, &RGBBLACK, &RGBBLACK, NULL);
|
---|
555 | }
|
---|
556 | pis = xmallocz(sizeof(ICONSTUF), pszSrcFile, __LINE__);
|
---|
557 | if (!pis) {
|
---|
558 | WinDismissDlg(hwnd, 1);
|
---|
559 | break;
|
---|
560 | }
|
---|
561 | WinSetWindowPtr(WinWindowFromID(hwnd, FLE_ICON), QWL_USER, (PVOID) pis);
|
---|
562 | pis->size = sizeof(ICONSTUF);
|
---|
563 | pis->pfs = pfs;
|
---|
564 | pis->oldproc = WinSubclassWindow(WinWindowFromID(hwnd, FLE_ICON),
|
---|
565 | IconProc);
|
---|
566 | break;
|
---|
567 |
|
---|
568 | case WM_CONTROL:
|
---|
569 | switch (SHORT1FROMMP(mp1)) {
|
---|
570 | case FLE_READONLY:
|
---|
571 | case FLE_ARCHIVED:
|
---|
572 | case FLE_SYSTEM:
|
---|
573 | case FLE_HIDDEN:
|
---|
574 | switch (SHORT2FROMMP(mp1)) {
|
---|
575 | case BN_CLICKED:
|
---|
576 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
577 | if (pfs && *pfs->szFileName) {
|
---|
578 |
|
---|
579 | LISTINFO li;
|
---|
580 | UINT numfiles = 0, numalloc = 0;
|
---|
581 |
|
---|
582 | memset(&li, 0, sizeof(LISTINFO));
|
---|
583 | if (!AddToList(pfs->szFileName, &li.list, &numfiles, &numalloc)) {
|
---|
584 | if (WinDlgBox(HWND_DESKTOP,
|
---|
585 | hwnd,
|
---|
586 | AttrListDlgProc,
|
---|
587 | FM3ModHandle,
|
---|
588 | ATR_FRAME, MPFROMP(&li)) && li.list && li.list[0]) {
|
---|
589 | pfs->madechanges = TRUE;
|
---|
590 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
591 | }
|
---|
592 | FreeList(li.list);
|
---|
593 | }
|
---|
594 | }
|
---|
595 | break;
|
---|
596 | } // switch
|
---|
597 | break;
|
---|
598 | case FLE_NAME:
|
---|
599 | switch (SHORT2FROMMP(mp1)) {
|
---|
600 | case LN_ENTER:
|
---|
601 | case LN_SELECT:
|
---|
602 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
603 | if (!pfs) {
|
---|
604 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
605 | WinDismissDlg(hwnd, 1);
|
---|
606 | }
|
---|
607 | else {
|
---|
608 |
|
---|
609 | SHORT sSelect;
|
---|
610 |
|
---|
611 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
612 | FLE_NAME,
|
---|
613 | LM_QUERYSELECTION,
|
---|
614 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
615 | if (sSelect >= 0) {
|
---|
616 | *pfs->szFileName = 0;
|
---|
617 | WinSendDlgItemMsg(hwnd,
|
---|
618 | FLE_NAME,
|
---|
619 | LM_QUERYITEMTEXT,
|
---|
620 | MPFROM2SHORT(sSelect, CCHMAXPATH),
|
---|
621 | MPFROMP(pfs->szFileName));
|
---|
622 | if (*pfs->szFileName) {
|
---|
623 | if (SHORT2FROMMP(mp1) == LN_SELECT)
|
---|
624 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
625 | else
|
---|
626 | DefaultView(hwnd,
|
---|
627 | (HWND) 0, (HWND) 0, NULL, 32, pfs->szFileName);
|
---|
628 | }
|
---|
629 | }
|
---|
630 | }
|
---|
631 | break;
|
---|
632 | }
|
---|
633 | break;
|
---|
634 | }
|
---|
635 | return 0;
|
---|
636 |
|
---|
637 | case UM_SETDIR:
|
---|
638 | WinCheckButton(hwnd, FLE_READONLY, FALSE);
|
---|
639 | WinCheckButton(hwnd, FLE_ARCHIVED, FALSE);
|
---|
640 | WinCheckButton(hwnd, FLE_SYSTEM, FALSE);
|
---|
641 | WinCheckButton(hwnd, FLE_HIDDEN, FALSE);
|
---|
642 | WinCheckButton(hwnd, FLE_DIRECTORY, FALSE);
|
---|
643 | WinCheckButton(hwnd, FLE_READABLE, FALSE);
|
---|
644 | WinCheckButton(hwnd, FLE_WRITEABLE, FALSE);
|
---|
645 | WinCheckButton(hwnd, FLE_OPEN, FALSE);
|
---|
646 | WinCheckButton(hwnd, FLE_BINARY, FALSE);
|
---|
647 | WinCheckButton(hwnd, FLE_ISARCHIVE, FALSE);
|
---|
648 | WinSetDlgItemText(hwnd, FLE_ARCNAME, NullStr);
|
---|
649 | WinCheckButton(hwnd, FLE_OS2FS, FALSE);
|
---|
650 | WinCheckButton(hwnd, FLE_OS2WIN, FALSE);
|
---|
651 | WinCheckButton(hwnd, FLE_OS2PM, FALSE);
|
---|
652 | WinCheckButton(hwnd, FLE_DOS, FALSE);
|
---|
653 | WinCheckButton(hwnd, FLE_32BIT, FALSE);
|
---|
654 | WinCheckButton(hwnd, FLE_WINREAL, FALSE);
|
---|
655 | WinCheckButton(hwnd, FLE_WINPROT, FALSE);
|
---|
656 | WinCheckButton(hwnd, FLE_WINENH, FALSE);
|
---|
657 | WinCheckButton(hwnd, FLE_DLL, FALSE);
|
---|
658 | WinCheckButton(hwnd, FLE_PHYSDRV, FALSE);
|
---|
659 | WinCheckButton(hwnd, FLE_VIRTDRV, FALSE);
|
---|
660 | WinCheckButton(hwnd, FLE_PROTDLL, FALSE);
|
---|
661 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
662 | if (pfs && *pfs->szFileName) {
|
---|
663 | CHAR s[97];
|
---|
664 | CHAR szCmmaFmtFileSize[81], szCmmaFmtEASize[81];
|
---|
665 | CHAR szCmmaFmtFileEASize[81], szCmmaFmtFileEASizeK[81], szDate[DATE_BUF_BYTES];
|
---|
666 | FILEFINDBUF4L fs;
|
---|
667 | HDIR hdir = HDIR_CREATE;
|
---|
668 | ULONG apptype = 1;
|
---|
669 | FILE *fp;
|
---|
670 | HPOINTER hptr;
|
---|
671 | ARC_TYPE *info;
|
---|
672 | CHAR *mode;
|
---|
673 |
|
---|
674 | DosError(FERR_DISABLEHARDERR);
|
---|
675 | if (xDosFindFirst(pfs->szFileName,
|
---|
676 | &hdir,
|
---|
677 | FILE_NORMAL | FILE_ARCHIVED |
|
---|
678 | FILE_DIRECTORY | FILE_READONLY | FILE_HIDDEN |
|
---|
679 | FILE_SYSTEM,
|
---|
680 | &fs, sizeof(fs), &apptype, FIL_QUERYEASIZEL)) {
|
---|
681 | // Not found
|
---|
682 | SHORT sSelect, numitems;
|
---|
683 |
|
---|
684 | if (!fAlertBeepOff)
|
---|
685 | DosBeep(250, 100); // Wake up user
|
---|
686 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
687 | FLE_NAME,
|
---|
688 | LM_QUERYSELECTION,
|
---|
689 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
690 | if (sSelect >= 0) {
|
---|
691 | WinSendDlgItemMsg(hwnd,
|
---|
692 | FLE_NAME,
|
---|
693 | LM_DELETEITEM, MPFROMSHORT(sSelect), MPVOID);
|
---|
694 | numitems = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
695 | FLE_NAME,
|
---|
696 | LM_QUERYITEMCOUNT,
|
---|
697 | MPVOID, MPVOID);
|
---|
698 | if (numitems)
|
---|
699 | PostMsg(WinWindowFromID(hwnd, FLE_NAME),
|
---|
700 | LM_SELECTITEM,
|
---|
701 | MPFROMSHORT(((sSelect) ? sSelect - 1 : 0)),
|
---|
702 | MPFROMSHORT(TRUE));
|
---|
703 | }
|
---|
704 | }
|
---|
705 | else {
|
---|
706 | DosFindClose(hdir);
|
---|
707 | FDateFormat(szDate, fs.fdateLastWrite);
|
---|
708 | sprintf(s, "%s %02u%s%02u%s%02u",
|
---|
709 | szDate,
|
---|
710 | fs.ftimeLastWrite.hours, TimeSeparator,
|
---|
711 | fs.ftimeLastWrite.minutes, TimeSeparator, fs.ftimeLastWrite.twosecs * 2);
|
---|
712 | WinSetDlgItemText(hwnd, FLE_LASTWRITE, s);
|
---|
713 | if (fs.fdateCreation.year &&
|
---|
714 | fs.fdateCreation.month && fs.fdateCreation.day) {
|
---|
715 | FDateFormat(szDate, fs.fdateCreation);
|
---|
716 | sprintf(s, "%s %02u%s%02u%s%02u",
|
---|
717 | szDate,
|
---|
718 | fs.ftimeCreation.hours, TimeSeparator,
|
---|
719 | fs.ftimeCreation.minutes, TimeSeparator, fs.ftimeCreation.twosecs * 2);
|
---|
720 | WinSetDlgItemText(hwnd, FLE_CREATE, s);
|
---|
721 | }
|
---|
722 | if (fs.fdateLastAccess.year &&
|
---|
723 | fs.fdateLastAccess.month && fs.fdateLastAccess.day) {
|
---|
724 | FDateFormat(szDate, fs.fdateLastAccess);
|
---|
725 | sprintf(s, "%s %02u%s%02u%s%02u",
|
---|
726 | szDate,
|
---|
727 | fs.ftimeLastAccess.hours, TimeSeparator,
|
---|
728 | fs.ftimeLastAccess.minutes, TimeSeparator, fs.ftimeLastAccess.twosecs * 2);
|
---|
729 | WinSetDlgItemText(hwnd, FLE_LASTACCESS, s);
|
---|
730 | }
|
---|
731 | CommaFmtULL(szCmmaFmtFileSize,
|
---|
732 | sizeof(szCmmaFmtFileSize), fs.cbFile, ' ');
|
---|
733 | CommaFmtULL(szCmmaFmtEASize,
|
---|
734 | sizeof(szCmmaFmtEASize), CBLIST_TO_EASIZE(fs.cbList), ' ');
|
---|
735 | CommaFmtULL(szCmmaFmtFileEASize,
|
---|
736 | sizeof(szCmmaFmtFileEASize),
|
---|
737 | fs.cbFile + CBLIST_TO_EASIZE(fs.cbList),
|
---|
738 | ' ');
|
---|
739 | CommaFmtULL(szCmmaFmtFileEASizeK,
|
---|
740 | sizeof(szCmmaFmtFileEASizeK),
|
---|
741 | fs.cbFile + CBLIST_TO_EASIZE(fs.cbList),
|
---|
742 | 'K');
|
---|
743 | sprintf(s,
|
---|
744 | GetPString(IDS_SIZEINCLEASTEXT),
|
---|
745 | szCmmaFmtFileSize,
|
---|
746 | szCmmaFmtEASize,
|
---|
747 | szCmmaFmtFileEASize,
|
---|
748 | szCmmaFmtFileEASizeK);
|
---|
749 | WinSetDlgItemText(hwnd, FLE_SIZES, s);
|
---|
750 | CommaFmtULL(szCmmaFmtFileSize,
|
---|
751 | sizeof(szCmmaFmtFileSize), fs.cbFileAlloc - fs.cbFile, ' ');
|
---|
752 | sprintf(s, "%s", szCmmaFmtFileSize);
|
---|
753 | WinSetDlgItemText(hwnd, FLE_SLACK, s);
|
---|
754 | WinCheckButton(hwnd,
|
---|
755 | FLE_READONLY, ((fs.attrFile & FILE_READONLY) != 0));
|
---|
756 | WinCheckButton(hwnd,
|
---|
757 | FLE_ARCHIVED, ((fs.attrFile & FILE_ARCHIVED) != 0));
|
---|
758 | WinCheckButton(hwnd,
|
---|
759 | FLE_DIRECTORY, ((fs.attrFile & FILE_DIRECTORY) != 0));
|
---|
760 | WinCheckButton(hwnd, FLE_HIDDEN, ((fs.attrFile & FILE_HIDDEN) != 0));
|
---|
761 | WinCheckButton(hwnd, FLE_SYSTEM, ((fs.attrFile & FILE_SYSTEM) != 0));
|
---|
762 | DosError(FERR_DISABLEHARDERR);
|
---|
763 | if (!DosQueryAppType(pfs->szFileName, &apptype)) {
|
---|
764 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2FS), TRUE);
|
---|
765 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2WIN), TRUE);
|
---|
766 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2PM), TRUE);
|
---|
767 | WinEnableWindow(WinWindowFromID(hwnd, FLE_BOUND), TRUE);
|
---|
768 | WinEnableWindow(WinWindowFromID(hwnd, FLE_32BIT), TRUE);
|
---|
769 | WinEnableWindow(WinWindowFromID(hwnd, FLE_DOS), TRUE);
|
---|
770 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINPROT), TRUE);
|
---|
771 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINREAL), TRUE);
|
---|
772 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINENH), TRUE);
|
---|
773 | WinEnableWindow(WinWindowFromID(hwnd, FLE_DLL), TRUE);
|
---|
774 | WinEnableWindow(WinWindowFromID(hwnd, FLE_PHYSDRV), TRUE);
|
---|
775 | WinEnableWindow(WinWindowFromID(hwnd, FLE_VIRTDRV), TRUE);
|
---|
776 | WinEnableWindow(WinWindowFromID(hwnd, FLE_PROTDLL), TRUE);
|
---|
777 | WinCheckButton(hwnd, FLE_OS2FS,
|
---|
778 | ((apptype & FAPPTYP_NOTWINDOWCOMPAT) &&
|
---|
779 | !(apptype & FAPPTYP_WINDOWCOMPAT)));
|
---|
780 | WinCheckButton(hwnd, FLE_OS2WIN,
|
---|
781 | ((apptype & FAPPTYP_WINDOWCOMPAT) &&
|
---|
782 | !(apptype & FAPPTYP_NOTWINDOWCOMPAT)));
|
---|
783 | WinCheckButton(hwnd, FLE_OS2PM,
|
---|
784 | ((apptype & FAPPTYP_WINDOWAPI) ==
|
---|
785 | FAPPTYP_WINDOWAPI));
|
---|
786 | WinCheckButton(hwnd, FLE_BOUND, ((apptype & FAPPTYP_BOUND) != 0));
|
---|
787 | WinCheckButton(hwnd, FLE_DLL, ((apptype & FAPPTYP_DLL) != 0));
|
---|
788 | WinCheckButton(hwnd, FLE_DOS, ((apptype & FAPPTYP_DOS) != 0));
|
---|
789 | WinCheckButton(hwnd, FLE_PHYSDRV,
|
---|
790 | ((apptype & FAPPTYP_PHYSDRV) != 0));
|
---|
791 | WinCheckButton(hwnd, FLE_VIRTDRV,
|
---|
792 | ((apptype & FAPPTYP_VIRTDRV) != 0));
|
---|
793 | WinCheckButton(hwnd, FLE_PROTDLL,
|
---|
794 | ((apptype & FAPPTYP_PROTDLL) != 0));
|
---|
795 | WinCheckButton(hwnd, FLE_WINREAL,
|
---|
796 | ((apptype & FAPPTYP_WINDOWSREAL) != 0));
|
---|
797 | WinCheckButton(hwnd, FLE_WINPROT,
|
---|
798 | ((apptype & FAPPTYP_WINDOWSPROT) != 0));
|
---|
799 | WinCheckButton(hwnd, FLE_32BIT, ((apptype & FAPPTYP_32BIT) != 0));
|
---|
800 | WinCheckButton(hwnd, FLE_WINENH, ((apptype & 0x1000) != 0));
|
---|
801 | }
|
---|
802 | else {
|
---|
803 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2FS), FALSE);
|
---|
804 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2WIN), FALSE);
|
---|
805 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OS2PM), FALSE);
|
---|
806 | WinEnableWindow(WinWindowFromID(hwnd, FLE_BOUND), FALSE);
|
---|
807 | WinEnableWindow(WinWindowFromID(hwnd, FLE_32BIT), FALSE);
|
---|
808 | WinEnableWindow(WinWindowFromID(hwnd, FLE_DOS), FALSE);
|
---|
809 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINPROT), FALSE);
|
---|
810 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINREAL), FALSE);
|
---|
811 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WINENH), FALSE);
|
---|
812 | WinEnableWindow(WinWindowFromID(hwnd, FLE_DLL), FALSE);
|
---|
813 | WinEnableWindow(WinWindowFromID(hwnd, FLE_PHYSDRV), FALSE);
|
---|
814 | WinEnableWindow(WinWindowFromID(hwnd, FLE_VIRTDRV), FALSE);
|
---|
815 | WinEnableWindow(WinWindowFromID(hwnd, FLE_PROTDLL), FALSE);
|
---|
816 | }
|
---|
817 | hptr = WinLoadFileIcon(pfs->szFileName, FALSE);
|
---|
818 | WinShowWindow(WinWindowFromID(hwnd, FLE_ICON), FALSE);
|
---|
819 | if (hptr) {
|
---|
820 | WinSendDlgItemMsg(hwnd,
|
---|
821 | FLE_ICON, SM_SETHANDLE, MPFROMLONG(hptr), MPVOID);
|
---|
822 | WinShowWindow(WinWindowFromID(hwnd, FLE_ICON), TRUE);
|
---|
823 | }
|
---|
824 | WinShowWindow(WinWindowFromID(hwnd, FLE_EAS), fs.cbList > 4);
|
---|
825 | if (!(fs.attrFile & FILE_DIRECTORY)) {
|
---|
826 | WinEnableWindow(WinWindowFromID(hwnd, FLE_READABLE), TRUE);
|
---|
827 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WRITEABLE), TRUE);
|
---|
828 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OPEN), TRUE);
|
---|
829 | WinEnableWindow(WinWindowFromID(hwnd, FLE_ISARCHIVE), TRUE);
|
---|
830 | WinEnableWindow(WinWindowFromID(hwnd, FLE_BINARY), TRUE);
|
---|
831 | mode = "rb";
|
---|
832 | fp = xfsopen(pfs->szFileName, mode, SH_DENYNO, pszSrcFile, __LINE__, TRUE);
|
---|
833 | if (fp) {
|
---|
834 | char buff[4096]; // 06 Oct 07 SHL protect against NTFS defect
|
---|
835 | ULONG len;
|
---|
836 | APIRET rc;
|
---|
837 |
|
---|
838 | len = 512;
|
---|
839 | rc = DosRead(fileno(fp), buff, len, &len);
|
---|
840 | fclose(fp);
|
---|
841 | WinCheckButton(hwnd,
|
---|
842 | FLE_BINARY,
|
---|
843 | ((len && rc) ? IsBinary(buff, len) : 2));
|
---|
844 | WinCheckButton(hwnd, FLE_READABLE, TRUE);
|
---|
845 | info = find_type(pfs->szFileName, NULL);
|
---|
846 | if (info) {
|
---|
847 | WinCheckButton(hwnd, FLE_ISARCHIVE, 1);
|
---|
848 | if (info->id)
|
---|
849 | WinSetDlgItemText(hwnd, FLE_ARCNAME, info->id);
|
---|
850 | }
|
---|
851 | }
|
---|
852 | else {
|
---|
853 | WinCheckButton(hwnd, FLE_ISARCHIVE, 2);
|
---|
854 | WinCheckButton(hwnd, FLE_BINARY, 2);
|
---|
855 | }
|
---|
856 | mode = "ab";
|
---|
857 | fp = xfsopen(pfs->szFileName, mode, SH_DENYNO, pszSrcFile, __LINE__, TRUE);
|
---|
858 | if (fp) {
|
---|
859 | WinCheckButton(hwnd, FLE_WRITEABLE, TRUE);
|
---|
860 | fclose(fp);
|
---|
861 | }
|
---|
862 | mode = "rb";
|
---|
863 | fp = xfsopen(pfs->szFileName, mode, SH_DENYRW, pszSrcFile, __LINE__, TRUE);
|
---|
864 | if (!fp)
|
---|
865 | WinCheckButton(hwnd, FLE_OPEN, TRUE);
|
---|
866 | else
|
---|
867 | fclose(fp);
|
---|
868 | }
|
---|
869 | else {
|
---|
870 | WinEnableWindow(WinWindowFromID(hwnd, FLE_READABLE), FALSE);
|
---|
871 | WinEnableWindow(WinWindowFromID(hwnd, FLE_WRITEABLE), FALSE);
|
---|
872 | WinEnableWindow(WinWindowFromID(hwnd, FLE_OPEN), FALSE);
|
---|
873 | WinEnableWindow(WinWindowFromID(hwnd, FLE_ISARCHIVE), FALSE);
|
---|
874 | WinEnableWindow(WinWindowFromID(hwnd, FLE_BINARY), FALSE);
|
---|
875 | }
|
---|
876 | }
|
---|
877 | }
|
---|
878 | return 0;
|
---|
879 |
|
---|
880 | case WM_COMMAND:
|
---|
881 | switch (SHORT1FROMMP(mp1)) {
|
---|
882 | case DID_OK:
|
---|
883 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
884 | WinDismissDlg(hwnd, (pfs && pfs->madechanges) ? 2 : 1);
|
---|
885 | break;
|
---|
886 | case IDM_HELP:
|
---|
887 | if (hwndHelp)
|
---|
888 | WinSendMsg(hwndHelp,
|
---|
889 | HM_DISPLAY_HELP,
|
---|
890 | MPFROM2SHORT(HELP_INFO, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
891 | break;
|
---|
892 | case FLE_SETTINGS:
|
---|
893 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
894 | if (pfs && *pfs->szFileName)
|
---|
895 | OpenObject(pfs->szFileName, Settings, hwnd);
|
---|
896 | break;
|
---|
897 | case FLE_EAS:
|
---|
898 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
899 | if (pfs && *pfs->szFileName) {
|
---|
900 |
|
---|
901 | CHAR *list[2];
|
---|
902 |
|
---|
903 | list[0] = pfs->szFileName;
|
---|
904 | list[1] = NULL;
|
---|
905 | WinDlgBox(HWND_DESKTOP,
|
---|
906 | hwnd, DisplayEAsProc, FM3ModHandle, EA_FRAME, (PVOID) list);
|
---|
907 | }
|
---|
908 | break;
|
---|
909 | case DID_CANCEL:
|
---|
910 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
911 | WinDismissDlg(hwnd, (pfs && pfs->madechanges) ? 2 : 0);
|
---|
912 | break;
|
---|
913 | }
|
---|
914 | return 0;
|
---|
915 |
|
---|
916 | case WM_DESTROY:
|
---|
917 | pfs = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
918 | xfree(pfs, pszSrcFile, __LINE__);
|
---|
919 | break;
|
---|
920 | }
|
---|
921 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
922 | }
|
---|
923 |
|
---|
924 | MRESULT EXPENTRY SetDrvProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
925 | {
|
---|
926 | switch (msg) {
|
---|
927 | case WM_INITDLG:
|
---|
928 | if (!mp2 || !isalpha(*(CHAR *)mp2))
|
---|
929 | WinDismissDlg(hwnd, 0);
|
---|
930 | else {
|
---|
931 |
|
---|
932 | CHAR s[80];
|
---|
933 |
|
---|
934 | WinSetWindowULong(hwnd, QWL_USER, (toupper(*(CHAR *)mp2) - 'A'));
|
---|
935 | sprintf(s, GetPString(IDS_DRIVEFLAGSTITLETEXT), toupper(*(CHAR *)mp2));
|
---|
936 | WinSetWindowText(hwnd, s);
|
---|
937 | PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
938 | }
|
---|
939 | break;
|
---|
940 |
|
---|
941 | case UM_UNDO:
|
---|
942 | {
|
---|
943 | ULONG drive = WinQueryWindowULong(hwnd, QWL_USER);
|
---|
944 |
|
---|
945 | WinCheckButton(hwnd, DVS_REMOVABLE,
|
---|
946 | ((driveflags[drive] & DRIVE_REMOVABLE) != 0));
|
---|
947 | WinCheckButton(hwnd, DVS_NOTWRITEABLE,
|
---|
948 | ((driveflags[drive] & DRIVE_NOTWRITEABLE) != 0));
|
---|
949 | WinCheckButton(hwnd, DVS_IGNORE,
|
---|
950 | ((driveflags[drive] & DRIVE_IGNORE) != 0));
|
---|
951 | WinCheckButton(hwnd, DVS_CDROM,
|
---|
952 | ((driveflags[drive] & DRIVE_CDROM) != 0));
|
---|
953 | WinCheckButton(hwnd, DVS_NOLONGNAMES,
|
---|
954 | ((driveflags[drive] & DRIVE_NOLONGNAMES) != 0));
|
---|
955 | WinCheckButton(hwnd, DVS_REMOTE,
|
---|
956 | ((driveflags[drive] & DRIVE_REMOTE) != 0));
|
---|
957 | WinCheckButton(hwnd,DVS_VIRTUAL,
|
---|
958 | ((driveflags[drive] & DRIVE_VIRTUAL) != 0));
|
---|
959 | WinCheckButton(hwnd,DVS_RAMDISK,
|
---|
960 | ((driveflags[drive] & DRIVE_RAMDISK) != 0));
|
---|
961 | WinCheckButton(hwnd, DVS_BOOT,
|
---|
962 | ((driveflags[drive] & DRIVE_BOOT) != 0));
|
---|
963 | WinCheckButton(hwnd, DVS_INVALID,
|
---|
964 | ((driveflags[drive] & DRIVE_INVALID) != 0));
|
---|
965 | WinCheckButton(hwnd, DVS_NOPRESCAN,
|
---|
966 | ((driveflags[drive] & DRIVE_NOPRESCAN) != 0));
|
---|
967 | WinCheckButton(hwnd, DVS_ZIPSTREAM,
|
---|
968 | ((driveflags[drive] & DRIVE_ZIPSTREAM) != 0));
|
---|
969 | WinCheckButton(hwnd, DVS_NOLOADICONS,
|
---|
970 | ((driveflags[drive] & DRIVE_NOLOADICONS) != 0));
|
---|
971 | WinCheckButton(hwnd, DVS_NOLOADSUBJS,
|
---|
972 | ((driveflags[drive] & DRIVE_NOLOADSUBJS) != 0));
|
---|
973 | WinCheckButton(hwnd, DVS_NOLOADLONGS,
|
---|
974 | ((driveflags[drive] & DRIVE_NOLOADLONGS) != 0));
|
---|
975 | WinCheckButton(hwnd, DVS_SLOW, ((driveflags[drive] & DRIVE_SLOW) != 0));
|
---|
976 | WinCheckButton(hwnd, DVS_INCLUDEFILES,
|
---|
977 | ((driveflags[drive] & DRIVE_INCLUDEFILES) != 0));
|
---|
978 | WinCheckButton(hwnd,DVS_NOSTATS,
|
---|
979 | ((driveflags[drive] & DRIVE_NOSTATS) != 0));
|
---|
980 | WinCheckButton(hwnd,DVS_WRITEVERIFYOFF,
|
---|
981 | ((driveflags[drive] & DRIVE_WRITEVERIFYOFF) != 0));
|
---|
982 | WinCheckButton(hwnd,DVS_RSCANNED,
|
---|
983 | ((driveflags[drive] & DRIVE_RSCANNED) != 0));
|
---|
984 | WinCheckButton(hwnd,DVS_LOCALHD,
|
---|
985 | ((driveflags[drive] & DRIVE_LOCALHD) != 0));
|
---|
986 | WinCheckButton(hwnd,DVS_NOEASUPPORT,
|
---|
987 | ((driveflags[drive] & DRIVE_NOEASUPPORT) != 0));
|
---|
988 | }
|
---|
989 | return 0;
|
---|
990 |
|
---|
991 | case WM_CONTROL:
|
---|
992 | return 0;
|
---|
993 |
|
---|
994 | case WM_COMMAND:
|
---|
995 | switch (SHORT1FROMMP(mp1)) {
|
---|
996 | case DID_OK:
|
---|
997 | {
|
---|
998 | ULONG drive = WinQueryWindowULong(hwnd, QWL_USER);
|
---|
999 |
|
---|
1000 | if (WinQueryButtonCheckstate(hwnd, DVS_NOPRESCAN))
|
---|
1001 | driveflags[drive] |= DRIVE_NOPRESCAN;
|
---|
1002 | else
|
---|
1003 | driveflags[drive] &= (~DRIVE_NOPRESCAN);
|
---|
1004 | if (WinQueryButtonCheckstate(hwnd, DVS_NOLOADICONS))
|
---|
1005 | driveflags[drive] |= DRIVE_NOLOADICONS;
|
---|
1006 | else
|
---|
1007 | driveflags[drive] &= (~DRIVE_NOLOADICONS);
|
---|
1008 | if (WinQueryButtonCheckstate(hwnd, DVS_NOLOADSUBJS))
|
---|
1009 | driveflags[drive] |= DRIVE_NOLOADSUBJS;
|
---|
1010 | else
|
---|
1011 | driveflags[drive] &= (~DRIVE_NOLOADSUBJS);
|
---|
1012 | if (WinQueryButtonCheckstate(hwnd, DVS_NOLOADLONGS))
|
---|
1013 | driveflags[drive] |= DRIVE_NOLOADLONGS;
|
---|
1014 | else
|
---|
1015 | driveflags[drive] &= (~DRIVE_NOLOADLONGS);
|
---|
1016 | if (WinQueryButtonCheckstate(hwnd, DVS_SLOW))
|
---|
1017 | driveflags[drive] |= DRIVE_SLOW;
|
---|
1018 | else
|
---|
1019 | driveflags[drive] &= (~DRIVE_SLOW);
|
---|
1020 | if (WinQueryButtonCheckstate(hwnd, DVS_INCLUDEFILES))
|
---|
1021 | driveflags[drive] |= DRIVE_INCLUDEFILES;
|
---|
1022 | else
|
---|
1023 | driveflags[drive] &= (~DRIVE_INCLUDEFILES);
|
---|
1024 | if (WinQueryButtonCheckstate(hwnd,DVS_NOSTATS))
|
---|
1025 | driveflags[drive] |= DRIVE_NOSTATS;
|
---|
1026 | else
|
---|
1027 | driveflags[drive] &= (~DRIVE_NOSTATS);
|
---|
1028 | if (WinQueryButtonCheckstate(hwnd,DVS_WRITEVERIFYOFF))
|
---|
1029 | driveflags[drive] |= DRIVE_WRITEVERIFYOFF;
|
---|
1030 | else
|
---|
1031 | driveflags[drive] &= (~DRIVE_WRITEVERIFYOFF);
|
---|
1032 | {
|
---|
1033 | ULONG flags;
|
---|
1034 | CHAR FlagKey[80];
|
---|
1035 |
|
---|
1036 | sprintf(FlagKey, "%c.DriveFlags", (CHAR) (drive + 'A'));
|
---|
1037 | flags = driveflags[drive];
|
---|
1038 | flags &= (~(DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
|
---|
1039 | DRIVE_IGNORE | DRIVE_CDROM |
|
---|
1040 | DRIVE_REMOTE | DRIVE_RSCANNED |
|
---|
1041 | DRIVE_BOOT | DRIVE_INVALID | DRIVE_ZIPSTREAM |
|
---|
1042 | DRIVE_VIRTUAL | DRIVE_RAMDISK));
|
---|
1043 | PrfWriteProfileData(fmprof, appname, FlagKey, &flags, sizeof(ULONG));
|
---|
1044 | }
|
---|
1045 | }
|
---|
1046 | WinDismissDlg(hwnd, 1);
|
---|
1047 | break;
|
---|
1048 |
|
---|
1049 | case DID_CANCEL:
|
---|
1050 | WinDismissDlg(hwnd, 0);
|
---|
1051 | break;
|
---|
1052 |
|
---|
1053 | case IDM_UNDO:
|
---|
1054 | PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
1055 | break;
|
---|
1056 |
|
---|
1057 | case IDM_HELP:
|
---|
1058 | if (hwndHelp)
|
---|
1059 | WinSendMsg(hwndHelp,
|
---|
1060 | HM_DISPLAY_HELP,
|
---|
1061 | MPFROM2SHORT(HELP_FLAGS, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
1062 | break;
|
---|
1063 | }
|
---|
1064 | return 0;
|
---|
1065 | }
|
---|
1066 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
1067 | }
|
---|
1068 |
|
---|
1069 | #pragma alloc_text(FMINFO,FileInfoProc,IconProc)
|
---|
1070 | #pragma alloc_text(FMINFO2,SetDrvProc,DrvInfoProc)
|
---|