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 3a4049c073bea66166c8056c47c04d6bed76ef08..4c386485a590824d50f21b4f1eb6230530b817d7 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 8ead99468d9e2761f1932c1410595fe6900b82aa..04a2bb1cdd48b2252b6daefcf67723bc804d5de3 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;