From 95599cd43dc4df3d7aa5227d3cf856c02da1fca4 Mon Sep 17 00:00:00 2001 From: tianp Date: Sat, 2 Aug 2025 12:09:40 +0800 Subject: [PATCH] =?UTF-8?q?open=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tianp Change-Id: I003e58c1e0652e3879d34dbef5cbe3a78fffd82b --- .../js/src/mod_fs/properties/ani/open_ani.cpp | 2 ++ .../js/src/mod_fs/properties/open_core.cpp | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/open_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/open_ani.cpp index 3a4049c07..4c386485a 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/open_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/open_ani.cpp @@ -46,6 +46,7 @@ ani_object OpenAni::OpenSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani ErrorHandler::Throw(env, EINVAL); return nullptr; } + FsResult ret = OpenCore::DoOpen(filePath, modeOp); if (!ret.IsSuccess()) { HILOGE("Open failed"); @@ -53,6 +54,7 @@ ani_object OpenAni::OpenSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani ErrorHandler::Throw(env, err); return nullptr; } + const FsFile *file = ret.GetData().value(); auto result = FileWrapper::Wrap(env, move(file)); if (result == nullptr) { diff --git a/interfaces/kits/js/src/mod_fs/properties/open_core.cpp b/interfaces/kits/js/src/mod_fs/properties/open_core.cpp index 8ead99468..04a2bb1cd 100644 --- a/interfaces/kits/js/src/mod_fs/properties/open_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/open_core.cpp @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "open_core.h" #include @@ -50,16 +51,16 @@ using namespace OHOS::DistributedFS::ModuleRemoteUri; using namespace OHOS::AppExecFwk; #endif -const std::string PROCEDURE_OPEN_NAME = "FileIOOpen"; -const std::string MEDIALIBRARY_DATA_URI = "datashare:///media"; -const std::string FILE_DATA_URI = "file://"; -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"; -const std::string SCHEME_BROKER = "content"; +const string PROCEDURE_OPEN_NAME = "FileIOOpen"; +const string MEDIALIBRARY_DATA_URI = "datashare:///media"; +const string FILE_DATA_URI = "file://"; +const string PATH_SHARE = "/data/storage/el2/share"; +const string MODE_RW = "/rw/"; +const string MODE_R = "/r/"; +const string MEDIA = "media"; +const string DOCS = "docs"; +const string DATASHARE = "datashare"; +const string SCHEME_BROKER = "content"; #if !defined(WIN_PLATFORM) && !defined(IOS_PLATFORM) constexpr uint32_t MAX_WANT_FLAG = 4; #endif @@ -99,8 +100,8 @@ static int OpenFileByPath(const string &path, uint32_t mode) static int OpenFileByDatashare(const string &path, uint32_t flags) { - std::shared_ptr dataShareHelper = nullptr; - sptr remote = new (std::nothrow) IRemoteStub(); + shared_ptr dataShareHelper = nullptr; + sptr remote = new (nothrow) IRemoteStub(); if (!remote) { HILOGE("Failed to get remote object"); return -ENOMEM; -- Gitee