X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ecd057376de847d40e1e29e2bf33e95eae3f835f..04a207ea8a9ddfba41b4d3806451b051eb1ba05c:/src/plugins/file_system/s4u_FileSystem.cpp diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 20e5c27c8a..677b4c5353 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -186,22 +186,13 @@ sg_size_t File::write(sg_size_t size, bool write_inside) // If the disk is full before even starting to write if (sg_disk_get_size_used(local_disk_) >= sg_disk_get_size(local_disk_)) return 0; - if (not write_inside) { + if (not write_inside) /* Subtract the part of the file that might disappear from the used sized on the storage element */ local_disk_->extension()->decr_used_size(size_ - current_position_); - write_size = local_disk_->write(size); - local_disk_->extension()->incr_used_size(write_size); - current_position_ += write_size; - size_ = current_position_; - } else { - write_size = local_disk_->write(size); - current_position_ += write_size; - if (current_position_ > size_) - size_ = current_position_; - } + write_size = local_disk_->write(size); + update_position(current_position_ + write_size); kernel::actor::simcall_answered([this] { std::map>* content = local_disk_->extension()->get_content(); - content->erase(path_); content->insert({path_, size_}); }); @@ -223,19 +214,29 @@ void File::seek(sg_offset_t offset, int origin) { switch (origin) { case SEEK_SET: - current_position_ = offset; - break; + update_position(offset); + break; case SEEK_CUR: - current_position_ += offset; + update_position(current_position_ + offset); break; case SEEK_END: - current_position_ = size_ + offset; + update_position(size_ + offset); break; default: break; } } +void File::update_position(sg_offset_t position) +{ + xbt_assert(position >= 0, "Error in seek, cannot seek before file %s", get_path()); + current_position_ = position; + if(current_position_>size_){ + local_disk_->extension()->incr_used_size(current_position_-size_); + size_ = current_position_; + } +} + sg_size_t File::tell() const { return current_position_;