ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/holofile.c
(Generate patch)

Comparing ray/src/hd/holofile.c (file contents):
Revision 3.52 by schorsch, Sun Jul 27 22:12:02 2003 UTC vs.
Revision 3.53 by greg, Mon Oct 20 16:01:55 2003 UTC

# Line 13 | Line 13 | static const char      RCSid[] = "$Id$";
13  
14   #include "holo.h"
15  
16 + #include "platform.h"
17 +
18   #ifndef CACHESIZE
19   #ifdef SMLMEM
20   #define CACHESIZE       5
# Line 133 | Line 135 | int    wr;
135          }
136          hdfragl[fd].nlinks++;
137          hdfragl[fd].writable = wr;              /* set writable flag */
138 <        hdfragl[fd].flen = lseek(fd, (off_t)0, 2);      /* get file length */
138 >                                                /* get file length */
139 >        hdfragl[fd].flen = lseek(fd, (off_t)0, SEEK_END);
140   }
141  
142  
# Line 165 | Line 168 | HDGRID *hproto;                /* holodeck section grid */
168          register int    n;
169                                          /* prepare for system errors */
170          errno = 0;
171 <        if ((fpos = lseek(fd, (off_t)0, 1)) < 0)
171 >        if ((fpos = lseek(fd, (off_t)0, SEEK_CUR)) < 0)
172                  error(SYSTEM, "cannot determine holodeck file position");
173          if (hproto == NULL) {           /* assume we're loading it */
174                  HDGRID  hpr;
# Line 190 | Line 193 | HDGRID *hproto;                /* holodeck section grid */
193                  if (fd < nhdfragls && hdfragl[fd].nlinks)
194                          writable = hdfragl[fd].writable;
195                  else
196 <                        writable = lseek(fd, fpos, 0) == fpos &&
196 >                        writable = lseek(fd, fpos, SEEK_SET) == fpos &&
197                                  write(fd, (char *)hp, sizeof(HDGRID)) ==
198                                                          sizeof(HDGRID);
199          } else {                        /* else assume we're creating it */
# Line 247 | Line 250 | int    i;
250          register int    j;
251  
252          if (!hp->dirty++) {                     /* write smudge first time */
253 <                if (lseek(hp->fd, biglob(hp)->fo+(i-1)*sizeof(BEAMI), 0) < 0
254 <                                || write(hp->fd, (char *)&smudge,
253 >                if (lseek(hp->fd, biglob(hp)->fo+(i-1)*sizeof(BEAMI),
254 >                                        SEEK_SET) < 0 ||
255 >                                write(hp->fd, (char *)&smudge,
256                                          sizeof(BEAMI)) != sizeof(BEAMI))
257                          error(SYSTEM, "seek/write error in hdmarkdirty");
258                  hp->dirseg[0].s = i;
# Line 311 | Line 315 | int    all;
315          errno = 0;                      /* write dirty segments */
316          for (j = 0; j < hp->dirty; j++) {
317                  if (lseek(hp->fd, biglob(hp)->fo +
318 <                                (hp->dirseg[j].s-1)*sizeof(BEAMI), 0) < 0)
318 >                            (hp->dirseg[j].s-1)*sizeof(BEAMI), SEEK_SET) < 0)
319                          error(SYSTEM, "cannot seek on holodeck file");
320                  n = hp->dirseg[j].n * sizeof(BEAMI);
321                  if (write(hp->fd, (char *)(hp->bi+hp->dirseg[j].s), n) != n)
# Line 360 | Line 364 | int    fd;
364          if (fd < 0)
365                  return(-1);
366          if (fd >= nhdfragls || !hdfragl[fd].nlinks) {
367 <                if ((fpos = lseek(fd, (off_t)0, 1)) < 0)
367 >                if ((fpos = lseek(fd, (off_t)0, SEEK_CUR)) < 0)
368                          return(-1);
369 <                flen = lseek(fd, (off_t)0, 2);
370 <                lseek(fd, fpos, 0);
369 >                flen = lseek(fd, (off_t)0, SEEK_END);
370 >                lseek(fd, fpos, SEEK_SET);
371                  return(flen);
372          }
373          return(hdfragl[fd].flen);
# Line 418 | Line 422 | int    nr;                     /* number of new rays desired */
422                  blglob(hp)->nrm += n;
423                  if ((n = hp->bl[i]->nrm = hp->bi[i].nrd)) {
424                          errno = 0;
425 <                        if (lseek(hp->fd, hp->bi[i].fo, 0) < 0)
425 >                        if (lseek(hp->fd, hp->bi[i].fo, SEEK_SET) < 0)
426                                  error(SYSTEM, "seek error on holodeck file");
427                          n *= sizeof(RAYVAL);
428                          if (read(hp->fd, (char *)hdbray(hp->bl[i]), n) != n)
# Line 457 | Line 461 | register int   i;
461                  hp->bl[i] = (BEAM *)hdrealloc(NULL, hdbsiz(n), "hdgetbeam");
462                  blglob(hp)->nrm += hp->bl[i]->nrm = n;
463                  errno = 0;
464 <                if (lseek(hp->fd, hp->bi[i].fo, 0) < 0)
464 >                if (lseek(hp->fd, hp->bi[i].fo, SEEK_SET) < 0)
465                          error(SYSTEM, "seek error on holodeck file");
466                  n *= sizeof(RAYVAL);
467                  if (read(hp->fd, (char *)hdbray(hp->bl[i]), n) != n)
# Line 688 | Line 692 | register int   i;
692          if (nrays) {                    /* get and write new fragment */
693                  nfo = hdallocfrag(hp->fd, nrays);
694                  errno = 0;
695 <                if (lseek(hp->fd, nfo, 0) < 0)
695 >                if (lseek(hp->fd, nfo, SEEK_SET) < 0)
696                          error(SYSTEM, "cannot seek on holodeck file");
697                  n = hp->bl[i]->nrm * sizeof(RAYVAL);
698                  if (write(hp->fd, (char *)hdbray(hp->bl[i]), n) != n) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines