Changeset 18837


Ignore:
Timestamp:
04/18/17 19:52:52 (8 years ago)
Author:
tbretz
Message:
Allow for automatic extension replacement in filename. Some minor fixes to the new feature.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/fitsdump.cc

    r18836 r18837  
    449449        if (tfile->IsZombie())
    450450        {
    451             cerr << "Could not open root file '" << rootfile << "'" << endl;
     451            cerr << "Could not open root file '" << filename << "'" << endl;
    452452            return -2;
    453453        }
     
    492492        for (auto it=cols.begin(); it!=cols.end(); it++)
    493493        {
    494             const string branch = it->name+"["+to_string(it->last-it->first+1)+"]";
     494            string branch = it->name;
     495            if (it->last!=it->first)
     496                branch += "["+to_string(it->last-it->first+1)+"]";
    495497
    496498            fout << "# Branch: " << branch << "\n";
     
    10981100    // ------------------------------------------------------------
    10991101
    1100     const string filename = conf.Get<string>("outfile");
     1102    string filename = conf.Get<string>("outfile");
     1103
     1104    if (!filename.empty() && filename[0]=='.')
     1105    {
     1106        if (fFilename.rfind(".fits")==fFilename.size()-5)
     1107            filename.insert(0, fFilename.substr(0, fFilename.size()-5));
     1108        if (fFilename.rfind(".fits.fz")==fFilename.size()-8)
     1109            filename.insert(0, fFilename.substr(0, fFilename.size()-8));
     1110    }
    11011111
    11021112    ostream fout(cout.rdbuf());
     
    12461256                                              , "Name of FITS file")
    12471257        ("col,c",       vars<string>(),         "List of columns to dump\narg is a list of columns, separated by a space.\nAdditionnally, a list of sub-columns can be added\ne.g. Data[3] will dump sub-column 3 of column Data\nData[3:4] will dump sub-columns 3 and 4\nOmitting this argument dump the entire column\nnote: all indices start at zero")
    1248         ("outfile,o",   var<string>("-"),       "Name of output file (-:/dev/stdout)")
     1258        ("outfile,o",   var<string>("-"),       "Name of output file (-:/dev/stdout), if outfile starts with a dot, the extension .fits and .fits.fz are replaced automatically.")
    12491259        ("precision,p", var<int>(20),           "Precision of ofstream")
    12501260        ("stat,s",      po_switch(),            "Perform statistics instead of dump")
Note: See TracChangeset for help on using the changeset viewer.