source: trunk/dll/update.c@ 385

Last change on this file since 385 was 385, checked in by root, 19 years ago

Add fm3str.h

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