- Timestamp:
- 10/18/13 16:50:39 (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fitsdump.cc
r17166 r17259 72 72 /// Lists all columns of an open file 73 73 void List(); 74 void ListFileContent(const string& filename); 74 75 void ListHeader(const string& filename); 75 76 void ListKeywords(ostream &); … … 165 166 } 166 167 168 void FitsDumper::ListFileContent(const string& filename) 169 { 170 ofstream fout(filename=="-"?"/dev/stdout":filename); 171 if (!fout) 172 { 173 cerr << "Cannot open file " << filename << ": " << strerror(errno) << endl; 174 return; 175 } 176 177 int table_id = 0; 178 179 vector<string> table_names; 180 vector<uint32_t> table_rows; 181 try 182 { 183 184 while (true) 185 { 186 clear(); 187 seekg(0); 188 fTable = Table(); 189 Constructor(fFilename, "", "", false, table_id); 190 191 table_names.push_back(fTable.Get<string>("EXTNAME")); 192 table_rows.push_back(GetNumRows()); 193 194 table_id++; 195 } 196 } 197 catch (runtime_error e) 198 { 199 //nothing to see here, just catching the error thrown by EOF 200 } 201 202 fout << "File " << fFilename << " has " << table_names.size() << " tables: " << endl; 203 for (uint32_t i=0; i<table_names.size(); i++) 204 { 205 fout << "#" << i << ": \"" << table_names[i]; 206 fout << "\" num. rows = " << table_rows[i] << endl; 207 } 208 } 167 209 void FitsDumper::ListHeader(const string& filename) 168 210 { … … 929 971 List(); 930 972 973 if (conf.Get<bool>("filecontent")) 974 ListFileContent(conf.Get<string>("outfile")); 975 931 976 if (conf.Get<bool>("header")) 932 977 ListHeader(conf.Get<string>("outfile")); 933 978 934 979 935 if (conf.Get<bool>("header") || conf.Get<bool>("list") )980 if (conf.Get<bool>("header") || conf.Get<bool>("list") || conf.Get<bool>("filecontent")) 936 981 return 1; 937 982 … … 1110 1155 ("limit", var<size_t>(size_t(0)), "Limit for the maximum number of rows to read (0=unlimited)") 1111 1156 ("tablename,t", var<string>(""), "Name of the table to open. If not specified, first binary table is opened") 1157 ("filecontent", po_switch(), "List the number of tables in the file, along with their name") 1112 1158 #ifdef HAVE_ROOT 1113 1159 ("root,r", po_switch(), "Enable root mode") -
trunk/Mars/mcore/fits.h
r17216 r17259 564 564 } 565 565 566 void Constructor(const string &fname, string fout, const string& tableName, bool force )566 void Constructor(const string &fname, string fout, const string& tableName, bool force, int tableNumber=-1) 567 567 { 568 568 char simple[10]; … … 570 570 if (!good()) 571 571 return; 572 573 int current_table = 0; 572 574 573 575 if (memcmp(simple, "SIMPLE = ", 10)) … … 649 651 // skip the current table? 650 652 if ((!tableName.empty() && tableName!=fTable.Get<string>("EXTNAME")) || 651 ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<string>("EXTNAME"))) 653 ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<string>("EXTNAME")) || 654 (tableNumber != -1)) 652 655 { 656 if (current_table == tableNumber) 657 { 658 fBufferRow.resize(fTable.bytes_per_row + 8-fTable.bytes_per_row%4); 659 fBufferDat.resize(fTable.bytes_per_row); 660 661 break; 662 } 653 663 const streamoff skip = fTable.GetTotalBytes(); 654 664 seekg(skip, ios_base::cur); 655 665 656 666 fChkHeader.reset(); 667 current_table++; 657 668 658 669 continue;
Note:
See TracChangeset
for help on using the changeset viewer.