Changeset 12035 for trunk/FACT++/src


Ignore:
Timestamp:
09/08/11 16:24:29 (13 years ago)
Author:
lyard
Message:
added moving of corrupted files to corrupted naming
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r11838 r12035  
    2222
    2323#include <sys/stat.h> //for file stats
     24#include <cstdio> // for file rename
    2425
    2526using namespace std;
     
    9192    fRunNumber = runNumber;
    9293    fMess = out;
     94    fFileName = fileName;
    9395
    9496    if (fFile)
     
    177179    return true;
    178180}
    179 
     181void Fits::MoveFileToCorruptedFile()
     182{
     183    ostringstream corruptName;
     184    struct stat st;
     185    int append = 0;
     186    corruptName << fFileName << "corrupt" << append;
     187    while (stat(corruptName.str().c_str(), &st))
     188    {
     189        append++;
     190        corruptName.str("");
     191        corruptName << fFileName << "corrupt" << append;
     192    }
     193    if (rename(fFileName.c_str(), corruptName.str().c_str()) != 0)
     194        fMess->Error("Could not rename file " + fFileName);
     195    else
     196        fMess->Message("Renamed file " + fFileName + " to " + corruptName.str());
     197
     198}
    180199// --------------------------------------------------------------------------
    181200//
     
    213232    {
    214233        Close();
     234        MoveFileToCorruptedFile();
    215235        return false;
    216236    }
  • trunk/FACT++/src/Fits.h

    r11716 r12035  
    1818private:
    1919    FitsFile *fFile;
     20    string fFileName;
    2021
    2122    ///Name of the "standard", i.e. data found in every fits file
     
    4849    ///Write the FITS header keys
    4950    bool WriteHeaderKeys();
     51    //if a write error occurs
     52    void MoveFileToCorruptedFile();
     53
     54
    5055
    5156public:
Note: See TracChangeset for help on using the changeset viewer.