Changeset 27435 for trunk/Ohana/src/libfits/table/F_write_T.c
- Timestamp:
- Mar 24, 2010, 11:22:25 AM (16 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/libfits/table/F_write_T.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
Property svn:mergeinfo
set to
/branches/eam_branches/20091201/Ohana merged eligible /branches/eam_branches/largefiles.20100314/Ohana merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/src/libfits/table/F_write_T.c
r15743 r27435 13 13 if (f == (FILE *) NULL) return (FALSE); 14 14 15 status = fseek (f, 0, SEEK_END); /* write table to end of file! */15 status = fseeko (f, 0LL, SEEK_END); /* write table to end of file! */ 16 16 status = gfits_fwrite_table (f, table); 17 17 … … 23 23 int gfits_fwrite_table (FILE *f, FTable *table) { 24 24 25 int Nbytes;25 off_t Nbytes; 26 26 27 Nbytes = fwrite (table[0].buffer, sizeof(char), table[0]. size, f);27 Nbytes = fwrite (table[0].buffer, sizeof(char), table[0].datasize, f); 28 28 29 if (Nbytes != table[0]. size) return (FALSE);29 if (Nbytes != table[0].datasize) return (FALSE); 30 30 return (TRUE); 31 31 } … … 34 34 int gfits_fwrite_vtable (FILE *f, VTable *table) { 35 35 36 int i, Nx, Ny, Npad, offset, start;37 int Nbytes, *row, Nrow;36 off_t i, Nx, Ny, Npad, offset, start; 37 off_t Nbytes, *row, Nrow; 38 38 char *pad; 39 39 40 40 Nrow = table[0].Nrow; 41 41 row = table[0].row; 42 gfits_scan (table[0].header, "NAXIS1", "% d", 1,&Nx);43 gfits_scan (table[0].header, "NAXIS2", "% d", 1,&Ny);42 gfits_scan (table[0].header, "NAXIS1", "%lld", 1, (long long *) &Nx); 43 gfits_scan (table[0].header, "NAXIS2", "%lld", 1, (long long *) &Ny); 44 44 45 45 /* file pointer is at beginning of desired table data */ 46 start = ftell (f);46 start = ftello (f); 47 47 48 48 for (i = 0; i < Nrow; i++) { 49 49 offset = start + Nx*row[i]; 50 fseek (f, offset, SEEK_SET);50 fseeko (f, offset, SEEK_SET); 51 51 Nbytes = fwrite (table[0].buffer[i], sizeof (char), Nx, f); 52 52 if (Nbytes != Nx) { return (FALSE); } 53 53 } 54 54 55 Npad = table[0]. size - Nx*Ny;55 Npad = table[0].datasize - Nx*Ny; 56 56 ALLOCATE (pad, char, Npad); 57 57 bzero (pad, Npad); 58 58 59 59 offset = start + Nx*Ny; 60 fseek (f, offset, SEEK_SET);60 fseeko (f, offset, SEEK_SET); 61 61 Nbytes = fwrite (pad, sizeof (char), Npad, f); 62 62 if (Nbytes != Npad) { return (FALSE); } … … 71 71 72 72 /*********************** fits read ftable data ***********************************/ 73 int gfits_fwrite_ftable_range (FILE *f, FTable *ftable, int start, int Nrows, int Ndisk, int Ntotal) {73 int gfits_fwrite_ftable_range (FILE *f, FTable *ftable, off_t start, off_t Nrows, off_t Ndisk, off_t Ntotal) { 74 74 75 int Nbytes, Nwrite, Nskip, Nx, Npad;75 off_t Nbytes, Nwrite, Nskip, Nx, Npad; 76 76 char *pad; 77 77 … … 79 79 80 80 /* modify vtable to represent full disk table */ 81 gfits_modify (ftable[0].header, "NAXIS2", "% d", 1,Ntotal);81 gfits_modify (ftable[0].header, "NAXIS2", "%lld", 1, (long long) Ntotal); 82 82 ftable[0].header[0].Naxis[1] = Ntotal; 83 83 84 84 Nx = ftable[0].header[0].Naxis[0]; // final output table size on disk 85 ftable[0]. size = gfits_data_size (ftable[0].header);85 ftable[0].datasize = gfits_data_size (ftable[0].header); 86 86 87 87 Nskip = start * Nx; … … 95 95 96 96 // cursor must be at start of the table (after table header) 97 fseek (f, Nskip, SEEK_CUR);97 fseeko (f, Nskip, SEEK_CUR); 98 98 Nwrite = fwrite (ftable[0].buffer, sizeof (char), Nbytes, f); 99 99 if (Nwrite != Nbytes) { … … 102 102 103 103 if (Ntotal >= Ndisk) { 104 Npad = ftable[0]. size - Nx*Ntotal;104 Npad = ftable[0].datasize - Nx*Ntotal; 105 105 ALLOCATE (pad, char, Npad); 106 106 bzero (pad, Npad);
Note:
See TracChangeset
for help on using the changeset viewer.
