if (!CheckCompatibility(fileName)) {
EXCEPTION(std::runtime_error, "Cannot open file '"<<fileName<<"'.");
}
- return new MED::TWrapper(fileName);
+ return new MED::TWrapper(fileName, false);
}
PWrapper CrWrapperW(const std::string& fileName, int theVersion)
CreateEmptyMEDFile(fileName, theVersion);
}
}
- return new MED::TWrapper(fileName, minor);
+ return new MED::TWrapper(fileName, true, minor);
}
}
//---------------------------------------------------------------
TWrapper
- ::TWrapper(const std::string& theFileName, TInt theMinor):
+ ::TWrapper(const std::string& theFileName, bool write, TInt theMinor):
myFile(new TFile(theFileName, theMinor)),
myMinor(theMinor)
{
TErr aRet;
- myFile->Open(eLECTURE_ECRITURE, &aRet);
- // if (aRet < 0)
- // myFile->Close();
- // myFile->Open(eLECTURE_AJOUT, &aRet);
- // }
- if (aRet < 0) {
- myFile->Close();
- myFile->Open(eLECTURE, &aRet);
+ if ( write ) {
+ myFile->Open(eLECTURE_ECRITURE, &aRet);
+ if (aRet < 0) {
+ myFile->Close();
+ myFile->Open(eCREATION, &aRet);
+ }
}
- if (aRet < 0) {
- myFile->Close();
- myFile->Open(eCREATION, &aRet);
+ else {
+ myFile->Open(eLECTURE, &aRet);
}
}
TWrapper& operator=(const TWrapper&);
public:
- TWrapper(const std::string& theFileName, TInt theVersion=-1);
+ TWrapper(const std::string& theFileName, bool write, TInt theVersion=-1);
virtual
~TWrapper();