source: trunk/dll/update.c@ 204

Last change on this file since 204 was 204, checked in by root, 20 years ago

Drop unused code

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