From 060d66a5d34f822a805e01cf212fc88ab96c72a8 Mon Sep 17 00:00:00 2001 From: zhangkaixiang Date: Sat, 19 Aug 2023 14:34:45 +0800 Subject: [PATCH] open by media when media or docs uri not existing Signed-off-by: zhangkaixiang Change-Id: I16f43c5c8993f891ccf590aa509fb0ba5b00a317 --- interfaces/kits/js/src/mod_fs/properties/open.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/properties/open.cpp b/interfaces/kits/js/src/mod_fs/properties/open.cpp index 0d94a2b3d..4be58bf8c 100644 --- a/interfaces/kits/js/src/mod_fs/properties/open.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/open.cpp @@ -54,6 +54,7 @@ const std::string PATH_SHARE = "/data/storage/el2/share"; const std::string MODE_RW = "/rw/"; const std::string MODE_R = "/r/"; const std::string MEDIA = "media"; +const std::string DOCS = "docs"; const std::string DATASHARE = "datashare"; static tuple GetJsFlags(napi_env env, const NFuncArg &funcArg) @@ -163,8 +164,8 @@ napi_value Open::Sync(napi_env env, napi_callback_info info) if (uriType == SCHEME_FILE) { AppFileService::ModuleFileUri::FileUri fileUri(pathStr); pathStr = fileUri.GetRealPath(); - if (bundleName == MEDIA && (pathStr.find(".") == string::npos || - access(pathStr.c_str(), F_OK) != 0)) { + if ((bundleName == MEDIA || bundleName == DOCS) && + access(pathStr.c_str(), F_OK) != 0) { int ret = OpenFileByDatashare(uri.ToString(), mode); if (ret >= 0) { auto file = InstantiateFile(env, ret, uri.ToString(), true).val_; @@ -223,8 +224,8 @@ static NError AsyncCbExec(shared_ptr arg, const string &path, if (uriType == SCHEME_FILE) { AppFileService::ModuleFileUri::FileUri fileUri(path); pStr = fileUri.GetRealPath(); - if (bundleName == MEDIA && (pStr.find(".") == string::npos || - access(pStr.c_str(), F_OK) != 0)) { + if ((bundleName == MEDIA || bundleName == DOCS) && + access(pStr.c_str(), F_OK) != 0) { int ret = OpenFileByDatashare(path, mode); if (ret >= 0) { arg->fd = ret; -- Gitee