From: Sungbae Yoo Date: Tue, 23 May 2017 02:06:10 +0000 (+0900) Subject: Fix copy() to be able to handle large files than 2GB X-Git-Tag: submit/tizen/20170523.073824^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9df7a18a5ef99658f4b870160a7b44aa53c19818;p=platform%2Fcore%2Fsecurity%2Fklay.git Fix copy() to be able to handle large files than 2GB Signed-off-by: Sungbae Yoo Change-Id: I5555d8dc13128ea969b09b35c913d54ccbe4e537 --- diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 91b27a3..c264b7b 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -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(); }