Fix copy() to be able to handle large files than 2GB 52/130552/2 accepted/tizen/unified/20170531.082403 submit/tizen/20170523.073824
authorSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 23 May 2017 02:06:10 +0000 (11:06 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 23 May 2017 02:21:22 +0000 (11:21 +0900)
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: I5555d8dc13128ea969b09b35c913d54ccbe4e537

src/filesystem.cpp

index 91b27a385a045086bc4975015d38f4cb4ace2d88..c264b7b631a76419932225f3edd1264907d0d997 100644 (file)
@@ -280,7 +280,14 @@ File File::copyTo(const std::string& destDir)
        } else {
                open(O_RDONLY);
                destFile.create(getMode());
-               ::sendfile(destFile.descriptor, descriptor, 0, size());
+               off_t s = 0;
+               while (s < size()) {
+                       ssize_t ret;
+                       ret = ::sendfile(destFile.descriptor, descriptor, &s, size() - s);
+                       if (ret < 0) {
+                               throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       }
+               }
                destFile.close();
                close();
        }