diff --git a/interfaces/kits/js/src/mod_fs/properties/copy_file.cpp b/interfaces/kits/js/src/mod_fs/properties/copy_file.cpp index 6dc697584af071e1cbe1adf4bdea9966c313f3af..15eb6ea4b48c658026f511854953f6783d04c753 100755 --- a/interfaces/kits/js/src/mod_fs/properties/copy_file.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/copy_file.cpp @@ -57,11 +57,24 @@ static NError SendFileCore(FileInfo& srcFdg, FileInfo& destFdg, struct stat& sta HILOGE("Failed to request heap memory."); return NError(ENOMEM); } - int ret = uv_fs_sendfile(nullptr, sendfile_req.get(), destFdg.fdg->GetFD(), srcFdg.fdg->GetFD(), 0, - statbf.st_size, nullptr); + int64_t offset = 0; + size_t size = static_cast(statbf.st_size); + int ret = 0; + while (size > MAX_SIZE) { + ret = uv_fs_sendfile(nullptr, sendfile_req.get(), destFdg.fdg->GetFD(), srcFdg.fdg->GetFD(), + offset, MAX_SIZE, nullptr); + if (ret < 0) { + HILOGE("Failed to sendfile by ret : %{public}d", ret); + return NError(ret); + } + offset += MAX_SIZE; + size -= MAX_SIZE; + } + ret = uv_fs_sendfile(nullptr, sendfile_req.get(), destFdg.fdg->GetFD(), srcFdg.fdg->GetFD(), + offset, size, nullptr); if (ret < 0) { HILOGE("Failed to sendfile by ret : %{public}d", ret); - return NError(errno); + return NError(ret); } return NError(ERRNO_NOERR); } diff --git a/interfaces/kits/js/src/mod_fs/properties/copy_file.h b/interfaces/kits/js/src/mod_fs/properties/copy_file.h index fef4af34b7eb795edfb0708d80fc8bce325f933d..2801c4a43a9793bab23a910d6b0e41d78b9c9ab1 100755 --- a/interfaces/kits/js/src/mod_fs/properties/copy_file.h +++ b/interfaces/kits/js/src/mod_fs/properties/copy_file.h @@ -36,7 +36,7 @@ public: Para(FileInfo src, FileInfo dest) : src_(move(src)), dest_(move(dest)){}; }; - +constexpr size_t MAX_SIZE = 0x7ffff000; const string PROCEDURE_COPYFILE_NAME = "FileIOCopyFile"; } // namespace ModuleFileIO } // namespace FileManagement diff --git a/interfaces/kits/js/src/mod_securitylabel/security_label.h b/interfaces/kits/js/src/mod_securitylabel/security_label.h index e789b7261bb3ad7cb7f14a6566cfbcb53696f718..fbac9b3104a07400e077f1d822d3a66b6f917d55 100644 --- a/interfaces/kits/js/src/mod_securitylabel/security_label.h +++ b/interfaces/kits/js/src/mod_securitylabel/security_label.h @@ -35,7 +35,11 @@ public: if (DATA_LEVEL.count(dataLevel) != 1) { return false; } +#ifdef IOS_PLATFORM + if (setxattr(path.c_str(), XATTR_KEY, dataLevel.c_str(), dataLevel.size(), 0, 0) < 0) { +#else if (setxattr(path.c_str(), XATTR_KEY, dataLevel.c_str(), dataLevel.size(), 0) < 0) { +#endif return false; } return true; @@ -43,7 +47,11 @@ public: static std::string GetSecurityLabel(const std::string &path) { +#ifdef IOS_PLATFORM + auto xattrValueSize = getxattr(path.c_str(), XATTR_KEY, nullptr, 0, 0, 0); +#else auto xattrValueSize = getxattr(path.c_str(), XATTR_KEY, nullptr, 0); +#endif if (xattrValueSize == -1 || errno == ENOTSUP) { return ""; } @@ -54,8 +62,11 @@ public: if (xattrValue == nullptr) { return ""; } - +#ifdef IOS_PLATFORM + xattrValueSize = getxattr(path.c_str(), XATTR_KEY, xattrValue.get(), xattrValueSize, 0, 0); +#else xattrValueSize = getxattr(path.c_str(), XATTR_KEY, xattrValue.get(), xattrValueSize); +#endif if (xattrValueSize == -1 || errno == ENOTSUP) { return ""; }