Add lseek for filesystem 87/96787/3 accepted/tizen/3.0/common/20161116.143239 accepted/tizen/3.0/ivi/20161116.021100 accepted/tizen/3.0/mobile/20161116.021004 accepted/tizen/3.0/tv/20161116.021018 accepted/tizen/3.0/wearable/20161116.021039 accepted/tizen/common/20161114.171517 accepted/tizen/ivi/20161114.074213 accepted/tizen/ivi/20161114.074736 accepted/tizen/mobile/20161114.074117 accepted/tizen/mobile/20161114.074642 accepted/tizen/tv/20161114.074126 accepted/tizen/tv/20161114.074701 accepted/tizen/wearable/20161114.074154 accepted/tizen/wearable/20161114.074720 submit/tizen/20161114.035936 submit/tizen/20161114.045524 submit/tizen_3.0/20161114.035945 submit/tizen_3.0/20161114.045617 submit/tizen_3.0/20161115.020653
authorSeok Hong <seok85.hong@samsung.com>
Thu, 10 Nov 2016 07:38:39 +0000 (16:38 +0900)
committerSeok Hong <seok85.hong@samsung.com>
Thu, 10 Nov 2016 09:26:20 +0000 (18:26 +0900)
Change-Id: I46251f11892788bde41fdc57ba88bc331fee3cd1
Signed-off-by: Seok Hong <seok85.hong@samsung.com>
include/klay/filesystem.h
src/filesystem.cpp
test/filesystem.cpp

index 02a80f6850b89c12539ebeb614157cfec324f8b4..75e35b9945ee664bb2d7ece05fc020538c7aebef 100644 (file)
@@ -18,6 +18,7 @@
 #define __RUNTIME_FILESYSTEM_H__
 
 #include <dirent.h>
+#include <sys/types.h>
 
 #include <string>
 
@@ -96,6 +97,7 @@ public:
        void open(int flags);
        void read(void *buffer, const size_t size) const;
        void write(const void *buffer, const size_t size) const;
+       void lseek(off_t offset, int whence) const;
        void close();
        File copyTo(const std::string& pathname);
        void remove(bool recursive = false);
index f9944c4a8dcb1b6213812644468ec0f95270e1b4..a5cb7fa59f4b7bbf3ca723aecf61ac1e094154ae 100644 (file)
@@ -226,6 +226,13 @@ void File::write(const void *buffer, const size_t size) const
        }
 }
 
+void File::lseek(off_t offset, int whence) const
+{
+       if (::lseek(descriptor, offset, whence) == -1) {
+               throw runtime::Exception(runtime::GetSystemErrorMessage());
+       }
+}
+
 File File::copyTo(const std::string& destDir)
 {
        const std::string& filename = getPath();
index 41790f7a83f29fc4d704fa0eabbff295159443cf..1a044f8308e84a994d0311fdb11cab6269b8014a 100644 (file)
@@ -50,6 +50,7 @@ TESTCASE(FileIO)
                tmp.create(755);
                tmp.lock();
                tmp.write(testbuf, ::strlen(testbuf));
+               tmp.lseek(10, SEEK_SET);
                tmp.unlock();
                tmp.close();
        } catch (runtime::Exception& e) {