Changeset 17259 for trunk/FACT++/src
- Timestamp:
- 10/18/13 16:50:39 (11 years ago)
- File:
-
- 1 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")
Note:
See TracChangeset
for help on using the changeset viewer.