Mercurial > hg-old > index.cgi
comparison lwar/add.c @ 174:cc41ccee8f64
added --merge to lwar
author | lost |
---|---|
date | Tue, 03 Mar 2009 00:42:47 +0000 |
parents | 47427342e41d |
children | bae1e3ecdce1 |
comparison
equal
deleted
inserted
replaced
173:0395e6fd67e9 | 174:cc41ccee8f64 |
---|---|
114 { | 114 { |
115 fprintf(stderr, "Cannot open file %s:", files[i]); | 115 fprintf(stderr, "Cannot open file %s:", files[i]); |
116 perror(""); | 116 perror(""); |
117 exit(1); | 117 exit(1); |
118 } | 118 } |
119 fread(buf, 1, 6, f2); | |
120 if (mergeflag && !memcmp("LWAR1V", buf, 6)) | |
121 { | |
122 // add archive contents... | |
123 for (;;) | |
124 { | |
125 c = fgetc(f2); | |
126 if (c == EOF || ferror(f2)) | |
127 { | |
128 perror("Reading input archive file"); | |
129 exit(1); | |
130 } | |
131 if (c == EOF) | |
132 break; | |
133 | |
134 if (!c) | |
135 { | |
136 break; | |
137 } | |
138 | |
139 // find the end of the file name | |
140 while (c) | |
141 { | |
142 fputc(c, f); | |
143 c = fgetc(f2); | |
144 if (c == EOF || ferror(f)) | |
145 { | |
146 fprintf(stderr, "Bad input archive file\n"); | |
147 exit(1); | |
148 } | |
149 } | |
150 fputc(0, f); | |
151 | |
152 // get length of archive member | |
153 l = 0; | |
154 c = fgetc(f2); | |
155 fputc(c, f); | |
156 l = c << 24; | |
157 c = fgetc(f2); | |
158 fputc(c, f); | |
159 l |= c << 16; | |
160 c = fgetc(f2); | |
161 fputc(c, f); | |
162 l |= c << 8; | |
163 c = fgetc(f2); | |
164 fputc(c, f); | |
165 l |= c; | |
166 | |
167 while (l) | |
168 { | |
169 c = fgetc(f2); | |
170 fputc(c, f); | |
171 l--; | |
172 } | |
173 } | |
174 | |
175 fclose(f2); | |
176 continue; | |
177 } | |
119 fseek(f2, 0, SEEK_END); | 178 fseek(f2, 0, SEEK_END); |
120 l = ftell(f2); | 179 l = ftell(f2); |
121 fseek(f2, 0, SEEK_SET); | 180 fseek(f2, 0, SEEK_SET); |
122 fputs(files[i], f); | 181 fputs(files[i], f); |
123 fputc(0, f); | 182 fputc(0, f); |