73 |
|
hdrelease(fd) /* stop tracking file fragments for some section */ |
74 |
|
register int fd; |
75 |
|
{ |
76 |
< |
if (fd >= nhdfrags || !hdfrag[fd].nlinks) |
76 |
> |
if (fd < 0 | fd >= nhdfrags || !hdfrag[fd].nlinks) |
77 |
|
return; |
78 |
|
if (!--hdfrag[fd].nlinks && hdfrag[fd].nfrags) { |
79 |
|
free((char *)hdfrag[fd].fi); |
211 |
|
|
212 |
|
|
213 |
|
long |
214 |
+ |
hdfilen(fd) /* return file length for fd */ |
215 |
+ |
int fd; |
216 |
+ |
{ |
217 |
+ |
long fpos, flen; |
218 |
+ |
|
219 |
+ |
if (fd < 0) |
220 |
+ |
return(-1); |
221 |
+ |
if (fd >= nhdfrags || !hdfrag[fd].nlinks) { |
222 |
+ |
if ((fpos = lseek(fd, 0L, 1)) < 0) |
223 |
+ |
return(-1); |
224 |
+ |
flen = lseek(fd, 0L, 2); |
225 |
+ |
lseek(fd, fpos, 0); |
226 |
+ |
return(flen); |
227 |
+ |
} |
228 |
+ |
return(hdfrag[fd].flen); |
229 |
+ |
} |
230 |
+ |
|
231 |
+ |
|
232 |
+ |
long |
233 |
|
hdfiluse(fd, all) /* compute file usage (in bytes) */ |
234 |
|
int fd; /* open file descriptor to check */ |
235 |
|
int all; /* include overhead and unflushed data */ |
435 |
|
nchanged += hdfreebeam(hdlist[i], 0); |
436 |
|
return(nchanged); |
437 |
|
} |
438 |
+ |
if (hp->fd < 0) /* check for recursive error */ |
439 |
+ |
return(-1); |
440 |
|
if (i == 0) { /* clear entire holodeck */ |
441 |
|
nchanged = 0; |
442 |
|
for (i = 1; i <= nbeams(hp); i++) |
455 |
|
if (lseek(hp->fd, hp->bi[i].fo, 0) < 0) |
456 |
|
error(SYSTEM, "cannot seek on holodeck file"); |
457 |
|
n = hp->bl[i]->nrm * sizeof(RAYVAL); |
458 |
< |
if (write(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) |
458 |
> |
if (write(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) { |
459 |
> |
hp->fd = -1; /* avoid recursive error */ |
460 |
|
error(SYSTEM, "write error in hdfreebeam"); |
461 |
+ |
} |
462 |
|
} |
463 |
|
blglob(hp)->nrm -= hp->bl[i]->nrm; |
464 |
|
free((char *)hp->bl[i]); /* free memory */ |