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