A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix build on Centos7 (again).
[simgrid.git]
/
src
/
surf
/
FileImpl.cpp
diff --git
a/src/surf/FileImpl.cpp
b/src/surf/FileImpl.cpp
index
e454c3a
..
d190065
100644
(file)
--- a/
src/surf/FileImpl.cpp
+++ b/
src/surf/FileImpl.cpp
@@
-17,9
+17,10
@@
FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_
location_ = st->getImpl();
std::map<std::string, sg_size_t>* content = location_->getContent();
// if file does not exist create an empty file
location_ = st->getImpl();
std::map<std::string, sg_size_t>* content = location_->getContent();
// if file does not exist create an empty file
- try {
- size_ = content->at(path);
- } catch (std::out_of_range& unfound) {
+ auto sz = content->find(path);
+ if (sz != content->end()) {
+ size_ = sz->second;
+ } else {
size_ = 0;
content->insert({path, size_});
XBT_DEBUG("File '%s' was not found, file created.", path.c_str());
size_ = 0;
content->insert({path, size_});
XBT_DEBUG("File '%s' was not found, file created.", path.c_str());
@@
-28,7
+29,7
@@
FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_
Action* FileImpl::read(sg_size_t size)
{
Action* FileImpl::read(sg_size_t size)
{
- XBT_DEBUG("READ %s on disk '%s'",
cname(), location_->c
name());
+ XBT_DEBUG("READ %s on disk '%s'",
getCname(), location_->getC
name());
if (current_position_ + size > size_) {
if (current_position_ > size_) {
size = 0;
if (current_position_ + size > size_) {
if (current_position_ > size_) {
size = 0;
@@
-44,7
+45,7
@@
Action* FileImpl::read(sg_size_t size)
Action* FileImpl::write(sg_size_t size)
{
Action* FileImpl::write(sg_size_t size)
{
- XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'",
cname(), location_->c
name(), size, size_);
+ XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'",
getCname(), location_->getC
name(), size, size_);
StorageAction* action = location_->write(size);
action->file_ = this;
StorageAction* action = location_->write(size);
action->file_ = this;
@@
-78,10
+79,10
@@
int FileImpl::unlink()
{
/* Check if the file is on this storage */
if (location_->getContent()->find(path_) == location_->getContent()->end()) {
{
/* Check if the file is on this storage */
if (location_->getContent()->find(path_) == location_->getContent()->end()) {
- XBT_WARN("File %s is not on disk %s. Impossible to unlink",
cname(), location_->c
name());
+ XBT_WARN("File %s is not on disk %s. Impossible to unlink",
getCname(), location_->getC
name());
return -1;
} else {
return -1;
} else {
- XBT_DEBUG("UNLINK %s on disk '%s'",
cname(), location_->c
name());
+ XBT_DEBUG("UNLINK %s on disk '%s'",
getCname(), location_->getC
name());
location_->usedSize_ -= size_;
// Remove the file from storage
location_->usedSize_ -= size_;
// Remove the file from storage
@@
-91,22
+92,23
@@
int FileImpl::unlink()
}
}
}
}
-void FileImpl::move(
const char*
fullpath)
+void FileImpl::move(
std::string
fullpath)
{
/* Check if the new full path is on the same mount point */
{
/* Check if the new full path is on the same mount point */
- if (not strncmp(mount_point_.c_str(), fullpath, mount_point_.size())) {
+ if (not strncmp(mount_point_.c_str(), fullpath
.c_str()
, mount_point_.size())) {
std::map<std::string, sg_size_t>* content = location_->getContent();
std::map<std::string, sg_size_t>* content = location_->getContent();
- try { // src file exists
- sg_size_t new_size = content->at(path_);
+ auto sz = content->find(path_);
+ if (sz != content->end()) { // src file exists
+ sg_size_t new_size = sz->second;
content->erase(path_);
content->erase(path_);
- std::string path =
std::string(fullpath).substr(mount_point_.size(), strlen(fullpath
));
+ std::string path =
fullpath.substr(mount_point_.length(), fullpath.length(
));
content->insert({path.c_str(), new_size});
content->insert({path.c_str(), new_size});
- XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath, new_size);
- }
catch (std::out_of_range& unfound)
{
+ XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath
.c_str()
, new_size);
+ }
else
{
XBT_WARN("File %s doesn't exist", path_.c_str());
}
} else {
XBT_WARN("File %s doesn't exist", path_.c_str());
}
} else {
- XBT_WARN("New full path %s is not on the same mount point: %s.", fullpath, mount_point_.c_str());
+ XBT_WARN("New full path %s is not on the same mount point: %s.", fullpath
.c_str()
, mount_point_.c_str());
}
}
}
}
}
}