mirror of
https://gitee.com/openharmony/filemanagement_user_file_service
synced 2024-11-26 17:10:55 +00:00
fix:code diff
Signed-off-by: zhouoaoteng <zhouaoteng@huawei.com>
This commit is contained in:
parent
8d0fd1308f
commit
8acc162a77
@ -113,7 +113,6 @@ private:
|
||||
T data;
|
||||
int code {ERR_OK};
|
||||
};
|
||||
|
||||
napi_value CallObjectMethod(const char *name, napi_value const *argv = nullptr, size_t argc = 0);
|
||||
int CallJsMethod(const std::string &funcName, JsRuntime &jsRuntime, NativeReference *jsObj,
|
||||
InputArgsParser argParser, ResultValueParser retParser);
|
||||
|
@ -40,8 +40,7 @@ int FileAccessExtProxy::OpenFile(const Uri &uri, const int flags, int &fd)
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputUri = uri.ToString();
|
||||
if (!data.WriteString(insideInputUri)) {
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -89,8 +88,7 @@ int FileAccessExtProxy::CreateFile(const Uri &parent, const std::string &display
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputUri = parent.ToString();
|
||||
if (!data.WriteString(insideInputUri)) {
|
||||
if (!data.WriteParcelable(&parent)) {
|
||||
HILOG_ERROR("fail to WriteParcelable parent");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -119,17 +117,17 @@ int FileAccessExtProxy::CreateFile(const Uri &parent, const std::string &display
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string tempUri;
|
||||
if (!reply.ReadString(tempUri)) {
|
||||
std::unique_ptr<Uri> tempUri(reply.ReadParcelable<Uri>());
|
||||
if (tempUri == nullptr) {
|
||||
HILOG_ERROR("ReadParcelable value is nullptr.");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
if (tempUri.empty()) {
|
||||
newFile = Uri(*tempUri);
|
||||
if (newFile.ToString().empty()) {
|
||||
HILOG_ERROR("get uri is empty.");
|
||||
return E_GETRESULT;
|
||||
}
|
||||
newFile = Uri(tempUri);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -144,8 +142,7 @@ int FileAccessExtProxy::Mkdir(const Uri &parent, const std::string &displayName,
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputUri = parent.ToString();
|
||||
if (!data.WriteString(insideInputUri)) {
|
||||
if (!data.WriteParcelable(&parent)) {
|
||||
HILOG_ERROR("fail to WriteParcelable parent");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -174,17 +171,17 @@ int FileAccessExtProxy::Mkdir(const Uri &parent, const std::string &displayName,
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string tempUri;
|
||||
if (!reply.ReadString(tempUri)) {
|
||||
std::unique_ptr<Uri> tempUri(reply.ReadParcelable<Uri>());
|
||||
if (tempUri == nullptr) {
|
||||
HILOG_ERROR("ReadParcelable value is nullptr.");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
if (tempUri.empty()) {
|
||||
newFile = Uri(*tempUri);
|
||||
if (newFile.ToString().empty()) {
|
||||
HILOG_ERROR("get uri is empty.");
|
||||
return E_GETRESULT;
|
||||
}
|
||||
newFile = Uri(tempUri);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -199,8 +196,7 @@ int FileAccessExtProxy::Delete(const Uri &sourceFile)
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputUri = sourceFile.ToString();
|
||||
if (!data.WriteString(insideInputUri)) {
|
||||
if (!data.WriteParcelable(&sourceFile)) {
|
||||
HILOG_ERROR("fail to WriteParcelable sourceFile");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -237,14 +233,12 @@ int FileAccessExtProxy::Move(const Uri &sourceFile, const Uri &targetParent, Uri
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputSourceUri = sourceFile.ToString();
|
||||
if (!data.WriteString(insideInputSourceUri)) {
|
||||
if (!data.WriteParcelable(&sourceFile)) {
|
||||
HILOG_ERROR("fail to WriteParcelable sourceFile");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputTargetUri = targetParent.ToString();
|
||||
if (!data.WriteString(insideInputTargetUri)) {
|
||||
if (!data.WriteParcelable(&targetParent)) {
|
||||
HILOG_ERROR("fail to WriteParcelable targetParent");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -268,17 +262,17 @@ int FileAccessExtProxy::Move(const Uri &sourceFile, const Uri &targetParent, Uri
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string tempUri;
|
||||
if (!reply.ReadString(tempUri)) {
|
||||
std::unique_ptr<Uri> tempUri(reply.ReadParcelable<Uri>());
|
||||
if (tempUri == nullptr) {
|
||||
HILOG_ERROR("ReadParcelable value is nullptr.");
|
||||
return E_IPCS;
|
||||
};
|
||||
}
|
||||
|
||||
if (tempUri.empty()) {
|
||||
newFile = Uri(*tempUri);
|
||||
if (newFile.ToString().empty()) {
|
||||
HILOG_ERROR("get uri is empty.");
|
||||
return E_GETRESULT;
|
||||
}
|
||||
newFile = Uri(tempUri);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -287,15 +281,13 @@ static int WriteCopyFuncArguments(OHOS::MessageParcel &data, const Uri &sourceUr
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("WriteCopyFuncArguments");
|
||||
std::string insideInputSourceUri = sourceUri.ToString();
|
||||
if (!data.WriteString(insideInputSourceUri)) {
|
||||
HILOG_ERROR("fail to WriteParcelable insideInputSourceUri");
|
||||
if (!data.WriteParcelable(&sourceUri)) {
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputTargetUri = destUri.ToString();
|
||||
if (!data.WriteString(insideInputTargetUri)) {
|
||||
HILOG_ERROR("fail to WriteParcelable insideInputTargetUri");
|
||||
if (!data.WriteParcelable(&destUri)) {
|
||||
HILOG_ERROR("fail to WriteParcelable targetParent");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
@ -451,8 +443,7 @@ int FileAccessExtProxy::Rename(const Uri &sourceFile, const std::string &display
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputSourceUri = sourceFile.ToString();
|
||||
if (!data.WriteString(insideInputSourceUri)) {
|
||||
if (!data.WriteParcelable(&sourceFile)) {
|
||||
HILOG_ERROR("fail to WriteParcelable sourceFile");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -481,17 +472,17 @@ int FileAccessExtProxy::Rename(const Uri &sourceFile, const std::string &display
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string tempUri;
|
||||
if (!reply.ReadString(tempUri)) {
|
||||
std::unique_ptr<Uri> tempUri(reply.ReadParcelable<Uri>());
|
||||
if (tempUri == nullptr) {
|
||||
HILOG_ERROR("ReadParcelable value is nullptr.");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
if (tempUri.empty()) {
|
||||
newFile = Uri(*tempUri);
|
||||
if (newFile.ToString().empty()) {
|
||||
HILOG_ERROR("get uri is empty.");
|
||||
return E_GETRESULT;
|
||||
}
|
||||
newFile = Uri(tempUri);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -705,8 +696,7 @@ int FileAccessExtProxy::Query(const Uri &uri, std::vector<std::string> &columns,
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputUri = uri.ToString();
|
||||
if (!data.WriteString(insideInputUri)) {
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
HILOG_ERROR("fail to WriteParcelable sourceFile");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -799,8 +789,7 @@ int FileAccessExtProxy::GetFileInfoFromUri(const Uri &selectFile, FileInfo &file
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputUri = selectFile.ToString();
|
||||
if (!data.WriteString(insideInputUri)) {
|
||||
if (!data.WriteParcelable(&selectFile)) {
|
||||
HILOG_ERROR("fail to WriteParcelable selectFile");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -888,8 +877,7 @@ int FileAccessExtProxy::Access(const Uri &uri, bool &isExist)
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideInputUri = uri.ToString();
|
||||
if (!data.WriteString(insideInputUri)) {
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
HILOG_ERROR("fail to WriteParcelable uri");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
@ -94,17 +94,12 @@ ErrCode FileAccessExtStub::CmdOpenFile(MessageParcel &data, MessageParcel &reply
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdOpenFile");
|
||||
std::string insideInputUri;
|
||||
if (!data.ReadString(insideInputUri)) {
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
HILOG_ERROR("Parameter OpenFile fail to ReadParcelable uri");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
if (insideInputUri.empty()) {
|
||||
HILOG_ERROR("Parameter OpenFile insideInputUri is empty");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
int flags = E_IPCS;
|
||||
if (!data.ReadInt32(flags)) {
|
||||
HILOG_ERROR("Parameter OpenFile fail to ReadInt32 flags");
|
||||
@ -117,8 +112,7 @@ ErrCode FileAccessExtStub::CmdOpenFile(MessageParcel &data, MessageParcel &reply
|
||||
}
|
||||
|
||||
int fd = -1;
|
||||
Uri uri(insideInputUri);
|
||||
int ret = OpenFile(uri, flags, fd);
|
||||
int ret = OpenFile(*uri, flags, fd);
|
||||
UniqueFd uniqueFd(fd);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter OpenFile fail to WriteInt32 ret");
|
||||
@ -137,17 +131,12 @@ ErrCode FileAccessExtStub::CmdCreateFile(MessageParcel &data, MessageParcel &rep
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdCreateFile");
|
||||
std::string insideInputUri;
|
||||
if (!data.ReadString(insideInputUri)) {
|
||||
HILOG_ERROR("Parameter OpenFile fail to ReadParcelable uri");
|
||||
std::shared_ptr<Uri> parent(data.ReadParcelable<Uri>());
|
||||
if (parent == nullptr) {
|
||||
HILOG_ERROR("Parameter CreateFile fail to ReadParcelable parent");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
if (insideInputUri.empty()) {
|
||||
HILOG_ERROR("Parameter CreateFile insideInputUri is empty");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
std::string displayName = "";
|
||||
if (!data.ReadString(displayName)) {
|
||||
HILOG_ERROR("Parameter CreateFile fail to ReadString displayName");
|
||||
@ -161,15 +150,13 @@ ErrCode FileAccessExtStub::CmdCreateFile(MessageParcel &data, MessageParcel &rep
|
||||
|
||||
std::string newFile = "";
|
||||
OHOS::Uri newFileUri(newFile);
|
||||
Uri uri(insideInputUri);
|
||||
int ret = CreateFile(uri, displayName, newFileUri);
|
||||
int ret = CreateFile(*parent, displayName, newFileUri);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter CreateFile fail to WriteInt32 ret");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideOutputUri = newFileUri.ToString();
|
||||
if (!reply.WriteString(insideOutputUri)) {
|
||||
if (!reply.WriteParcelable(&newFileUri)) {
|
||||
HILOG_ERROR("Parameter CreateFile fail to WriteParcelable newFileUri");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -181,17 +168,12 @@ ErrCode FileAccessExtStub::CmdMkdir(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdMkdir");
|
||||
std::string insideInputUri;
|
||||
if (!data.ReadString(insideInputUri)) {
|
||||
HILOG_ERROR("Parameter Mkdir fail to ReadParcelable uri");
|
||||
std::shared_ptr<Uri> parent(data.ReadParcelable<Uri>());
|
||||
if (parent == nullptr) {
|
||||
HILOG_ERROR("Parameter Mkdir fail to ReadParcelable parent");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
if (insideInputUri.empty()) {
|
||||
HILOG_ERROR("Parameter Mkdir insideInputUri is empty");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
std::string displayName = "";
|
||||
if (!data.ReadString(displayName)) {
|
||||
HILOG_ERROR("Parameter Mkdir fail to ReadString displayName");
|
||||
@ -205,15 +187,13 @@ ErrCode FileAccessExtStub::CmdMkdir(MessageParcel &data, MessageParcel &reply)
|
||||
|
||||
std::string newFile = "";
|
||||
OHOS::Uri newFileUri(newFile);
|
||||
Uri uri(insideInputUri);
|
||||
int ret = Mkdir(uri, displayName, newFileUri);
|
||||
int ret = Mkdir(*parent, displayName, newFileUri);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter Mkdir fail to WriteInt32 ret");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideOutputUri = newFileUri.ToString();
|
||||
if (!reply.WriteString(insideOutputUri)) {
|
||||
if (!reply.WriteParcelable(&newFileUri)) {
|
||||
HILOG_ERROR("Parameter Mkdir fail to WriteParcelable newFileUri");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -225,19 +205,13 @@ ErrCode FileAccessExtStub::CmdDelete(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdDelete");
|
||||
std::string insideInputUri;
|
||||
if (!data.ReadString(insideInputUri)) {
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
HILOG_ERROR("Parameter Delete fail to ReadParcelable uri");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
if (insideInputUri.empty()) {
|
||||
HILOG_ERROR("Parameter Delete insideInputUri is empty");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
Uri uri(insideInputUri);
|
||||
int ret = Delete(uri);
|
||||
int ret = Delete(*uri);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter Delete fail to WriteInt32 ret");
|
||||
return E_IPCS;
|
||||
@ -250,30 +224,27 @@ ErrCode FileAccessExtStub::CmdMove(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdMove");
|
||||
std::string sourceFile;
|
||||
if (!data.ReadString(sourceFile)) {
|
||||
HILOG_ERROR("Parameter Move fail to ReadParcelable uri");
|
||||
std::shared_ptr<Uri> sourceFile(data.ReadParcelable<Uri>());
|
||||
if (sourceFile == nullptr) {
|
||||
HILOG_ERROR("Parameter Move fail to ReadParcelable sourceFile");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string targetParent;
|
||||
if (!data.ReadString(targetParent)) {
|
||||
HILOG_ERROR("Parameter Move fail to ReadParcelable uri");
|
||||
std::shared_ptr<Uri> targetParent(data.ReadParcelable<Uri>());
|
||||
if (targetParent == nullptr) {
|
||||
HILOG_ERROR("Parameter Move fail to ReadParcelable targetParent");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string newFile = "";
|
||||
OHOS::Uri newFileUri(newFile);
|
||||
Uri source(sourceFile);
|
||||
Uri target(targetParent);
|
||||
int ret = Move(source, target, newFileUri);
|
||||
int ret = Move(*sourceFile, *targetParent, newFileUri);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter Move fail to WriteInt32 ret");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideOutputUri = newFileUri.ToString();
|
||||
if (!reply.WriteString(insideOutputUri)) {
|
||||
if (!reply.WriteParcelable(&newFileUri)) {
|
||||
HILOG_ERROR("Parameter Move fail to WriteParcelable newFileUri");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -285,15 +256,15 @@ ErrCode FileAccessExtStub::CmdCopy(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdCopy");
|
||||
std::string sourceUri;
|
||||
if (!data.ReadString(sourceUri)) {
|
||||
HILOG_ERROR("Parameter Copy fail to ReadParcelable uri");
|
||||
std::shared_ptr<Uri> sourceUri(data.ReadParcelable<Uri>());
|
||||
if (sourceUri == nullptr) {
|
||||
HILOG_ERROR("Parameter Copy fail to ReadParcelable sourceUri");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string destUri;
|
||||
if (!data.ReadString(destUri)) {
|
||||
HILOG_ERROR("Parameter Copy fail to ReadParcelable uri");
|
||||
std::shared_ptr<Uri> destUri(data.ReadParcelable<Uri>());
|
||||
if (destUri == nullptr) {
|
||||
HILOG_ERROR("Parameter Copy fail to ReadParcelable destUri");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
@ -304,9 +275,7 @@ ErrCode FileAccessExtStub::CmdCopy(MessageParcel &data, MessageParcel &reply)
|
||||
}
|
||||
|
||||
std::vector<Result> copyResult;
|
||||
Uri source(sourceUri);
|
||||
Uri dest(destUri);
|
||||
int ret = Copy(source, dest, copyResult, force);
|
||||
int ret = Copy(*sourceUri, *destUri, copyResult, force);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter Copy fail to WriteInt32 ret");
|
||||
return E_IPCS;
|
||||
@ -369,9 +338,9 @@ ErrCode FileAccessExtStub::CmdRename(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdRename");
|
||||
std::string sourceFile;
|
||||
if (!data.ReadString(sourceFile)) {
|
||||
HILOG_ERROR("Parameter Rename fail to ReadParcelable uri");
|
||||
std::shared_ptr<Uri> sourceFile(data.ReadParcelable<Uri>());
|
||||
if (sourceFile == nullptr) {
|
||||
HILOG_ERROR("Parameter Rename fail to ReadParcelable sourceFile");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
@ -388,15 +357,13 @@ ErrCode FileAccessExtStub::CmdRename(MessageParcel &data, MessageParcel &reply)
|
||||
|
||||
std::string newFile = "";
|
||||
OHOS::Uri newFileUri(newFile);
|
||||
Uri source(sourceFile);
|
||||
int ret = Rename(source, displayName, newFileUri);
|
||||
int ret = Rename(*sourceFile, displayName, newFileUri);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter Rename fail to WriteInt32 ret");
|
||||
return E_IPCS;
|
||||
}
|
||||
|
||||
std::string insideOutputUri = newFileUri.ToString();
|
||||
if (!reply.WriteString(insideOutputUri)) {
|
||||
if (!reply.WriteParcelable(&newFileUri)) {
|
||||
HILOG_ERROR("Parameter Rename fail to WriteParcelable newFileUri");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -573,8 +540,8 @@ ErrCode FileAccessExtStub::CmdQuery(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdQuery");
|
||||
std::string uri;
|
||||
if (!data.ReadString(uri)) {
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
HILOG_ERROR("Parameter Query fail to ReadParcelable uri");
|
||||
return E_IPCS;
|
||||
}
|
||||
@ -584,7 +551,7 @@ ErrCode FileAccessExtStub::CmdQuery(MessageParcel &data, MessageParcel &reply)
|
||||
HILOG_ERROR("Query operation failed to Read count");
|
||||
return E_IPCS;
|
||||
}
|
||||
if (count > FILE_RESULT_TYPE.size()) {
|
||||
if (count > static_cast<int64_t>(FILE_RESULT_TYPE.size())) {
|
||||
HILOG_ERROR(" The number of query operations exceeds %{public}zu ", FILE_RESULT_TYPE.size());
|
||||
return EINVAL;
|
||||
}
|
||||
@ -593,8 +560,7 @@ ErrCode FileAccessExtStub::CmdQuery(MessageParcel &data, MessageParcel &reply)
|
||||
columns.push_back(data.ReadString());
|
||||
}
|
||||
std::vector<std::string> results;
|
||||
Uri sourceUri(uri);
|
||||
int ret = Query(sourceUri, columns, results);
|
||||
int ret = Query(*uri, columns, results);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter Query fail to WriteInt32 ret");
|
||||
return E_IPCS;
|
||||
@ -620,15 +586,14 @@ ErrCode FileAccessExtStub::CmdGetFileInfoFromUri(MessageParcel &data, MessagePar
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdGetFileInfoFromUri");
|
||||
std::string uri;
|
||||
if (!data.ReadString(uri)) {
|
||||
HILOG_ERROR("Parameter GetFileInfoFromUri fail to ReadParcelable uri");
|
||||
return E_IPCS;
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
HILOG_ERROR("SelectFile uri is nullptr");
|
||||
return E_URIS;
|
||||
}
|
||||
|
||||
FileInfo fileInfoTemp;
|
||||
Uri sourceUri(uri);
|
||||
int ret = GetFileInfoFromUri(sourceUri, fileInfoTemp);
|
||||
int ret = GetFileInfoFromUri(*uri, fileInfoTemp);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter GetFileInfoFromUri fail to WriteInt32 ret");
|
||||
return E_IPCS;
|
||||
@ -667,15 +632,14 @@ ErrCode FileAccessExtStub::CmdAccess(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
UserAccessTracer trace;
|
||||
trace.Start("CmdAccess");
|
||||
std::string uri;
|
||||
if (!data.ReadString(uri)) {
|
||||
HILOG_ERROR("Parameter Query fail to ReadParcelable uri");
|
||||
return E_IPCS;
|
||||
std::shared_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
HILOG_ERROR("Access uri is nullptr");
|
||||
return E_URIS;
|
||||
}
|
||||
|
||||
bool isExist = false;
|
||||
Uri sourceUri(uri);
|
||||
int ret = Access(sourceUri, isExist);
|
||||
int ret = Access(*uri, isExist);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("Parameter Access fail to WriteInt32 ret");
|
||||
return E_IPCS;
|
||||
|
@ -244,7 +244,7 @@ int JsFileAccessExtAbility::CallJsMethod(const std::string &funcName, JsRuntime
|
||||
CallJsParam *param = reinterpret_cast<CallJsParam *>(work->data);
|
||||
if (param == nullptr) {
|
||||
HILOG_ERROR("failed to get CallJsParam.");
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
napi_handle_scope scope = nullptr;
|
||||
@ -254,7 +254,7 @@ int JsFileAccessExtAbility::CallJsMethod(const std::string &funcName, JsRuntime
|
||||
if (DoCallJsMethod(param) != ERR_OK) {
|
||||
HILOG_ERROR("failed to call DoCallJsMethod.");
|
||||
}
|
||||
|
||||
|
||||
std::unique_lock<std::mutex> lock(param->fileOperateMutex);
|
||||
param->isReady = true;
|
||||
param->fileOperateCondition.notify_one();
|
||||
|
@ -19,8 +19,6 @@
|
||||
#include "file_trash_n_exporter.h"
|
||||
#include "filemgmt_libn.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "os_account_manager.h"
|
||||
#include "parameter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Trash {
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.UserFile.ExternalFileManager",
|
||||
"versionCode": 1000003,
|
||||
"versionName": "1.0.0.3",
|
||||
"versionCode": 1000004,
|
||||
"versionName": "1.0.0.4",
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 9,
|
||||
"icon": "$media:app_icon",
|
||||
|
@ -58,28 +58,6 @@ function getPath(uri): string {
|
||||
return path;
|
||||
}
|
||||
|
||||
function encodePathOfUri(uri): string {
|
||||
try {
|
||||
let suffixUri = uri.slice(SLICE_PREFIX_URI, uri.length);
|
||||
let prefixUri = uri.slice(0, SLICE_PREFIX_URI);
|
||||
uri = prefixUri.concat(encodeURIComponent(suffixUri).replace(/%2F/g, '/'));
|
||||
} catch (e) {
|
||||
hilog.error(DOMAIN_CODE, TAG, 'The reason of encodeURIComponent: ' + e.message + ' code: ' + e.code);
|
||||
uri = '';
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
function decodeUri(uri): string {
|
||||
try {
|
||||
uri = decodeURIComponent(uri);
|
||||
} catch (e) {
|
||||
hilog.error(DOMAIN_CODE, TAG, 'The reason of decodeURIComponent: ' + e.message + ' code: ' + e.code);
|
||||
uri = '';
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
interface Fileinfo {
|
||||
uri: string,
|
||||
relativePath: string,
|
||||
@ -139,6 +117,28 @@ function rootsReturnObject(roots: object, code: number): {roots: object, code: n
|
||||
};
|
||||
}
|
||||
|
||||
function encodePathOfUri(uri): string {
|
||||
try {
|
||||
let suffixUri = uri.slice(SLICE_PREFIX_URI, uri.length);
|
||||
let prefixUri = uri.slice(0, SLICE_PREFIX_URI);
|
||||
uri = prefixUri.concat(encodeURIComponent(suffixUri).replace(/%2F/g, '/'));
|
||||
} catch (e) {
|
||||
hilog.error(DOMAIN_CODE, TAG, 'The reason of encodeURIComponent: ' + e.message + ' code: ' + e.code);
|
||||
uri = '';
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
function decodeUri(uri): string {
|
||||
try {
|
||||
uri = decodeURIComponent(uri);
|
||||
} catch (e) {
|
||||
hilog.error(DOMAIN_CODE, TAG, 'The reason of decodeURIComponent: ' + e.message + ' code: ' + e.code);
|
||||
uri = '';
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
export {
|
||||
getPath, checkUri, encodePathOfUri, decodeUri, uriReturnObject, infosReturnObject, fdReturnObject, boolReturnObject, resultsResultObject,
|
||||
fileinfoReturnObject, rootsReturnObject, BUNDLE_NAME, DOMAIN_CODE, FILE_PREFIX_NAME, TAG
|
||||
|
@ -161,17 +161,6 @@ export default class FileExtAbility extends Extension {
|
||||
}
|
||||
}
|
||||
|
||||
isCrossDeviceLink(sourceFileUri, targetParentUri): boolean {
|
||||
let roots = this.getRoots().roots;
|
||||
for (let index = 0; index < roots.length; index++) {
|
||||
let uri = roots[index].uri;
|
||||
if (sourceFileUri.indexOf(uri) === 0 && targetParentUri.indexOf(uri) === 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
openFile(sourceFileUri, flags): {number, number} {
|
||||
sourceFileUri = decodeUri(sourceFileUri);
|
||||
if (!checkUri(sourceFileUri)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
|
||||
virtual ~UserAccessTracer()
|
||||
{
|
||||
for (int32_t i = 0; i < count_; i++ ) {
|
||||
for (int32_t i = 0; i < count_; i++) {
|
||||
FinishTrace(HITRACE_TAG_FILEMANAGEMENT);
|
||||
}
|
||||
count_ = 0;
|
||||
@ -44,7 +44,6 @@ public:
|
||||
}
|
||||
private:
|
||||
int32_t count_ = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // OHOS_USER_ACCESS_TRACER
|
||||
|
Loading…
Reference in New Issue
Block a user