Changeset 18490


Ignore:
Timestamp:
05/06/16 10:22:08 (9 years ago)
Author:
tbretz
Message:
Now also running fitsdump -h from a cronjob without redirection should work, /dev/stdout is not writable in this context.
File:
1 edited

Legend:

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

    r18489 r18490  
    8585
    8686    ///Display the selected columns values VS time
    87     void Dump(ofstream &, const vector<string> &, const vector<MyColumn> &, const string &, size_t, size_t, const string &);
    88     void DumpRoot(ofstream &, const vector<string> &, const string &, size_t, size_t, const string &);
    89     void DumpMinMax(ofstream &, const vector<MyColumn> &, size_t, size_t, bool);
    90     void DumpStats(ofstream &, const vector<MyColumn> &, const string &, size_t, size_t);
     87    void Dump(ostream &, const vector<string> &, const vector<MyColumn> &, const string &, size_t, size_t, const string &);
     88    void DumpRoot(ostream &, const vector<string> &, const string &, size_t, size_t, const string &);
     89    void DumpMinMax(ostream &, const vector<MyColumn> &, size_t, size_t, bool);
     90    void DumpStats(ostream &, const vector<MyColumn> &, const string &, size_t, size_t);
    9191
    9292public:
     
    177177void FitsDumper::ListHeader(const string& filename)
    178178{
    179     ofstream fout(filename=="-"?"/dev/stdout":filename);
    180     if (!fout)
    181     {
    182         cerr << "Cannot open output stream " << filename << ": " << strerror(errno) << endl;
    183         return;
     179    ostream fout(cout.rdbuf());
     180
     181    ofstream sout;
     182    if (filename!="-")
     183    {
     184        sout.open(filename);
     185        if (!sout)
     186        {
     187            cerr << "Cannot open output stream " << filename << ": " << strerror(errno) << endl;
     188            return;
     189        }
     190        fout.rdbuf(sout.rdbuf());
    184191    }
    185192
     
    401408//! Perform the actual dump, based on the current parameters
    402409//
    403 void FitsDumper::Dump(ofstream &fout, const vector<string> &format, const vector<MyColumn> &cols, const string &filter, size_t first, size_t limit, const string &filename)
     410void FitsDumper::Dump(ostream &fout, const vector<string> &format, const vector<MyColumn> &cols, const string &filter, size_t first, size_t limit, const string &filename)
    404411{
    405412    const fits::Table::Keys &fKeyMap = GetKeys();
     
    625632}
    626633
    627 void FitsDumper::DumpRoot(ofstream &fout, const vector<string> &cols, const string &filter, size_t first, size_t limit, const string &filename)
     634void FitsDumper::DumpRoot(ostream &fout, const vector<string> &cols, const string &filter, size_t first, size_t limit, const string &filename)
    628635{
    629636#ifdef HAVE_ROOT
     
    715722}
    716723
    717 void FitsDumper::DumpMinMax(ofstream &fout, const vector<MyColumn> &cols, size_t first, size_t limit, bool fNoZeroPlease)
     724void FitsDumper::DumpMinMax(ostream &fout, const vector<MyColumn> &cols, size_t first, size_t limit, bool fNoZeroPlease)
    718725{
    719726    vector<minMaxStruct> statData(cols.size());
     
    789796
    790797template<typename T>
    791 void displayStats(vector<char> &array, ofstream& out)
     798void displayStats(vector<char> &array, ostream& out)
    792799{
    793800    const size_t numElems = array.size()/sizeof(T);
     
    829836}
    830837
    831 void FitsDumper::DumpStats(ofstream &fout, const vector<MyColumn> &cols, const string &filter, size_t first, size_t limit)
     838void FitsDumper::DumpStats(ostream &fout, const vector<MyColumn> &cols, const string &filter, size_t first, size_t limit)
    832839{
    833840#ifdef HAVE_ROOT
     
    981988    const string filename = conf.Get<string>("outfile");
    982989
    983     ofstream fout(filename=="-"?"/dev/stdout":filename);
    984     if (!fout)
    985     {
    986         cerr << "Cannot open output stream " << filename << ": " << strerror(errno) << endl;
    987         return false;
    988     }
     990    ostream fout(cout.rdbuf());
     991
     992    ofstream sout;
     993    if (filename!="-")
     994    {
     995        sout.open(filename);
     996        if (!sout)
     997        {
     998            cerr << "Cannot open output stream " << filename << ": " << strerror(errno) << endl;
     999            return false;
     1000        }
     1001        fout.rdbuf(sout.rdbuf());
     1002    }
     1003
    9891004    fout.precision(conf.Get<int>("precision"));
    9901005    if (conf.Get<bool>("fixed"))
Note: See TracChangeset for help on using the changeset viewer.