Changeset 124
- Timestamp:
- Oct 14, 2003, 12:35:40 PM (23 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/imregister/detrend/altpath.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/imregister/detrend/altpath.c
r76 r124 7 7 int Nimage, Nlist, Ncurrent, Nadd, Nremove; 8 8 int *list, *current, *curfound, *add, *remove; 9 char *dBPath, in put[256], output[256], line[1024];9 char *dBPath, infile[256], outfile[256], line[1024]; 10 10 DetReg *image; 11 11 struct stat statbuf; 12 12 13 image = get_images (&Nimage); 13 14 ALLOCATE (current, int, Nimage); 14 15 15 /* identify current altpath images */16 Ncurrent = 0;17 for (i = 0; i < Nimage; i++) {18 if (image[i].altpath) {19 current[Ncurrent] = i;20 Ncurrent++;21 }22 }23 24 /* extract 'remove' and 'add' entries from current & match */25 ALLOCATE (remove, int, Nimage);26 ALLOCATE (add, int, Nimage);27 28 ALLOCATE (curfound, int, Ncurrent);29 bzero (curfound, Ncurrent*sizeof(int));30 31 Nadd = Nremove = 0;32 for (i = 0; i < Nmatch; i++) {33 found = FALSE;34 for (j = 0; !found && (j < Ncurrent); j++) {35 if (match[i].image == current[j]) {36 found = TRUE;37 curfound[j] = TRUE;38 }39 }40 if (!found) {41 add[Nadd] = match[i].image;42 Nadd ++;43 }44 }45 for (i = 0; i < Ncurrent; i++) {46 if (!curfound[i]) {47 remove[Nremove] = current[i];48 Nremove ++;49 }50 }51 free (current);52 free (curfound);53 54 16 ALLOCATE (list, int, Nimage); 55 17 Nlist = 0; … … 58 20 59 21 /* set altpath for 'add' images */ 60 for (j = 0; j < Nadd; j++) { 61 i = add[j]; 62 image[i].altpath = TRUE; 63 list[Nlist] = i; 64 Nlist ++; 65 for (n = 0; n < NDetrendAltDB; n++) { 66 sprintf (input, "%s/%s", dBPath, image[i].filename); 67 sprintf (output, "%s/%s", DetrendAltDB[n], image[i].filename); 68 status = ckpathname (output); 69 if (!status) { 70 remove[Nremove] = i; 71 Nremove ++; 72 break; 73 } 74 sprintf (line, "cp %s %s", input, output); 75 fprintf (stderr, "%s\n", line); 76 status = system (line); 77 if (status) { 78 remove[Nremove] = i; 79 Nremove ++; 80 break; 22 if (output.Altpath == ADD) { 23 /* find images to add */ 24 for (i = 0; i < Nmatch; i++) { 25 if (image[match[i].image].altpath == FALSE) { 26 list[Nlist] = match[i].image; 27 Nlist ++; 81 28 } 82 29 } 30 /* copy the masters to the altpath locations */ 31 for (j = 0; j < Nlist; j++) { 32 i = list[j]; 33 for (n = 0; n < NDetrendAltDB; n++) { 34 sprintf (infile, "%s/%s", dBPath, image[i].filename); 35 sprintf (outfile, "%s/%s", DetrendAltDB[n], image[i].filename); 36 status = ckpathname (outfile); 37 if (!status) { 38 fprintf (stderr, "warning: can't make outfile directory for %s\n", outfile); 39 continue; 40 } 41 sprintf (line, "cp %s %s", infile, outfile); 42 fprintf (stderr, "%s\n", line); 43 status = system (line); 44 if (status) { 45 fprintf (stderr, "warning: can't make outfile directory for %s\n", outfile); 46 continue; 47 } 48 } 49 image[i].altpath = TRUE; 50 } 51 update_db (list, Nlist); 52 close_db (); 53 fprintf (stderr, "SUCCESS\n"); 54 exit (0); 83 55 } 84 56 85 /* unset altpath for 'remove' images */ 86 for (j = 0; j < Nremove; j++) { 87 i = remove[j]; 88 image[i].altpath = FALSE; 89 list[Nlist] = i; 90 Nlist ++; 91 for (n = 0; n < NDetrendAltDB; n++) { 92 sprintf (output, "%s/%s", DetrendAltDB[n], image[i].filename); 93 sprintf (line, "rm %s", output); 94 fprintf (stderr, "%s\n", line); 95 status = system (line); 96 if (status) { 97 fprintf (stderr, "warning: can't delete %s\n", output); 57 /* unset altpath for 'delete' images */ 58 if (output.Altpath == DELETE) { 59 /* find images to delete */ 60 for (i = 0; i < Nmatch; i++) { 61 if (image[match[i].image].altpath == TRUE) { 62 list[Nlist] = match[i].image; 63 Nlist ++; 98 64 } 99 65 } 66 /* remove the copies from the altpath locations */ 67 for (j = 0; j < Nlist; j++) { 68 i = list[j]; 69 image[i].altpath = FALSE; 70 for (n = 0; n < NDetrendAltDB; n++) { 71 sprintf (outfile, "%s/%s", DetrendAltDB[n], image[i].filename); 72 sprintf (line, "rm %s", outfile); 73 fprintf (stderr, "%s\n", line); 74 status = system (line); 75 if (status) { 76 fprintf (stderr, "warning: can't delete %s\n", outfile); 77 } 78 } 79 } 80 update_db (list, Nlist); 81 close_db (); 82 fprintf (stderr, "SUCCESS\n"); 83 exit (0); 100 84 } 101 85 102 update_db (list, Nlist); 103 close_db (); 104 fprintf (stderr, "SUCCESS\n"); 105 exit (0); 86 /* check for existence in altpath, set flag as appropriate */ 87 if (output.Altpath == UPDATE) { 88 for (j = 0; j < Nmatch; j++) { 89 i = match[j].image; 90 list[Nlist] = i; 91 Nlist ++; 92 found = TRUE; 93 for (n = 0; found && (n < NDetrendAltDB); n++) { 94 sprintf (outfile, "%s/%s", DetrendAltDB[n], image[i].filename); 95 status = stat (outfile, &statbuf); 96 fprintf (stderr, "checking for %s, status is %d\n", outfile, status); 97 if (status == -1) found = FALSE; 98 } 99 image[i].altpath = found; 100 } 101 update_db (list, Nlist); 102 close_db (); 103 fprintf (stderr, "SUCCESS\n"); 104 exit (0); 105 } 106 106 107 fprintf (stderr, "unknown altpath mode: %d\n", output.Altpath); 107 108 } 108 109 … … 131 132 return (TRUE); 132 133 } 134
Note:
See TracChangeset
for help on using the changeset viewer.
