From e509abf786d26a16a38e8c2b7b0bea0800b0b8dc Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 26 Oct 2010 10:07:18 +0000 Subject: [PATCH] Correction of bug when the file does not exist. --- src/MEDLoader/MEDLoaderBase.cxx | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/MEDLoader/MEDLoaderBase.cxx b/src/MEDLoader/MEDLoaderBase.cxx index 057c2869d..14c33ac1e 100644 --- a/src/MEDLoader/MEDLoaderBase.cxx +++ b/src/MEDLoader/MEDLoaderBase.cxx @@ -31,38 +31,17 @@ int MEDLoaderBase::getStatusOfFile(const char *fileName) { std::ifstream ifs; ifs.open(fileName); - unsigned int res=0; if((ifs.rdstate() & std::ifstream::failbit)!=0) { - res+=1; ifs.close(); + return NOT_EXIST; } std::ofstream ofs(fileName,std::ios_base::app); if((ofs.rdstate() & std::ofstream::failbit)!=0) { - ofs.close(); - res+=2; - } - switch(res) - { - case 0: - return EXIST_RW; - case 1: - { - std::ifstream ifs2; - ifs2.open(fileName); - if((ifs2.rdstate() & std::ifstream::failbit)!=0) - return EXIST_WRONLY; - else - return NOT_EXIST; - } - case 2: return EXIST_RDONLY; - case 3: - return DIR_LOCKED; - default: - throw INTERP_KERNEL::Exception("Internal error !"); } + return EXIST_RW; } char *MEDLoaderBase::buildEmptyString(int lgth) -- 2.39.2