X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/86ad7bacaf8c0b206a62bf87193ca6800006a854..c897fb0d193bbe081581d7ea7f579f04df1b5b5d:/src/surf/FileImpl.cpp diff --git a/src/surf/FileImpl.cpp b/src/surf/FileImpl.cpp index 53548500a5..e454c3a073 100644 --- a/src/surf/FileImpl.cpp +++ b/src/surf/FileImpl.cpp @@ -17,9 +17,9 @@ FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_ location_ = st->getImpl(); std::map* content = location_->getContent(); // if file does not exist create an empty file - if (content->find(path) != content->end()) + try { size_ = content->at(path); - else { + } catch (std::out_of_range& unfound) { size_ = 0; content->insert({path, size_}); XBT_DEBUG("File '%s' was not found, file created.", path.c_str()); @@ -96,13 +96,13 @@ void FileImpl::move(const char* fullpath) /* Check if the new full path is on the same mount point */ if (not strncmp(mount_point_.c_str(), fullpath, mount_point_.size())) { std::map* content = location_->getContent(); - if (content->find(path_) != content->end()) { // src file exists + try { // src file exists sg_size_t new_size = content->at(path_); content->erase(path_); std::string path = std::string(fullpath).substr(mount_point_.size(), strlen(fullpath)); content->insert({path.c_str(), new_size}); XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath, new_size); - } else { + } catch (std::out_of_range& unfound) { XBT_WARN("File %s doesn't exist", path_.c_str()); } } else {