From e2680c4776709548e15f400af83ffe4a2cf5eb49 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 4 Jul 2017 12:07:14 +0200 Subject: [PATCH 1/1] address a todo --- include/simgrid/s4u/File.hpp | 4 +++- src/msg/msg_io.cpp | 2 +- src/s4u/s4u_file.cpp | 7 ++++++- src/surf/FileImpl.hpp | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/simgrid/s4u/File.hpp b/include/simgrid/s4u/File.hpp index 189c70331a..e3b644b75b 100644 --- a/include/simgrid/s4u/File.hpp +++ b/include/simgrid/s4u/File.hpp @@ -52,7 +52,9 @@ public: sg_size_t size(); /** Sets the file head to the given position. */ - void seek(sg_size_t pos); + void seek(sg_offset_t pos); + void seek(sg_offset_t pos, int origin); + /** Retrieves the current file position */ sg_size_t tell(); diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index a37a312db1..031d2dda4e 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -233,7 +233,7 @@ sg_size_t MSG_file_get_size(msg_file_t fd) */ msg_error_t MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin) { - fd->seek(offset); // TODO re-add origin + fd->seek(offset, origin); return MSG_OK; } diff --git a/src/s4u/s4u_file.cpp b/src/s4u/s4u_file.cpp index 5eaf55c82d..25595a9212 100644 --- a/src/s4u/s4u_file.cpp +++ b/src/s4u/s4u_file.cpp @@ -73,11 +73,16 @@ sg_size_t File::size() return simgrid::simix::kernelImmediate([this] { return pimpl_->size(); }); } -void File::seek(sg_size_t pos) +void File::seek(sg_offset_t pos) { simgrid::simix::kernelImmediate([this, pos] { pimpl_->seek(pos, SEEK_SET); }); } +void File::seek(sg_offset_t pos, int origin) +{ + simgrid::simix::kernelImmediate([this, pos, origin] { pimpl_->seek(pos, origin); }); +} + sg_size_t File::tell() { return simgrid::simix::kernelImmediate([this] { return pimpl_->tell(); }); diff --git a/src/surf/FileImpl.hpp b/src/surf/FileImpl.hpp index b50fa8f262..eea45fccd2 100644 --- a/src/surf/FileImpl.hpp +++ b/src/surf/FileImpl.hpp @@ -47,7 +47,7 @@ private: std::string path_; std::string mount_point_; sg_size_t size_; - sg_size_t current_position_ = 0; + sg_size_t current_position_ = SEEK_SET; }; } } -- 2.20.1