annotate old-trunk/lwar/replace.c @ 348:11a95c6414b4

Added third func to instab to split resolve and emit logic
author lost@starbug
date Sat, 27 Mar 2010 22:15:07 -0600
parents eb230fa7d28e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
1 /*
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
2 replace.c
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
3 Copyright © 2009 William Astle
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
4
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
5 This file is part of LWAR.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
6
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
7 LWAR is free software: you can redistribute it and/or modify it under the
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
10 version.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
11
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
15 more details.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
16
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
19
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
20 */
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
21
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
22 #include <config.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
23
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
24 #include <errno.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
25 #include <stdio.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
26 #include <stdlib.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
27 #include <string.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
28
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
29 #include "lwar.h"
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
30
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
31 void do_replace(void)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
32 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
33 FILE *f;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
34 FILE *nf;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
35 unsigned char buf[8];
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
36 long l;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
37 int c;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
38 FILE *f2;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
39 int i;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
40 char fnbuf[1024];
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
41 char fnbuf2[1024];
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
42
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
43 sprintf(fnbuf, "%s.tmp", archive_file);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
44
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
45 f = fopen(archive_file, "r+");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
46 if (!f)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
47 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
48 if (errno == ENOENT)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
49 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
50 nf = fopen(fnbuf, "w");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
51 if (nf)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
52 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
53 fputs("LWAR1V", nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
54 goto doadd;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
55 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
56 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
57 perror("Cannot open archive file");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
58 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
59
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
60 fread(buf, 1, 6, f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
61 if (memcmp("LWAR1V", buf, 6))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
62 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
63 fprintf(stderr, "%s is not a valid archive file.\n", archive_file);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
64 exit(1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
65 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
66
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
67 nf = fopen(fnbuf, "w");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
68 if (!nf)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
69 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
70 perror("Cannot create temp archive file");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
71 exit(1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
72 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
73
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
74 fputs("LWAR1V", nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
75
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
76 for (;;)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
77 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
78 c = fgetc(f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
79 if (c == EOF && ferror(f))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
80 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
81 perror("Reading archive file");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
82 exit(1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
83 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
84 if (c == EOF)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
85 goto doadd;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
86
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
87 if (!c)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
88 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
89 goto doadd;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
90 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
91
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
92 // find the end of the file name
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
93 i = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
94 while (c)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
95 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
96 fnbuf2[i++] = c;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
97 c = fgetc(f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
98 if (c == EOF || ferror(f))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
99 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
100 fprintf(stderr, "Bad archive file\n");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
101 exit(1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
102 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
103 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
104 fnbuf2[i] = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
105
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
106 // get length of archive member
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
107 l = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
108 c = fgetc(f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
109 l = c << 24;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
110 c = fgetc(f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
111 l |= c << 16;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
112 c = fgetc(f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
113 l |= c << 8;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
114 c = fgetc(f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
115 l |= c;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
116
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
117 // is it a file we are replacing? if so, do not copy it
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
118 for (i = 0; i < nfiles; i++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
119 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
120 if (!strcmp(files[i], fnbuf2))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
121 break;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
122 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
123 if (i < nfiles)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
124 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
125 fseek(f, l, SEEK_CUR);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
126 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
127 else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
128 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
129 // otherwise, copy it
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
130 fprintf(nf, "%s", fnbuf2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
131 fputc(0, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
132 fputc(l >> 24, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
133 fputc((l >> 16) & 0xff, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
134 fputc((l >> 8) & 0xff, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
135 fputc(l & 0xff, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
136 while (l)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
137 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
138 c = fgetc(f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
139 fputc(c, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
140 l--;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
141 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
142 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
143 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
144
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
145 // done with the original file
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
146 fclose(f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
147 doadd:
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
148 for (i = 0; i < nfiles; i++)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
149 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
150 f2 = fopen(files[i], "r");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
151 if (!f2)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
152 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
153 fprintf(stderr, "Cannot open file %s:", files[i]);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
154 perror("");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
155 exit(1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
156 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
157 fread(buf, 1, 6, f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
158 if (mergeflag && !memcmp("LWAR1V", buf, 6))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
159 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
160 // add archive contents...
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
161 for (;;)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
162 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
163 c = fgetc(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
164 if (c == EOF || ferror(f2))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
165 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
166 perror("Reading input archive file");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
167 exit(1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
168 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
169 if (c == EOF)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
170 break;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
171
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
172 if (!c)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
173 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
174 break;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
175 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
176
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
177 // find the end of the file name
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
178 while (c)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
179 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
180 fputc(c, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
181 c = fgetc(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
182 if (c == EOF || ferror(f))
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
183 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
184 fprintf(stderr, "Bad input archive file\n");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
185 exit(1);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
186 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
187 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
188 fputc(0, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
189
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
190 // get length of archive member
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
191 l = 0;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
192 c = fgetc(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
193 fputc(c, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
194 l = c << 24;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
195 c = fgetc(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
196 fputc(c, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
197 l |= c << 16;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
198 c = fgetc(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
199 fputc(c, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
200 l |= c << 8;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
201 c = fgetc(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
202 fputc(c, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
203 l |= c;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
204
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
205 while (l)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
206 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
207 c = fgetc(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
208 fputc(c, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
209 l--;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
210 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
211 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
212
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
213 fclose(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
214 continue;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
215 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
216 fseek(f2, 0, SEEK_END);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
217 l = ftell(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
218 fseek(f2, 0, SEEK_SET);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
219 fputs(files[i], nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
220 fputc(0, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
221 fputc(l >> 24, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
222 fputc((l >> 16) & 0xff, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
223 fputc((l >> 8) & 0xff, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
224 fputc(l & 0xff, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
225 while (l)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
226 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
227 c = fgetc(f2);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
228 fputc(c, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
229 l--;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
230 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
231 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
232
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
233 // flag end of file
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
234 fputc(0, nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
235
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
236 fclose(nf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
237
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
238 if (rename(fnbuf, archive_file) < 0)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
239 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
240 perror("Cannot replace old archive file");
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
241 unlink(fnbuf);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
242 }
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
243 }