source: trunk/dll/update.c@ 551

Last change on this file since 551 was 551, checked in by Gregg Young, 18 years ago

Indentation cleanup

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