1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: update.c 1890 2020-01-30 06:39:42Z stevenhl $
|
---|
5 |
|
---|
6 | Update Container record/list
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2003, 2015 Steven H. Levine
|
---|
10 |
|
---|
11 | 12 Feb 03 SHL Standardize EA math
|
---|
12 | 10 Jan 04 SHL Add some intermin large drive error avoidance
|
---|
13 | 25 May 05 SHL Rework for ULONGLONG
|
---|
14 | 25 May 05 SHL Rework for FillInRecordFromFFB
|
---|
15 | 06 Jun 05 SHL Drop unused code
|
---|
16 | 22 Jul 06 SHL Use wrappers
|
---|
17 | 20 Feb 07 GKY Add SelectDriveIcon()
|
---|
18 | 09 Mar 07 GKY Cleanup SelectDriveIcon using "driveflag =" from Steven
|
---|
19 | 02 Aug 07 SHL Sync with CNRITEM mods
|
---|
20 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
21 | 14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring
|
---|
22 | 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
|
---|
23 | 07 Aug 15 SHL Sync with Flesh/Stubby mods
|
---|
24 | 10 Oct 15 GKY Eliminate some unnecessary Flesh and UnFlesh calls
|
---|
25 |
|
---|
26 | ***********************************************************************/
|
---|
27 |
|
---|
28 | #include <stdlib.h>
|
---|
29 | #include <string.h>
|
---|
30 | #include <ctype.h>
|
---|
31 |
|
---|
32 | #define INCL_DOS
|
---|
33 | #define INCL_WIN
|
---|
34 | #define INCL_LONGLONG
|
---|
35 |
|
---|
36 | #include "fm3dll.h"
|
---|
37 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
38 | #include "update.h"
|
---|
39 | #include "init.h" // Data declaration(s)
|
---|
40 | #include "notebook.h" // Data declaration(s)
|
---|
41 | #include "info.h" // Data declaration(s)
|
---|
42 | #include "newview.h" // Data declarations
|
---|
43 | #include "fm3str.h"
|
---|
44 | #include "errutil.h" // Dos_Error...
|
---|
45 | #include "filldir.h" // FillInRecordFromFFB
|
---|
46 | #include "dircnrs.h"
|
---|
47 | #include "flesh.h" // Flesh, Stubby
|
---|
48 | #include "findrec.h" // FindCnrRecord
|
---|
49 | #include "valid.h" // IsFullName
|
---|
50 | #include "wrappers.h" // xDosFindFirst
|
---|
51 | #include "misc.h" // PostMsg
|
---|
52 | #include "fortify.h"
|
---|
53 |
|
---|
54 | #ifdef PMPRINTF
|
---|
55 | #define _PMPRINTF_ // Enable debug macros
|
---|
56 | #include "PMPRINTF.H"
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | static PSZ pszSrcFile = __FILE__;
|
---|
60 |
|
---|
61 | HPOINTER SelectDriveIcon(PCNRITEM pci)
|
---|
62 | {
|
---|
63 | UINT driveflag = driveflags[toupper(*pci->pszFileName) - 'A'];
|
---|
64 | *pci->pszFileName = toupper(*pci->pszFileName);
|
---|
65 | if (isalpha(*pci->pszFileName) &&
|
---|
66 | toupper(*pci->pszFileName) > 'B') {
|
---|
67 | if (driveflag & DRIVE_CDROM)
|
---|
68 | pci->rc.hptrIcon = hptrCDROM;
|
---|
69 | else
|
---|
70 | pci->rc.hptrIcon =
|
---|
71 | (driveflag & DRIVE_REMOVABLE) ? hptrRemovable
|
---|
72 | :(driveflag & DRIVE_VIRTUAL) ? hptrVirtual
|
---|
73 | :(driveflag & DRIVE_REMOTE) ? hptrRemote
|
---|
74 | :(driveflag & DRIVE_RAMDISK) ? hptrRamdisk
|
---|
75 | :(driveflag & DRIVE_ZIPSTREAM) ? hptrZipstrm : hptrDrive;
|
---|
76 | }
|
---|
77 | else
|
---|
78 | pci->rc.hptrIcon = hptrFloppy;
|
---|
79 | return pci->rc.hptrIcon;
|
---|
80 | }
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * Update/add CNRITEM record for filename
|
---|
84 | * Deletes existing CNRITEM if file has disappeared
|
---|
85 | * @returns pci pointer to CNRITEM record or NULL if not found or if stale CNRITEM deleted
|
---|
86 | */
|
---|
87 |
|
---|
88 | PCNRITEM UpdateCnrRecord(HWND hwndCnr, CHAR *filename, BOOL partial,
|
---|
89 | DIRCNRDATA *dcd)
|
---|
90 | {
|
---|
91 | PCNRITEM pci;
|
---|
92 | FILEFINDBUF4L ffb;
|
---|
93 | HDIR hDir = HDIR_CREATE;
|
---|
94 | ULONG nm = 1;
|
---|
95 | ULONG oldemphasis = 0;
|
---|
96 | APIRET status;
|
---|
97 |
|
---|
98 | if (!filename || !*filename)
|
---|
99 | return (PCNRITEM) NULL;
|
---|
100 | if (IsFullName(filename)) {
|
---|
101 | if (driveflags[toupper(*filename) - 'A'] & DRIVE_NOTWRITEABLE)
|
---|
102 | // ignore non-writeable drives
|
---|
103 | return (PCNRITEM) NULL;
|
---|
104 | }
|
---|
105 | status = xDosFindFirst(filename,
|
---|
106 | &hDir,
|
---|
107 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
108 | FILE_ARCHIVED | FILE_READONLY |
|
---|
109 | FILE_HIDDEN | FILE_SYSTEM,
|
---|
110 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL);
|
---|
111 | if (!status) {
|
---|
112 | // file exists
|
---|
113 | DosFindClose(hDir);
|
---|
114 | if (!dcd)
|
---|
115 | dcd = INSTDATA(hwndCnr);
|
---|
116 | if (dcd->type == ARC_FRAME)
|
---|
117 | return (PCNRITEM) NULL;
|
---|
118 | if (*dcd->directory) {
|
---|
119 |
|
---|
120 | CHAR *p, temp;
|
---|
121 |
|
---|
122 | p = strrchr(filename, '\\');
|
---|
123 | if (p) {
|
---|
124 | if (p < filename + 3)
|
---|
125 | p++;
|
---|
126 | temp = *p;
|
---|
127 | *p = 0;
|
---|
128 | if (stricmp(filename, dcd->directory)) {
|
---|
129 | *p = temp;
|
---|
130 | return (PCNRITEM) NULL;
|
---|
131 | }
|
---|
132 | *p = temp;
|
---|
133 | }
|
---|
134 | else
|
---|
135 | return (PCNRITEM) NULL;
|
---|
136 | }
|
---|
137 | pci = FindCnrRecord(hwndCnr,
|
---|
138 | filename, (PCNRITEM) NULL, partial, FALSE, TRUE);
|
---|
139 | Update:
|
---|
140 | if (pci) {
|
---|
141 | // Check if record needs to be updated
|
---|
142 | if ((!fForceUpper && !fForceLower && strcmp(pci->pszFileName, filename)) ||
|
---|
143 | pci->cbFile != ffb.cbFile || pci->attrFile != ffb.attrFile ||
|
---|
144 | pci->easize != CBLIST_TO_EASIZE(ffb.cbList) || pci->date.day !=
|
---|
145 | ffb.fdateLastWrite.day || pci->date.month != ffb.fdateLastWrite.month ||
|
---|
146 | pci->date.year != ffb.fdateLastWrite.year + 1980 || pci->time.seconds !=
|
---|
147 | ffb.ftimeLastWrite.twosecs * 2 || pci->time.minutes != ffb.ftimeLastWrite.minutes ||
|
---|
148 | pci->time.hours != ffb.ftimeLastWrite.hours || pci->ladate.day !=
|
---|
149 | ffb.fdateLastAccess.day || pci->ladate.month != ffb.fdateLastAccess.month ||
|
---|
150 | pci->ladate.year != ffb.fdateLastAccess.year + 1980 || pci->latime.seconds !=
|
---|
151 | ffb.ftimeLastAccess.twosecs * 2 || pci->latime.minutes !=
|
---|
152 | ffb.ftimeLastAccess.minutes || pci->latime.hours != ffb.ftimeLastAccess.hours)
|
---|
153 | {
|
---|
154 | // Something changed - update
|
---|
155 | *ffb.achName = 0; // Tell FillInRecordFromFFB that filename contains full pathname
|
---|
156 | ffb.cchName = 0;
|
---|
157 | FillInRecordFromFFB(hwndCnr, pci, filename, &ffb, partial, dcd);
|
---|
158 | if (strlen(pci->pszFileName) < 4)
|
---|
159 | SelectDriveIcon(pci);
|
---|
160 | oldemphasis = pci->rc.flRecordAttr & (CRA_SELECTED | CRA_CURSORED);
|
---|
161 | if (oldemphasis)
|
---|
162 | WinSendMsg(hwndCnr,
|
---|
163 | CM_SETRECORDEMPHASIS,
|
---|
164 | MPFROMP(pci), MPFROM2SHORT(FALSE, oldemphasis));
|
---|
165 | WinSendMsg(hwndCnr,
|
---|
166 | CM_INVALIDATERECORD, MPFROMP(&pci), MPFROM2SHORT(1, CMA_TEXTCHANGED));
|
---|
167 | if (oldemphasis)
|
---|
168 | WinSendMsg(hwndCnr,
|
---|
169 | CM_SETRECORDEMPHASIS,
|
---|
170 | MPFROMP(pci), MPFROM2SHORT(TRUE, oldemphasis));
|
---|
171 | }
|
---|
172 | else // existed, unchanged, do nothing but return
|
---|
173 | return pci;
|
---|
174 | }
|
---|
175 | else {
|
---|
176 | // Add record
|
---|
177 | if (dcd->type == DIR_FRAME) {
|
---|
178 |
|
---|
179 | RECORDINSERT ri;
|
---|
180 | ULONGLONG ullTotalBytes;
|
---|
181 |
|
---|
182 | pci = WinSendMsg(hwndCnr,
|
---|
183 | CM_ALLOCRECORD,
|
---|
184 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1));
|
---|
185 | if (pci) {
|
---|
186 | *ffb.achName = 0;
|
---|
187 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
188 | pci,
|
---|
189 | filename, &ffb, partial, dcd);
|
---|
190 | if (strlen(pci->pszFileName) < 4)
|
---|
191 | SelectDriveIcon(pci);
|
---|
192 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
193 | ri.cb = sizeof(RECORDINSERT);
|
---|
194 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
195 | ri.pRecordParent = (PRECORDCORE) NULL;
|
---|
196 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
197 | ri.cRecordsInsert = 1;
|
---|
198 | ri.fInvalidateRecord = TRUE;
|
---|
199 | if (WinSendMsg(hwndCnr,
|
---|
200 | CM_INSERTRECORD,
|
---|
201 | MPFROMP(pci), MPFROMP(&ri)) && ullTotalBytes) {
|
---|
202 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
203 | PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
204 | if (pci->attrFile & FILE_DIRECTORY) {
|
---|
205 | AddFleshWorkRequest(hwndCnr, pci, eStubby);
|
---|
206 | }
|
---|
207 | }
|
---|
208 | }
|
---|
209 | }
|
---|
210 | else if (ffb.attrFile & FILE_DIRECTORY) {
|
---|
211 |
|
---|
212 | // check all parts and insert as required
|
---|
213 | CHAR *p, temp;
|
---|
214 | PCNRITEM pciParent = NULL, pciT;
|
---|
215 |
|
---|
216 | p = strchr(filename, '\\');
|
---|
217 | if (p) {
|
---|
218 | while (p && *p) {
|
---|
219 | if (p < filename + 3)
|
---|
220 | p++;
|
---|
221 | temp = *p;
|
---|
222 | *p = 0;
|
---|
223 | pciT = FindCnrRecord(hwndCnr,
|
---|
224 | filename, NULL, partial, FALSE, TRUE);
|
---|
225 | if (!pciT || (INT) pciT == -1) {
|
---|
226 | pci = WinSendMsg(hwndCnr,
|
---|
227 | CM_ALLOCRECORD,
|
---|
228 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
229 | MPFROMLONG(1));
|
---|
230 | if (pci) {
|
---|
231 |
|
---|
232 | RECORDINSERT ri;
|
---|
233 |
|
---|
234 | *ffb.achName = 0;
|
---|
235 | FillInRecordFromFFB(hwndCnr,
|
---|
236 | pci, filename, &ffb, partial, dcd);
|
---|
237 | if (strlen(pci->pszFileName) < 4)
|
---|
238 | SelectDriveIcon(pci);
|
---|
239 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
240 | ri.cb = sizeof(RECORDINSERT);
|
---|
241 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
242 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
243 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
244 | ri.cRecordsInsert = 1;
|
---|
245 | ri.fInvalidateRecord = TRUE;
|
---|
246 | if (WinSendMsg(hwndCnr,
|
---|
247 | CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
|
---|
248 | if (!pci->fleshed)
|
---|
249 | AddFleshWorkRequest(hwndCnr, pci, eFlesh);
|
---|
250 | *p = temp;
|
---|
251 | pci = FindCnrRecord(hwndCnr,
|
---|
252 | filename, pciT, partial, FALSE, TRUE);
|
---|
253 | if (pci)
|
---|
254 | goto Update;
|
---|
255 | }
|
---|
256 | }
|
---|
257 | }
|
---|
258 | else {
|
---|
259 | pciParent = pciT;
|
---|
260 | if (!(pciT->rc.flRecordAttr & CRA_EXPANDED)) {
|
---|
261 | if (!pciT->fleshed)
|
---|
262 | AddFleshWorkRequest(hwndCnr, pciT, eFlesh);
|
---|
263 | *p = temp;
|
---|
264 | pci = FindCnrRecord(hwndCnr,
|
---|
265 | filename, pciT, partial, FALSE, TRUE);
|
---|
266 | if (pci)
|
---|
267 | goto Update;
|
---|
268 | }
|
---|
269 | }
|
---|
270 | *p = temp;
|
---|
271 | p = strchr(p + ((temp == '\\') ? 1 : 0), '\\');
|
---|
272 | }
|
---|
273 | }
|
---|
274 | pci = WinSendMsg(hwndCnr,
|
---|
275 | CM_ALLOCRECORD,
|
---|
276 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1));
|
---|
277 | if (pci) {
|
---|
278 |
|
---|
279 | RECORDINSERT ri;
|
---|
280 | ULONGLONG ullTotalBytes;
|
---|
281 |
|
---|
282 | *ffb.achName = 0;
|
---|
283 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
284 | pci,
|
---|
285 | filename, &ffb, partial, dcd);
|
---|
286 | if (strlen(pci->pszFileName) < 4)
|
---|
287 | SelectDriveIcon(pci);
|
---|
288 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
289 | ri.cb = sizeof(RECORDINSERT);
|
---|
290 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
291 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
292 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
293 | ri.cRecordsInsert = 1;
|
---|
294 | ri.fInvalidateRecord = TRUE;
|
---|
295 | if (WinSendMsg(hwndCnr,
|
---|
296 | CM_INSERTRECORD,
|
---|
297 | MPFROMP(pci), MPFROMP(&ri)) && ullTotalBytes) {
|
---|
298 | if (dcd->type == DIR_FRAME) {
|
---|
299 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
300 | }
|
---|
301 | AddFleshWorkRequest(hwndCnr, pci, eStubby);
|
---|
302 | }
|
---|
303 | }
|
---|
304 | }
|
---|
305 | }
|
---|
306 | }
|
---|
307 | else if ((pci = FindCnrRecord(hwndCnr,
|
---|
308 | filename,
|
---|
309 | (PCNRITEM) NULL,
|
---|
310 | partial,
|
---|
311 | FALSE,
|
---|
312 | TRUE)) !=
|
---|
313 | NULL && (INT) pci != -1 && strlen(pci->pszFileName) > 3) {
|
---|
314 | // File has disappeared and found stale CNRITEM record delete it
|
---|
315 | if (!dcd)
|
---|
316 | dcd = INSTDATA(hwndCnr);
|
---|
317 | if (pci->rc.flRecordAttr & CRA_SELECTED)
|
---|
318 | WinSendMsg(hwndCnr,
|
---|
319 | CM_SETRECORDEMPHASIS,
|
---|
320 | MPFROMP(pci), MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
321 | if (dcd->type == DIR_FRAME)
|
---|
322 | dcd->ullTotalBytes -= pci->cbFile + pci->easize;
|
---|
323 | RemoveCnrItems(hwndCnr, pci, 1, CMA_FREE | CMA_INVALIDATE);
|
---|
324 | pci = NULL;
|
---|
325 | PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
326 | }
|
---|
327 | return pci;
|
---|
328 | }
|
---|
329 |
|
---|
330 | BOOL UpdateCnrList(HWND hwndCnr, CHAR ** filename, INT howmany, BOOL partial,
|
---|
331 | DIRCNRDATA * dcd)
|
---|
332 | {
|
---|
333 | PCNRITEM pci, *pciList = NULL;
|
---|
334 | FILEFINDBUF4L ffb;
|
---|
335 | HDIR hDir;
|
---|
336 | ULONG nm = (ULONG) howmany;
|
---|
337 | INT x;
|
---|
338 | INT numlist = 0;
|
---|
339 | INT numremain;
|
---|
340 | BOOL repos = FALSE;
|
---|
341 | BOOL ret = FALSE;
|
---|
342 | APIRET status;
|
---|
343 |
|
---|
344 | if (!dcd)
|
---|
345 | dcd = INSTDATA(hwndCnr);
|
---|
346 | if (!dcd) {
|
---|
347 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
348 | return ret;
|
---|
349 | }
|
---|
350 | if (!filename || !howmany || !filename[0])
|
---|
351 | return ret;
|
---|
352 | {
|
---|
353 | CNRINFO cnri;
|
---|
354 |
|
---|
355 | memset(&cnri, 0, sizeof(CNRINFO));
|
---|
356 | cnri.cb = sizeof(CNRINFO);
|
---|
357 | WinSendMsg(hwndCnr,
|
---|
358 | CM_QUERYCNRINFO, MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
|
---|
359 | numremain = cnri.cRecords;
|
---|
360 | }
|
---|
361 | pciList = xmalloc(sizeof(PCNRITEM) * howmany, pszSrcFile, __LINE__);
|
---|
362 | if (pciList) {
|
---|
363 | for (x = 0; filename[x] && x < howmany; x++) {
|
---|
364 | if (IsFullName(filename[x])) {
|
---|
365 | if (driveflags[toupper(*filename[x]) - 'A'] & DRIVE_NOTWRITEABLE)
|
---|
366 | // ignore non-writeable drives
|
---|
367 | continue;
|
---|
368 | }
|
---|
369 | hDir = HDIR_CREATE;
|
---|
370 | status = xDosFindFirst(filename[x],
|
---|
371 | &hDir,
|
---|
372 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
373 | FILE_ARCHIVED | FILE_READONLY |
|
---|
374 | FILE_HIDDEN | FILE_SYSTEM,
|
---|
375 | &ffb, sizeof(ffb), &nm, FIL_QUERYEASIZEL);
|
---|
376 | if (!status) {
|
---|
377 | // file exists
|
---|
378 | DosFindClose(hDir);
|
---|
379 | if (dcd->type == DIR_FRAME && *dcd->directory) {
|
---|
380 |
|
---|
381 | CHAR *p, temp;
|
---|
382 |
|
---|
383 | p = strrchr(filename[x], '\\');
|
---|
384 | if (p) {
|
---|
385 | if (p < filename[x] + 3)
|
---|
386 | p++;
|
---|
387 | temp = *p;
|
---|
388 | *p = 0;
|
---|
389 | if (stricmp(filename[x], dcd->directory)) {
|
---|
390 | *p = temp;
|
---|
391 | continue;
|
---|
392 | }
|
---|
393 | *p = temp;
|
---|
394 | }
|
---|
395 | else
|
---|
396 | continue;
|
---|
397 | }
|
---|
398 | ret = TRUE;
|
---|
399 | pci = FindCnrRecord(hwndCnr,
|
---|
400 | filename[x],
|
---|
401 | (PCNRITEM) NULL, partial, FALSE, TRUE);
|
---|
402 | if (pci) {
|
---|
403 | // update record?
|
---|
404 | if ((!fForceUpper && !fForceLower &&
|
---|
405 | strcmp(pci->pszFileName, filename[x])) ||
|
---|
406 | pci->cbFile != ffb.cbFile || pci->attrFile != ffb.attrFile ||
|
---|
407 | pci->easize != CBLIST_TO_EASIZE(ffb.cbList) ||
|
---|
408 | pci->date.day != ffb.fdateLastWrite.day ||
|
---|
409 | pci->date.month != ffb.fdateLastWrite.month ||
|
---|
410 | pci->date.year != ffb.fdateLastWrite.year + 1980 ||
|
---|
411 | pci->time.seconds != ffb.ftimeLastWrite.twosecs * 2 ||
|
---|
412 | pci->time.minutes != ffb.ftimeLastWrite.minutes ||
|
---|
413 | pci->time.hours != ffb.ftimeLastWrite.hours ||
|
---|
414 | pci->ladate.day != ffb.fdateLastAccess.day ||
|
---|
415 | pci->ladate.month != ffb.fdateLastAccess.month ||
|
---|
416 | pci->ladate.year != ffb.fdateLastAccess.year + 1980 ||
|
---|
417 | pci->latime.seconds != ffb.ftimeLastAccess.twosecs * 2 ||
|
---|
418 | pci->latime.minutes != ffb.ftimeLastAccess.minutes ||
|
---|
419 | pci->latime.hours != ffb.ftimeLastAccess.hours) {
|
---|
420 | // changed; update
|
---|
421 | pciList[numlist++] = pci;
|
---|
422 | *ffb.achName = 0;
|
---|
423 | ffb.cchName = 0;
|
---|
424 | FillInRecordFromFFB(hwndCnr,
|
---|
425 | pci, filename[x], &ffb, partial, dcd);
|
---|
426 | if (IsRoot(pci->pszFileName))
|
---|
427 | SelectDriveIcon(pci);
|
---|
428 | WinSendMsg(hwndCnr,
|
---|
429 | CM_SETRECORDEMPHASIS,
|
---|
430 | MPFROMP(pci),
|
---|
431 | MPFROM2SHORT(FALSE, CRA_SELECTED | CRA_CURSORED));
|
---|
432 | }
|
---|
433 | }
|
---|
434 | else {
|
---|
435 | // add record
|
---|
436 | if (dcd->type == DIR_FRAME) {
|
---|
437 | RECORDINSERT ri;
|
---|
438 | ULONGLONG ullTotalBytes;
|
---|
439 |
|
---|
440 | pci = WinSendMsg(hwndCnr,
|
---|
441 | CM_ALLOCRECORD,
|
---|
442 | MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(1));
|
---|
443 | if (pci) {
|
---|
444 | ret = TRUE;
|
---|
445 | *ffb.achName = 0;
|
---|
446 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
447 | pci,
|
---|
448 | filename[x],
|
---|
449 | &ffb, partial, dcd);
|
---|
450 | if (strlen(pci->pszFileName) < 4)
|
---|
451 | SelectDriveIcon(pci);
|
---|
452 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
453 | ri.cb = sizeof(RECORDINSERT);
|
---|
454 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
455 | ri.pRecordParent = (PRECORDCORE) NULL;
|
---|
456 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
457 | ri.cRecordsInsert = 1;
|
---|
458 | ri.fInvalidateRecord = FALSE;
|
---|
459 | if (WinSendMsg(hwndCnr,
|
---|
460 | CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
|
---|
461 | if (ullTotalBytes) {
|
---|
462 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
463 | numremain++;
|
---|
464 | }
|
---|
465 | repos = TRUE;
|
---|
466 | if (pci->attrFile & FILE_DIRECTORY) {
|
---|
467 | AddFleshWorkRequest(hwndCnr, pci, eStubby);
|
---|
468 | }
|
---|
469 | }
|
---|
470 | else
|
---|
471 | FreeCnrItem(hwndCnr, pci);
|
---|
472 | }
|
---|
473 | }
|
---|
474 | else if (ffb.attrFile & FILE_DIRECTORY) {
|
---|
475 | // check all parts and insert as required
|
---|
476 | CHAR *p, temp;
|
---|
477 | PCNRITEM pciParent = NULL, pciT;
|
---|
478 |
|
---|
479 | p = strchr(filename[x], '\\');
|
---|
480 | if (p) {
|
---|
481 | while (p && *p) {
|
---|
482 | if (p < filename[x] + 3)
|
---|
483 | p++;
|
---|
484 | temp = *p;
|
---|
485 | *p = 0;
|
---|
486 | pciT = FindCnrRecord(hwndCnr,
|
---|
487 | filename[x], NULL, partial, FALSE, TRUE);
|
---|
488 | if (!pciT || (INT) pciT == -1) {
|
---|
489 | pci = WinSendMsg(hwndCnr,
|
---|
490 | CM_ALLOCRECORD,
|
---|
491 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
492 | MPFROMLONG(1));
|
---|
493 | if (pci) {
|
---|
494 |
|
---|
495 | RECORDINSERT ri;
|
---|
496 | ULONGLONG ullTotalBytes;
|
---|
497 |
|
---|
498 | ret = TRUE;
|
---|
499 | *ffb.achName = 0;
|
---|
500 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
501 | pci,
|
---|
502 | filename[x],
|
---|
503 | &ffb, partial, dcd);
|
---|
504 | if (strlen(pci->pszFileName) < 4)
|
---|
505 | SelectDriveIcon(pci);
|
---|
506 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
507 | ri.cb = sizeof(RECORDINSERT);
|
---|
508 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
509 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
510 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
511 | ri.cRecordsInsert = 1;
|
---|
512 | ri.fInvalidateRecord = FALSE;
|
---|
513 | if (WinSendMsg(hwndCnr,
|
---|
514 | CM_INSERTRECORD,
|
---|
515 | MPFROMP(pci), MPFROMP(&ri))) {
|
---|
516 | if (ullTotalBytes) {
|
---|
517 | numremain++;
|
---|
518 | if (dcd->type == DIR_FRAME)
|
---|
519 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
520 | }
|
---|
521 | repos = TRUE;
|
---|
522 | }
|
---|
523 | else
|
---|
524 | FreeCnrItem(hwndCnr, pci);
|
---|
525 | }
|
---|
526 | }
|
---|
527 | else
|
---|
528 | pciParent = pciT;
|
---|
529 | *p = temp;
|
---|
530 | p = strchr(p + ((temp == '\\') ? 1 : 0), '\\');
|
---|
531 | }
|
---|
532 | }
|
---|
533 | {
|
---|
534 | pci = WinSendMsg(hwndCnr,
|
---|
535 | CM_ALLOCRECORD,
|
---|
536 | MPFROMLONG(EXTRA_RECORD_BYTES),
|
---|
537 | MPFROMLONG(1));
|
---|
538 | if (pci) {
|
---|
539 |
|
---|
540 | RECORDINSERT ri;
|
---|
541 | ULONGLONG ullTotalBytes;
|
---|
542 |
|
---|
543 | ret = TRUE;
|
---|
544 | *ffb.achName = 0;
|
---|
545 | ullTotalBytes = FillInRecordFromFFB(hwndCnr,
|
---|
546 | pci,
|
---|
547 | filename[x],
|
---|
548 | &ffb, partial, dcd);
|
---|
549 | if (strlen(pci->pszFileName) < 4)
|
---|
550 | SelectDriveIcon(pci);
|
---|
551 | memset(&ri, 0, sizeof(RECORDINSERT));
|
---|
552 | ri.cb = sizeof(RECORDINSERT);
|
---|
553 | ri.pRecordOrder = (PRECORDCORE) CMA_END;
|
---|
554 | ri.pRecordParent = (PRECORDCORE) pciParent;
|
---|
555 | ri.zOrder = (USHORT) CMA_TOP;
|
---|
556 | ri.cRecordsInsert = 1;
|
---|
557 | ri.fInvalidateRecord = FALSE;
|
---|
558 | if (WinSendMsg(hwndCnr,
|
---|
559 | CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
|
---|
560 | if (ullTotalBytes) {
|
---|
561 | numremain++;
|
---|
562 | if (dcd->type == DIR_FRAME)
|
---|
563 | dcd->ullTotalBytes += ullTotalBytes;
|
---|
564 | }
|
---|
565 | repos = TRUE;
|
---|
566 | AddFleshWorkRequest(hwndCnr, pci, eStubby);
|
---|
567 | }
|
---|
568 | else
|
---|
569 | FreeCnrItem(hwndCnr, pci);
|
---|
570 | }
|
---|
571 | }
|
---|
572 | }
|
---|
573 | }
|
---|
574 | }
|
---|
575 | else if ((pci = FindCnrRecord(hwndCnr,
|
---|
576 | filename[x],
|
---|
577 | (PCNRITEM) NULL,
|
---|
578 | partial,
|
---|
579 | FALSE,
|
---|
580 | TRUE)) != NULL &&
|
---|
581 | (INT) pci != -1 && !IsRoot(pci->pszFileName)) {
|
---|
582 | // file doesn't exist; delete record
|
---|
583 | if (pci->rc.flRecordAttr & CRA_SELECTED)
|
---|
584 | WinSendMsg(hwndCnr,
|
---|
585 | CM_SETRECORDEMPHASIS,
|
---|
586 | MPFROMP(pci), MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
587 | if (dcd->type == DIR_FRAME)
|
---|
588 | dcd->ullTotalBytes -= (pci->cbFile + pci->easize);
|
---|
589 | // 02 Aug 07 SHL rc check was wrong
|
---|
590 | if (RemoveCnrItems(hwndCnr, pci, 1,
|
---|
591 | CMA_FREE |
|
---|
592 | numremain == 1 ? CMA_INVALIDATE : 0) != -1) {
|
---|
593 | pci = NULL;
|
---|
594 | numremain--;
|
---|
595 | repos = TRUE;
|
---|
596 | }
|
---|
597 | }
|
---|
598 | } // for x
|
---|
599 | }
|
---|
600 | if (repos || (pciList && numlist)) {
|
---|
601 | QUERYRECORDRECT qrr;
|
---|
602 | RECTL rCnr, rCItem;
|
---|
603 |
|
---|
604 | pci = WinSendMsg(hwndCnr,
|
---|
605 | CM_QUERYRECORDEMPHASIS,
|
---|
606 | MPFROMLONG(CMA_FIRST), MPFROMLONG(CRA_CURSORED));
|
---|
607 | if (pci && (INT) pci != -1) {
|
---|
608 | memset(&qrr, 0, sizeof(QUERYRECORDRECT));
|
---|
609 | qrr.cb = sizeof(QUERYRECORDRECT);
|
---|
610 | qrr.pRecord = (PRECORDCORE) pci;
|
---|
611 | qrr.fRightSplitWindow = FALSE;
|
---|
612 | qrr.fsExtent = CMA_TEXT;
|
---|
613 | if (!WinSendMsg(hwndCnr,
|
---|
614 | CM_QUERYRECORDRECT, MPFROMP(&rCItem), MPFROMP(&qrr)))
|
---|
615 | qrr.cb = 0;
|
---|
616 | }
|
---|
617 | if (pciList && numlist && !repos) {
|
---|
618 | WinSendMsg(hwndCnr,
|
---|
619 | CM_INVALIDATERECORD,
|
---|
620 | MPFROMP(pciList),
|
---|
621 | MPFROM2SHORT(numlist,
|
---|
622 | (repos ? CMA_NOREPOSITION :
|
---|
623 | CMA_REPOSITION | CMA_ERASE)));
|
---|
624 | }
|
---|
625 | if (repos)
|
---|
626 | WinSendMsg(hwndCnr,
|
---|
627 | CM_INVALIDATERECORD,
|
---|
628 | MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
|
---|
629 | if (pci && (INT) pci != -1 && qrr.cb) {
|
---|
630 | WinSendMsg(hwndCnr,
|
---|
631 | CM_QUERYVIEWPORTRECT,
|
---|
632 | MPFROMP(&rCnr), MPFROM2SHORT(CMA_WINDOW, (SHORT) FALSE));
|
---|
633 | WinSendMsg(hwndCnr,
|
---|
634 | CM_SCROLLWINDOW,
|
---|
635 | MPFROMSHORT(CMA_VERTICAL),
|
---|
636 | MPFROMLONG(rCnr.yTop - rCItem.yTop));
|
---|
637 | }
|
---|
638 | }
|
---|
639 | PostMsg(hwndCnr, UM_RESCAN, MPVOID, MPVOID);
|
---|
640 | if (pciList) {
|
---|
641 | free(pciList);
|
---|
642 | DosPostEventSem(CompactSem);
|
---|
643 | }
|
---|
644 | return ret;
|
---|
645 | }
|
---|
646 |
|
---|
647 | #pragma alloc_text(UPDATECNR,UpdateCnrRecord,UpdateCnrList)
|
---|