IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34692


Ignore:
Timestamp:
Nov 24, 2012, 4:07:15 PM (14 years ago)
Author:
eugene
Message:

need to truncate the image and catalog files when shinking the total amount of data in the file

Location:
branches/eam_branches/ipp-20120905/Ohana/src/libdvo/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120905/Ohana/src/libdvo/src/dvo_catalog_split.c

    r33963 r34692  
    8383    return (FALSE);
    8484  }
     85  off_t fullsize = catalog->header.datasize;
    8586
    8687  // write the PHU matrix; this is probably a NOP, do I have to keep it in?
     
    9192    return (FALSE);
    9293  }
     94  fullsize += matrix.datasize;
    9395  gfits_free_matrix (&matrix);
    9496
     
    98100    return (FALSE);
    99101  }
     102  fullsize += ftable->datasize + ftable->header->datasize;
     103
     104  // if the output file will be completely re-written, truncate to total datasize
     105  if ((start == 0) && (Nrows == Ntotal)) {
     106    int fd = fileno (catalog->f);
     107    if (ftruncate (fd, fullsize)) {
     108      perror ("dvo_catalog_save_subset: ");
     109      return (FALSE);
     110    }
     111  }
     112
    100113  return (TRUE);
    101114}
  • branches/eam_branches/ipp-20120905/Ohana/src/libdvo/src/fits_db.c

    r29938 r34692  
    159159  make_backup (db[0].filename);
    160160  Fseek (db[0].f, 0, SEEK_SET);
     161
     162  int fd = fileno (db->f);
     163  if (ftruncate (fd, 0)) {
     164    perror ("gfits_db_save: ");
     165    return (FALSE);
     166  }
    161167
    162168  if (!gfits_fwrite_header  (db[0].f, &db[0].header)) {
Note: See TracChangeset for help on using the changeset viewer.