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