From 27d581930d8f594052e78950de01206137f5de0b Mon Sep 17 00:00:00 2001 From: chenkai008 Date: Wed, 15 Jun 2022 19:10:30 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0FAF=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenkai008 --- frameworks/innerkits/file_access/BUILD.gn | 4 + .../file_access/include/file_ext_proxy.h | 38 ++ .../file_access/include/file_ext_stub.h | 39 ++ .../file_access/include/file_ext_stub_impl.h | 42 ++ .../file_access/include/file_extension_info.h | 146 +++++++ .../file_access/include/ifile_ext_base.h | 46 +++ .../include/napi_common_fileaccess.h | 54 +++ .../file_access/src/file_ext_proxy.cpp | 24 ++ .../file_access/src/file_ext_stub.cpp | 53 +++ .../file_access/src/file_ext_stub_impl.cpp | 28 ++ .../src/napi_common_fileaccess.cpp | 362 ++++++++++++++++++ 11 files changed, 836 insertions(+) create mode 100644 frameworks/innerkits/file_access/include/file_ext_proxy.h create mode 100644 frameworks/innerkits/file_access/include/file_ext_stub.h create mode 100644 frameworks/innerkits/file_access/include/file_ext_stub_impl.h create mode 100644 frameworks/innerkits/file_access/include/file_extension_info.h create mode 100644 frameworks/innerkits/file_access/include/ifile_ext_base.h create mode 100644 frameworks/innerkits/file_access/include/napi_common_fileaccess.h create mode 100644 frameworks/innerkits/file_access/src/file_ext_proxy.cpp create mode 100644 frameworks/innerkits/file_access/src/file_ext_stub.cpp create mode 100644 frameworks/innerkits/file_access/src/file_ext_stub_impl.cpp create mode 100644 frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp diff --git a/frameworks/innerkits/file_access/BUILD.gn b/frameworks/innerkits/file_access/BUILD.gn index be069752..67394e91 100644 --- a/frameworks/innerkits/file_access/BUILD.gn +++ b/frameworks/innerkits/file_access/BUILD.gn @@ -51,7 +51,11 @@ ohos_shared_library("file_access_ability_kit") { sources = [ "src/file_ext_ability.cpp", + "src/file_ext_proxy.cpp", + "src/file_ext_stub_impl.cpp", + "src/file_ext_stub.cpp", "src/js_file_ext_ability.cpp", + "src/napi_common_fileaccess.cpp", ] configs = [ ":ability_config" ] public_configs = [ diff --git a/frameworks/innerkits/file_access/include/file_ext_proxy.h b/frameworks/innerkits/file_access/include/file_ext_proxy.h new file mode 100644 index 00000000..5e96325d --- /dev/null +++ b/frameworks/innerkits/file_access/include/file_ext_proxy.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FILE_EXT_PROXY_H +#define FILE_EXT_PROXY_H + +#include + +#include "file_extension_info.h" +#include "ifile_ext_base.h" + +namespace OHOS { +namespace FileAccessFwk { +class FileExtProxy : public IRemoteProxy { +public: + explicit FileExtProxy(const sptr& remote) : IRemoteProxy(remote) {} + + virtual ~FileExtProxy() {} + +private: + static inline BrokerDelegator delegator_; +}; +} // namespace FileAccessFwk +} // namespace OHOS +#endif // FILE_EXT_PROXY_H + diff --git a/frameworks/innerkits/file_access/include/file_ext_stub.h b/frameworks/innerkits/file_access/include/file_ext_stub.h new file mode 100644 index 00000000..a69bc95f --- /dev/null +++ b/frameworks/innerkits/file_access/include/file_ext_stub.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FILE_EXT_STUB_H +#define FILE_EXT_STUB_H + +#include +#include + +#include "file_extension_info.h" +#include "ifile_ext_base.h" + +namespace OHOS { +namespace FileAccessFwk { +class FileExtStub : public IRemoteStub { +public: + FileExtStub(); + ~FileExtStub(); + int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; +private: + using RequestFuncType = int (FileExtStub::*)(MessageParcel &data, MessageParcel &reply); + std::map stubFuncMap_; +}; +} // namespace FileAccessFwk +} // namespace OHOS +#endif // FILE_EXT_STUB_H + diff --git a/frameworks/innerkits/file_access/include/file_ext_stub_impl.h b/frameworks/innerkits/file_access/include/file_ext_stub_impl.h new file mode 100644 index 00000000..e5a63868 --- /dev/null +++ b/frameworks/innerkits/file_access/include/file_ext_stub_impl.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FILE_EXT_STUB_IMPL_H +#define FILE_EXT_STUB_IMPL_H + +#include +#include "file_ext_stub.h" +#include "file_extension_info.h" +#include "file_ext_ability.h" +#include "native_engine/native_value.h" + +namespace OHOS { +namespace FileAccessFwk { +class FileExtStubImpl : public FileExtStub { +public: + explicit FileExtStubImpl(const std::shared_ptr& extension, napi_env env) + : extension_(extension) {} + + virtual ~FileExtStubImpl() {} + +private: + std::shared_ptr GetOwner(); + +private: + std::shared_ptr extension_; +}; +} // namespace FileAccessFwk +} // namespace OHOS +#endif // FILE_EXT_STUB_IMPL_H diff --git a/frameworks/innerkits/file_access/include/file_extension_info.h b/frameworks/innerkits/file_access/include/file_extension_info.h new file mode 100644 index 00000000..9cd7faae --- /dev/null +++ b/frameworks/innerkits/file_access/include/file_extension_info.h @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef FILE_EXTENSION_INFO_H +#define FILE_EXTENSION_INFO_H + +#include +#include + +#include "parcel.h" +#include "uri.h" + +namespace OHOS { +namespace FileAccessFwk { +struct FileInfo : public virtual OHOS::Parcelable { +public: + Uri uri = Uri(""); + std::string fileName; + std::string mode; + int64_t size {0}; + int64_t mtime {0}; + std::string mimiType; + + bool ReadFromParcel(Parcel &parcel) + { + std::unique_ptr uriInfo(parcel.ReadParcelable()); + if (uriInfo == nullptr) { + return false; + } + uri = *uriInfo; + + fileName = parcel.ReadString(); + mode = parcel.ReadString(); + size = parcel.ReadUint64(); + mtime = parcel.ReadInt64(); + mimiType = parcel.ReadString(); + return true; + } + virtual bool Marshalling(Parcel &parcel) const override + { + if (!parcel.WriteParcelable(&uri)) { + return false; + } + if (!parcel.WriteString(fileName)) { + return false; + } + if (!parcel.WriteString(mode)) { + return false; + } + if (!parcel.WriteUint64(size)) { + return false; + } + if (!parcel.WriteInt64(mtime)) { + return false; + } + if (!parcel.WriteString(mimiType)) { + return false; + } + return true; + } + static FileInfo *Unmarshalling(Parcel &parcel) + { + FileInfo *info = new (std::nothrow) FileInfo(); + if (info == nullptr) { + return nullptr; + } + + if (!info->ReadFromParcel(parcel)) { + delete info; + info = nullptr; + } + return info; + } +}; + +struct DeviceInfo : public virtual OHOS::Parcelable { +public: + Uri uri = Uri(""); + std::string displayName; + std::string deviceId; + uint32_t flags {0}; + + bool ReadFromParcel(Parcel &parcel) + { + std::unique_ptr uriInfo(parcel.ReadParcelable()); + if (uriInfo == nullptr) { + return false; + } + uri = *uriInfo; + + displayName = parcel.ReadString(); + deviceId = parcel.ReadString(); + flags = parcel.ReadUint32(); + return true; + } + virtual bool Marshalling(Parcel &parcel) const override + { + if (!parcel.WriteParcelable(&uri)) { + return false; + } + if (!parcel.WriteString(displayName)) { + return false; + } + if (!parcel.WriteString(deviceId)) { + return false; + } + if (!parcel.WriteUint32(flags)) { + return false; + } + return true; + } + static DeviceInfo *Unmarshalling(Parcel &parcel) + { + DeviceInfo *info = new (std::nothrow) DeviceInfo(); + if (info == nullptr) { + return nullptr; + } + + if (!info->ReadFromParcel(parcel)) { + delete info; + info = nullptr; + } + return info; + } +}; + +const uint32_t FLAG_SUPPORTS_THUMBNAIL = 1; +const uint32_t FLAG_SUPPORTS_WRITE = 1 << 1; +const uint32_t FLAG_SUPPORTS_READ = 1 << 2; +const uint32_t FLAG_SUPPORTS_DELETE = 1 << 3; +const uint32_t FLAG_SUPPORTS_RENAME = 1 << 4; +const uint32_t FLAG_SUPPORTS_MOVE = 1 << 5; +} // namespace FileAccessFwk +} // namespace OHOS +#endif // FILE_EXTENSION_INFO_H \ No newline at end of file diff --git a/frameworks/innerkits/file_access/include/ifile_ext_base.h b/frameworks/innerkits/file_access/include/ifile_ext_base.h new file mode 100644 index 00000000..677eef91 --- /dev/null +++ b/frameworks/innerkits/file_access/include/ifile_ext_base.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef I_FILE_EXT_BASE_H +#define I_FILE_EXT_BASE_H + +#include +#include +#include + +#include "file_extension_info.h" +#include "uri.h" + +namespace OHOS { +namespace FileAccessFwk { +class IFileExtBase : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.AppExecFwk.IFileExtBase"); + + enum { + CMD_OPEN_FILE = 1, + CMD_CLOSE_FILE = 2, + CMD_CREATE_FILE = 3, + CMD_MKDIR = 4, + CMD_DELETE = 5, + CMD_MOVE = 6, + CMD_RENAME = 7, + CMD_LIST_FILE = 8, + CMD_GET_ROOTS = 9 + }; +}; +} // namespace FileAccessFwk +} // namespace OHOS +#endif // I_FILE_EXT_BASE_H diff --git a/frameworks/innerkits/file_access/include/napi_common_fileaccess.h b/frameworks/innerkits/file_access/include/napi_common_fileaccess.h new file mode 100644 index 00000000..9ac9d64e --- /dev/null +++ b/frameworks/innerkits/file_access/include/napi_common_fileaccess.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NAPI_COMMON_FILE_ACCESS_H +#define NAPI_COMMON_FILE_ACCESS_H + +#include +#include +#include + +#include "file_extension_info.h" +#include "napi_common_data.h" +#include "napi_common_util.h" + +namespace OHOS { +namespace FileAccessFwk { +bool UnwrapInt64ByPropertyName(napi_env env, napi_value param, const char *propertyName, int64_t &value); + +napi_value WrapUint32ToJS(napi_env env, uint32_t value); +uint32_t UnwrapUint32FromJS(napi_env env, napi_value param, uint32_t defaultValue = 0); +bool UnwrapUint32FromJS2(napi_env env, napi_value param, uint32_t &value); +bool UnwrapUint32ByPropertyName(napi_env env, napi_value param, const char *propertyName, uint32_t &value); + +napi_value WrapBigIntUint64ToJS(napi_env env, uint64_t value); +uint64_t UnwrapBigIntUint64FromJS(napi_env env, napi_value param, uint64_t defaultValue = 0); +bool UnwrapBigIntUint64FromJS2(napi_env env, napi_value param, uint64_t &defaultValue); +bool UnwrapBigIntUint64ByPropertyName(napi_env env, napi_value param, const char *propertyName, uint64_t &value); + +napi_value WrapFileInfo(napi_env env, const FileInfo &fileInfo); +bool UnwrapFileInfo(napi_env env, napi_value param, FileInfo &fileInfo); + +napi_value WrapArrayFileInfoToJS(napi_env env, const std::vector &fileInfoVec); +bool UnwrapArrayFileInfoFromJS(napi_env env, napi_value param, std::vector &fileInfoVec); + +napi_value WrapDeviceInfo(napi_env env, const DeviceInfo &deviceInfo); +bool UnwrapDeviceInfo(napi_env env, napi_value param, DeviceInfo &deviceInfo); + +napi_value WrapArrayDeviceInfoToJS(napi_env env, const std::vector &deviceInfoVec); +bool UnwrapArrayDeviceInfoFromJS(napi_env env, napi_value param, std::vector &deviceInfoVec); +} // namespace FileAccessFwk +} // namespace OHOS +#endif // NAPI_COMMON_FILE_ACCESS_H diff --git a/frameworks/innerkits/file_access/src/file_ext_proxy.cpp b/frameworks/innerkits/file_access/src/file_ext_proxy.cpp new file mode 100644 index 00000000..f55184d2 --- /dev/null +++ b/frameworks/innerkits/file_access/src/file_ext_proxy.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "file_ext_proxy.h" + +#include "hilog_wrapper.h" + +namespace OHOS { +namespace FileAccessFwk { + +} // namespace FileAccessFwk +} // namespace OHOS diff --git a/frameworks/innerkits/file_access/src/file_ext_stub.cpp b/frameworks/innerkits/file_access/src/file_ext_stub.cpp new file mode 100644 index 00000000..55febce9 --- /dev/null +++ b/frameworks/innerkits/file_access/src/file_ext_stub.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "file_ext_stub.h" + +#include "hilog_wrapper.h" + +namespace OHOS { +namespace FileAccessFwk { +FileExtStub::FileExtStub() +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); +} + +FileExtStub::~FileExtStub() +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + stubFuncMap_.clear(); +} + +int FileExtStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, + MessageOption& option) +{ + HILOG_INFO("tag dsa %{public}s Received stub message: %{public}d", __func__, code); + std::u16string descriptor = FileExtStub::GetDescriptor(); + std::u16string remoteDescriptor = data.ReadInterfaceToken(); + if (descriptor != remoteDescriptor) { + HILOG_INFO("tag dsa local descriptor is not equal to remote"); + return ERR_INVALID_STATE; + } + + const auto &itFunc = stubFuncMap_.find(code); + if (itFunc != stubFuncMap_.end()) { + return (this->*(itFunc->second))(data, reply); + } + + HILOG_INFO("tag dsa %{public}s remote request unhandled: %{public}d", __func__, code); + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); +} +} // namespace FileAccessFwk +} // namespace OHOS diff --git a/frameworks/innerkits/file_access/src/file_ext_stub_impl.cpp b/frameworks/innerkits/file_access/src/file_ext_stub_impl.cpp new file mode 100644 index 00000000..1b4f66c0 --- /dev/null +++ b/frameworks/innerkits/file_access/src/file_ext_stub_impl.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "file_ext_stub_impl.h" + +#include "hilog_wrapper.h" + +namespace OHOS { +namespace FileAccessFwk { +std::shared_ptr FileExtStubImpl::GetOwner() +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + return extension_; +} +} // namespace FileAccessFwk +} // namespace OHOS diff --git a/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp b/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp new file mode 100644 index 00000000..3f04a84c --- /dev/null +++ b/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp @@ -0,0 +1,362 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hilog_wrapper.h" +#include "napi_common_fileaccess.h" + +namespace OHOS { +namespace FileAccessFwk { +using namespace OHOS::AppExecFwk; +bool UnwrapInt64ByPropertyName(napi_env env, napi_value param, const char *propertyName, int64_t &value) +{ + napi_value jsValue = GetPropertyValueByPropertyName(env, param, propertyName, napi_number); + if (jsValue != nullptr) { + return UnwrapInt64FromJS2(env, jsValue, value); + } else { + return false; + } +} + +napi_value WrapUint32ToJS(napi_env env, uint32_t value) +{ + napi_value result = nullptr; + NAPI_CALL(env, napi_create_uint32(env, value, &result)); + return result; +} + +uint32_t UnwrapUint32FromJS(napi_env env, napi_value param, uint32_t defaultValue) +{ + uint32_t value = defaultValue; + if (napi_get_value_uint32(env, param, &value) == napi_ok) { + return value; + } else { + return defaultValue; + } +} + +bool UnwrapUint32FromJS2(napi_env env, napi_value param, uint32_t &value) +{ + HILOG_INFO("tag dsa %{public}s,called begin", __func__); + bool result = false; + if (napi_get_value_uint32(env, param, &value) == napi_ok) { + result = true; + } + HILOG_INFO("tag dsa %{public}s,called end, value: %{public}u", __func__, value); + return result; +} + +bool UnwrapUint32ByPropertyName(napi_env env, napi_value param, const char *propertyName, uint32_t &value) +{ + HILOG_INFO("tag dsa %{public}s,called begin", __func__); + napi_value jsValue = GetPropertyValueByPropertyName(env, param, propertyName, napi_number); + if (jsValue != nullptr) { + HILOG_INFO("tag dsa %{public}s,called end.", __func__); + return UnwrapUint32FromJS2(env, jsValue, value); + } else { + HILOG_INFO("tag dsa %{public}s,called faild.", __func__); + return false; + } +} + +napi_value WrapBigIntUint64ToJS(napi_env env, uint64_t value) +{ + napi_value result = nullptr; + NAPI_CALL(env, napi_create_bigint_uint64(env, value, &result)); + return result; +} + +uint64_t UnwrapBigIntUint64FromJS(napi_env env, napi_value param, uint64_t defaultValue) +{ + HILOG_INFO("tag dsa %{public}s,called begin", __func__); + bool lossless = true; + uint64_t value = defaultValue; + if (napi_get_value_bigint_uint64(env, param, &value, &lossless) == napi_ok) { + HILOG_INFO("tag dsa %{public}s,called value: %{public}llu.", __func__, defaultValue); + return value; + } else { + HILOG_INFO("tag dsa %{public}s,called end with faild.", __func__); + return defaultValue; + } +} + +bool UnwrapBigIntUint64FromJS2(napi_env env, napi_value param, uint64_t &defaultValue) +{ + HILOG_INFO("tag dsa %{public}s,called begin", __func__); + bool lossless = true; + if (napi_get_value_bigint_uint64(env, param, &defaultValue, &lossless) == napi_ok) { + HILOG_INFO("tag dsa %{public}s,called value: %{public}llu.", __func__, defaultValue); + return true; + } else { + HILOG_INFO("tag dsa %{public}s,called end with faild.", __func__); + return false; + } +} + +bool UnwrapBigIntUint64ByPropertyName(napi_env env, napi_value param, const char *propertyName, uint64_t &value) +{ + HILOG_INFO("tag dsa %{public}s,called begin", __func__); + napi_value jsValue = GetPropertyValueByPropertyName(env, param, propertyName, napi_bigint); + if (jsValue != nullptr) { + HILOG_INFO("tag dsa %{public}s,called end.", __func__); + return UnwrapBigIntUint64FromJS2(env, jsValue, value); + } else { + HILOG_INFO("tag dsa %{public}s,called faild.", __func__); + return false; + } +} + +napi_value WrapFileInfo(napi_env env, const FileInfo &fileInfo) +{ + HILOG_INFO("tag dsa %{public}s,called begin", __func__); + HILOG_INFO("tag dsa %{public}s,uri: %{public}s", __func__, fileInfo.uri.ToString().c_str()); + HILOG_INFO("tag dsa %{public}s,fileName: %{public}s", __func__, fileInfo.fileName.c_str()); + HILOG_INFO("tag dsa %{public}s,mode: %{public}s", __func__, fileInfo.mode.c_str()); + HILOG_INFO("tag dsa %{public}s,size: %{public}lld", __func__, fileInfo.size); + HILOG_INFO("tag dsa %{public}s,mtime: %{public}lld", __func__, fileInfo.mtime); + HILOG_INFO("tag dsa %{public}s,mimiType: %{public}s", __func__, fileInfo.mimiType.c_str()); + napi_value jsObject = nullptr; + napi_value jsValue = nullptr; + + NAPI_CALL(env, napi_create_object(env, &jsObject)); + + jsValue = nullptr; + jsValue = OHOS::AppExecFwk::WrapStringToJS(env, fileInfo.uri.ToString()); + SetPropertyValueByPropertyName(env, jsObject, "uri", jsValue); + + jsValue = nullptr; + jsValue = OHOS::AppExecFwk::WrapStringToJS(env, fileInfo.fileName); + SetPropertyValueByPropertyName(env, jsObject, "fileName", jsValue); + + jsValue = nullptr; + jsValue = OHOS::AppExecFwk::WrapStringToJS(env, fileInfo.mode); + SetPropertyValueByPropertyName(env, jsObject, "mode", jsValue); + + jsValue = nullptr; + jsValue = OHOS::AppExecFwk::WrapInt64ToJS(env, fileInfo.size); + SetPropertyValueByPropertyName(env, jsObject, "size", jsValue); + + jsValue = nullptr; + jsValue = OHOS::AppExecFwk::WrapInt64ToJS(env, fileInfo.mtime); + SetPropertyValueByPropertyName(env, jsObject, "mtime", jsValue); + + jsValue = nullptr; + jsValue = OHOS::AppExecFwk::WrapStringToJS(env, fileInfo.mimiType); + SetPropertyValueByPropertyName(env, jsObject, "mimiType", jsValue); + + HILOG_INFO("tag dsa %{public}s,called end", __func__); + return jsObject; +} + +bool UnwrapFileInfo(napi_env env, napi_value param, FileInfo &fileInfo) +{ + HILOG_INFO("tag dsa %{public}s,called begin", __func__); + if (!IsTypeForNapiValue(env, param, napi_object)) { + HILOG_INFO("%{public}s called. Params is invalid.", __func__); + return false; + } + + std::string natValueString(""); + if (OHOS::AppExecFwk::UnwrapStringByPropertyName(env, param, "uri", natValueString)) { + fileInfo.uri = Uri(natValueString); + } + + natValueString = ""; + if (OHOS::AppExecFwk::UnwrapStringByPropertyName(env, param, "fileName", natValueString)) { + fileInfo.fileName = natValueString; + } + + natValueString = ""; + if (OHOS::AppExecFwk::UnwrapStringByPropertyName(env, param, "mode", natValueString)) { + fileInfo.mode = natValueString; + } + + int64_t natValueInt64 = 0; + if (UnwrapInt64ByPropertyName(env, param, "size", natValueInt64)) { + fileInfo.size = natValueInt64; + } + + natValueInt64 = 0; + if (UnwrapInt64ByPropertyName(env, param, "mtime", natValueInt64)) { + fileInfo.mtime = natValueInt64; + } + + natValueString = ""; + if (OHOS::AppExecFwk::UnwrapStringByPropertyName(env, param, "mimiType", natValueString)) { + fileInfo.mimiType = natValueString; + } + + HILOG_INFO("tag dsa %{public}s,uri: %{public}s", __func__, fileInfo.uri.ToString().c_str()); + HILOG_INFO("tag dsa %{public}s,fileName: %{public}s", __func__, fileInfo.fileName.c_str()); + HILOG_INFO("tag dsa %{public}s,mode: %{public}s", __func__, fileInfo.mode.c_str()); + HILOG_INFO("tag dsa %{public}s,size: %{public}lld", __func__, fileInfo.size); + HILOG_INFO("tag dsa %{public}s,mtime: %{public}lld", __func__, fileInfo.mtime); + HILOG_INFO("tag dsa %{public}s,mimiType: %{public}s", __func__, fileInfo.mimiType.c_str()); + HILOG_INFO("tag dsa %{public}s,end", __func__); + return true; +} + +napi_value WrapArrayFileInfoToJS(napi_env env, const std::vector &fileInfoVec) +{ + napi_value jsArray = nullptr; + napi_value jsValue = nullptr; + uint32_t index = 0; + + NAPI_CALL(env, napi_create_array(env, &jsArray)); + for (uint32_t i = 0; i < fileInfoVec.size(); i++) { + jsValue = WrapFileInfo(env, fileInfoVec[i]); + if (napi_set_element(env, jsArray, index, jsValue) == napi_ok) { + index++; + } + } + return jsArray; +} + +bool UnwrapArrayFileInfoFromJS(napi_env env, napi_value param, std::vector &fileInfoVec) +{ + uint32_t arraySize = 0; + napi_value jsValue = nullptr; + + if (!IsArrayForNapiValue(env, param, arraySize)) { + return false; + } + + fileInfoVec.clear(); + for (uint32_t i = 0; i < arraySize; i++) { + jsValue = nullptr; + FileInfo fileInfo; + if (napi_get_element(env, param, i, &jsValue) != napi_ok) { + return false; + } + + if (!UnwrapFileInfo(env, jsValue, fileInfo)) { + return false; + } + + fileInfoVec.push_back(fileInfo); + } + return true; +} + +napi_value WrapDeviceInfo(napi_env env, const DeviceInfo &deviceInfo) +{ + HILOG_INFO("tag dsa %{public}s,called begin", __func__); + HILOG_INFO("tag dsa %{public}s,uri: %{public}s", __func__, deviceInfo.uri.ToString().c_str()); + HILOG_INFO("tag dsa %{public}s,displayName: %{public}s", __func__, deviceInfo.displayName.c_str()); + HILOG_INFO("tag dsa %{public}s,deviceId: %{public}s", __func__, deviceInfo.deviceId.c_str()); + HILOG_INFO("tag dsa %{public}s,flags: %{public}u", __func__, deviceInfo.flags); + napi_value jsObject = nullptr; + napi_value jsValue = nullptr; + + NAPI_CALL(env, napi_create_object(env, &jsObject)); + + jsValue = nullptr; + jsValue = OHOS::AppExecFwk::WrapStringToJS(env, deviceInfo.uri.ToString()); + SetPropertyValueByPropertyName(env, jsObject, "uri", jsValue); + + jsValue = nullptr; + jsValue = OHOS::AppExecFwk::WrapStringToJS(env, deviceInfo.displayName); + SetPropertyValueByPropertyName(env, jsObject, "displayName", jsValue); + + jsValue = nullptr; + jsValue = OHOS::AppExecFwk::WrapStringToJS(env, deviceInfo.deviceId); + SetPropertyValueByPropertyName(env, jsObject, "deviceId", jsValue); + + jsValue = nullptr; + jsValue = WrapUint32ToJS(env, deviceInfo.flags); + SetPropertyValueByPropertyName(env, jsObject, "flags", jsValue); + + HILOG_INFO("tag dsa %{public}s,called end", __func__); + return jsObject; +} + +bool UnwrapDeviceInfo(napi_env env, napi_value param, DeviceInfo &deviceInfo) +{ + HILOG_INFO("tag dsa %{public}s,called begin", __func__); + if (!IsTypeForNapiValue(env, param, napi_object)) { + HILOG_INFO("%{public}s called. Params is invalid.", __func__); + return false; + } + + std::string natValueString(""); + if (OHOS::AppExecFwk::UnwrapStringByPropertyName(env, param, "uri", natValueString)) { + deviceInfo.uri = Uri(natValueString); + } + + natValueString = ""; + if (OHOS::AppExecFwk::UnwrapStringByPropertyName(env, param, "displayName", natValueString)) { + deviceInfo.displayName = natValueString; + } + + natValueString = ""; + if (OHOS::AppExecFwk::UnwrapStringByPropertyName(env, param, "deviceId", natValueString)) { + deviceInfo.deviceId = natValueString; + } + + uint32_t natValueUint32 = 0; + if (UnwrapUint32ByPropertyName(env, param, "flags", natValueUint32)) { + HILOG_INFO("tag dsa %{public}s,flags: %{public}zu", __func__, natValueUint32); + deviceInfo.flags = natValueUint32; + } + HILOG_INFO("tag dsa %{public}s,uri: %{public}s", __func__, deviceInfo.uri.ToString().c_str()); + HILOG_INFO("tag dsa %{public}s,displayName: %{public}s", __func__, deviceInfo.displayName.c_str()); + HILOG_INFO("tag dsa %{public}s,deviceId: %{public}s", __func__, deviceInfo.deviceId.c_str()); + HILOG_INFO("tag dsa %{public}s,flags: %{public}u", __func__, deviceInfo.flags); + HILOG_INFO("tag dsa %{public}s,end", __func__); + return true; +} + +napi_value WrapArrayDeviceInfoToJS(napi_env env, const std::vector &deviceInfoVec) +{ + napi_value jsArray = nullptr; + napi_value jsValue = nullptr; + uint32_t index = 0; + + NAPI_CALL(env, napi_create_array(env, &jsArray)); + for (uint32_t i = 0; i < deviceInfoVec.size(); i++) { + jsValue = WrapDeviceInfo(env, deviceInfoVec[i]); + if (napi_set_element(env, jsArray, index, jsValue) == napi_ok) { + index++; + } + } + return jsArray; +} + +bool UnwrapArrayDeviceInfoFromJS(napi_env env, napi_value param, std::vector &deviceInfoVec) +{ + uint32_t arraySize = 0; + napi_value jsValue = nullptr; + + if (!IsArrayForNapiValue(env, param, arraySize)) { + return false; + } + + deviceInfoVec.clear(); + for (uint32_t i = 0; i < arraySize; i++) { + jsValue = nullptr; + DeviceInfo deviceInfo; + if (napi_get_element(env, param, i, &jsValue) != napi_ok) { + return false; + } + + if (!UnwrapDeviceInfo(env, jsValue, deviceInfo)) { + return false; + } + + deviceInfoVec.push_back(deviceInfo); + } + return true; +} +} // namespace FileAccessFwk +} // namespace OHOS -- Gitee From b9167f163350d2090e9b32b48c72a13776ead094 Mon Sep 17 00:00:00 2001 From: chenkai008 Date: Wed, 15 Jun 2022 19:17:47 +0800 Subject: [PATCH 2/4] delete space line Signed-off-by: chenkai008 --- frameworks/innerkits/file_access/src/file_ext_proxy.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/innerkits/file_access/src/file_ext_proxy.cpp b/frameworks/innerkits/file_access/src/file_ext_proxy.cpp index f55184d2..aa411716 100644 --- a/frameworks/innerkits/file_access/src/file_ext_proxy.cpp +++ b/frameworks/innerkits/file_access/src/file_ext_proxy.cpp @@ -19,6 +19,5 @@ namespace OHOS { namespace FileAccessFwk { - } // namespace FileAccessFwk } // namespace OHOS -- Gitee From cb4c6563bfd97e11731d80a74b0ac910e6640f5a Mon Sep 17 00:00:00 2001 From: chenkai008 Date: Thu, 16 Jun 2022 14:19:53 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenkai008 --- .../file_access/include/ifile_ext_base.h | 12 --- .../file_access/src/file_ext_stub.cpp | 12 +-- .../file_access/src/file_ext_stub_impl.cpp | 3 +- .../src/napi_common_fileaccess.cpp | 84 +++++++++---------- 4 files changed, 51 insertions(+), 60 deletions(-) diff --git a/frameworks/innerkits/file_access/include/ifile_ext_base.h b/frameworks/innerkits/file_access/include/ifile_ext_base.h index 677eef91..5f7a2c22 100644 --- a/frameworks/innerkits/file_access/include/ifile_ext_base.h +++ b/frameworks/innerkits/file_access/include/ifile_ext_base.h @@ -28,18 +28,6 @@ namespace FileAccessFwk { class IFileExtBase : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.AppExecFwk.IFileExtBase"); - - enum { - CMD_OPEN_FILE = 1, - CMD_CLOSE_FILE = 2, - CMD_CREATE_FILE = 3, - CMD_MKDIR = 4, - CMD_DELETE = 5, - CMD_MOVE = 6, - CMD_RENAME = 7, - CMD_LIST_FILE = 8, - CMD_GET_ROOTS = 9 - }; }; } // namespace FileAccessFwk } // namespace OHOS diff --git a/frameworks/innerkits/file_access/src/file_ext_stub.cpp b/frameworks/innerkits/file_access/src/file_ext_stub.cpp index 55febce9..6dffcb94 100644 --- a/frameworks/innerkits/file_access/src/file_ext_stub.cpp +++ b/frameworks/innerkits/file_access/src/file_ext_stub.cpp @@ -21,23 +21,25 @@ namespace OHOS { namespace FileAccessFwk { FileExtStub::FileExtStub() { - HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("%{public}s begin.", __func__); + HILOG_INFO("%{public}s end.", __func__); } FileExtStub::~FileExtStub() { - HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("%{public}s begin.", __func__); + HILOG_INFO("%{public}s end.", __func__); stubFuncMap_.clear(); } int FileExtStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { - HILOG_INFO("tag dsa %{public}s Received stub message: %{public}d", __func__, code); + HILOG_INFO("%{public}s Received stub message: %{public}d", __func__, code); std::u16string descriptor = FileExtStub::GetDescriptor(); std::u16string remoteDescriptor = data.ReadInterfaceToken(); if (descriptor != remoteDescriptor) { - HILOG_INFO("tag dsa local descriptor is not equal to remote"); + HILOG_INFO("%{public}s local descriptor is not equal to remote", __func__); return ERR_INVALID_STATE; } @@ -46,7 +48,7 @@ int FileExtStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParc return (this->*(itFunc->second))(data, reply); } - HILOG_INFO("tag dsa %{public}s remote request unhandled: %{public}d", __func__, code); + HILOG_INFO("%{public}s remote request unhandled: %{public}d", __func__, code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } } // namespace FileAccessFwk diff --git a/frameworks/innerkits/file_access/src/file_ext_stub_impl.cpp b/frameworks/innerkits/file_access/src/file_ext_stub_impl.cpp index 1b4f66c0..50a76fd2 100644 --- a/frameworks/innerkits/file_access/src/file_ext_stub_impl.cpp +++ b/frameworks/innerkits/file_access/src/file_ext_stub_impl.cpp @@ -21,7 +21,8 @@ namespace OHOS { namespace FileAccessFwk { std::shared_ptr FileExtStubImpl::GetOwner() { - HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("%{public}s begin.", __func__); + HILOG_INFO("%{public}s end.", __func__); return extension_; } } // namespace FileAccessFwk diff --git a/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp b/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp index 3f04a84c..3486d489 100644 --- a/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp +++ b/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp @@ -48,24 +48,24 @@ uint32_t UnwrapUint32FromJS(napi_env env, napi_value param, uint32_t defaultValu bool UnwrapUint32FromJS2(napi_env env, napi_value param, uint32_t &value) { - HILOG_INFO("tag dsa %{public}s,called begin", __func__); + HILOG_INFO("%{public}s,called begin", __func__); bool result = false; if (napi_get_value_uint32(env, param, &value) == napi_ok) { result = true; } - HILOG_INFO("tag dsa %{public}s,called end, value: %{public}u", __func__, value); + HILOG_INFO("%{public}s,called end, value: %{public}u", __func__, value); return result; } bool UnwrapUint32ByPropertyName(napi_env env, napi_value param, const char *propertyName, uint32_t &value) { - HILOG_INFO("tag dsa %{public}s,called begin", __func__); + HILOG_INFO("%{public}s,called begin", __func__); napi_value jsValue = GetPropertyValueByPropertyName(env, param, propertyName, napi_number); if (jsValue != nullptr) { - HILOG_INFO("tag dsa %{public}s,called end.", __func__); + HILOG_INFO("%{public}s,called end.", __func__); return UnwrapUint32FromJS2(env, jsValue, value); } else { - HILOG_INFO("tag dsa %{public}s,called faild.", __func__); + HILOG_INFO("%{public}s,called faild.", __func__); return false; } } @@ -79,53 +79,53 @@ napi_value WrapBigIntUint64ToJS(napi_env env, uint64_t value) uint64_t UnwrapBigIntUint64FromJS(napi_env env, napi_value param, uint64_t defaultValue) { - HILOG_INFO("tag dsa %{public}s,called begin", __func__); + HILOG_INFO("%{public}s,called begin", __func__); bool lossless = true; uint64_t value = defaultValue; if (napi_get_value_bigint_uint64(env, param, &value, &lossless) == napi_ok) { - HILOG_INFO("tag dsa %{public}s,called value: %{public}llu.", __func__, defaultValue); + HILOG_INFO("%{public}s,called value: %{public}llu.", __func__, defaultValue); return value; } else { - HILOG_INFO("tag dsa %{public}s,called end with faild.", __func__); + HILOG_INFO("%{public}s,called end with faild.", __func__); return defaultValue; } } bool UnwrapBigIntUint64FromJS2(napi_env env, napi_value param, uint64_t &defaultValue) { - HILOG_INFO("tag dsa %{public}s,called begin", __func__); + HILOG_INFO("%{public}s,called begin", __func__); bool lossless = true; if (napi_get_value_bigint_uint64(env, param, &defaultValue, &lossless) == napi_ok) { - HILOG_INFO("tag dsa %{public}s,called value: %{public}llu.", __func__, defaultValue); + HILOG_INFO("%{public}s,called value: %{public}llu.", __func__, defaultValue); return true; } else { - HILOG_INFO("tag dsa %{public}s,called end with faild.", __func__); + HILOG_INFO("%{public}s,called end with faild.", __func__); return false; } } bool UnwrapBigIntUint64ByPropertyName(napi_env env, napi_value param, const char *propertyName, uint64_t &value) { - HILOG_INFO("tag dsa %{public}s,called begin", __func__); + HILOG_INFO("%{public}s,called begin", __func__); napi_value jsValue = GetPropertyValueByPropertyName(env, param, propertyName, napi_bigint); if (jsValue != nullptr) { - HILOG_INFO("tag dsa %{public}s,called end.", __func__); + HILOG_INFO("%{public}s,called end.", __func__); return UnwrapBigIntUint64FromJS2(env, jsValue, value); } else { - HILOG_INFO("tag dsa %{public}s,called faild.", __func__); + HILOG_INFO("%{public}s,called faild.", __func__); return false; } } napi_value WrapFileInfo(napi_env env, const FileInfo &fileInfo) { - HILOG_INFO("tag dsa %{public}s,called begin", __func__); - HILOG_INFO("tag dsa %{public}s,uri: %{public}s", __func__, fileInfo.uri.ToString().c_str()); - HILOG_INFO("tag dsa %{public}s,fileName: %{public}s", __func__, fileInfo.fileName.c_str()); - HILOG_INFO("tag dsa %{public}s,mode: %{public}s", __func__, fileInfo.mode.c_str()); - HILOG_INFO("tag dsa %{public}s,size: %{public}lld", __func__, fileInfo.size); - HILOG_INFO("tag dsa %{public}s,mtime: %{public}lld", __func__, fileInfo.mtime); - HILOG_INFO("tag dsa %{public}s,mimiType: %{public}s", __func__, fileInfo.mimiType.c_str()); + HILOG_INFO("%{public}s,called begin", __func__); + HILOG_INFO("%{public}s,uri: %{public}s", __func__, fileInfo.uri.ToString().c_str()); + HILOG_INFO("%{public}s,fileName: %{public}s", __func__, fileInfo.fileName.c_str()); + HILOG_INFO("%{public}s,mode: %{public}s", __func__, fileInfo.mode.c_str()); + HILOG_INFO("%{public}s,size: %{public}lld", __func__, fileInfo.size); + HILOG_INFO("%{public}s,mtime: %{public}lld", __func__, fileInfo.mtime); + HILOG_INFO("%{public}s,mimiType: %{public}s", __func__, fileInfo.mimiType.c_str()); napi_value jsObject = nullptr; napi_value jsValue = nullptr; @@ -155,13 +155,13 @@ napi_value WrapFileInfo(napi_env env, const FileInfo &fileInfo) jsValue = OHOS::AppExecFwk::WrapStringToJS(env, fileInfo.mimiType); SetPropertyValueByPropertyName(env, jsObject, "mimiType", jsValue); - HILOG_INFO("tag dsa %{public}s,called end", __func__); + HILOG_INFO("%{public}s,called end", __func__); return jsObject; } bool UnwrapFileInfo(napi_env env, napi_value param, FileInfo &fileInfo) { - HILOG_INFO("tag dsa %{public}s,called begin", __func__); + HILOG_INFO("%{public}s,called begin", __func__); if (!IsTypeForNapiValue(env, param, napi_object)) { HILOG_INFO("%{public}s called. Params is invalid.", __func__); return false; @@ -197,13 +197,13 @@ bool UnwrapFileInfo(napi_env env, napi_value param, FileInfo &fileInfo) fileInfo.mimiType = natValueString; } - HILOG_INFO("tag dsa %{public}s,uri: %{public}s", __func__, fileInfo.uri.ToString().c_str()); - HILOG_INFO("tag dsa %{public}s,fileName: %{public}s", __func__, fileInfo.fileName.c_str()); - HILOG_INFO("tag dsa %{public}s,mode: %{public}s", __func__, fileInfo.mode.c_str()); - HILOG_INFO("tag dsa %{public}s,size: %{public}lld", __func__, fileInfo.size); - HILOG_INFO("tag dsa %{public}s,mtime: %{public}lld", __func__, fileInfo.mtime); - HILOG_INFO("tag dsa %{public}s,mimiType: %{public}s", __func__, fileInfo.mimiType.c_str()); - HILOG_INFO("tag dsa %{public}s,end", __func__); + HILOG_INFO("%{public}s,uri: %{public}s", __func__, fileInfo.uri.ToString().c_str()); + HILOG_INFO("%{public}s,fileName: %{public}s", __func__, fileInfo.fileName.c_str()); + HILOG_INFO("%{public}s,mode: %{public}s", __func__, fileInfo.mode.c_str()); + HILOG_INFO("%{public}s,size: %{public}lld", __func__, fileInfo.size); + HILOG_INFO("%{public}s,mtime: %{public}lld", __func__, fileInfo.mtime); + HILOG_INFO("%{public}s,mimiType: %{public}s", __func__, fileInfo.mimiType.c_str()); + HILOG_INFO("%{public}s,end", __func__); return true; } @@ -251,11 +251,11 @@ bool UnwrapArrayFileInfoFromJS(napi_env env, napi_value param, std::vector Date: Thu, 16 Jun 2022 14:52:11 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenkai008 --- frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp b/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp index 3486d489..3714a061 100644 --- a/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp +++ b/frameworks/innerkits/file_access/src/napi_common_fileaccess.cpp @@ -306,7 +306,7 @@ bool UnwrapDeviceInfo(napi_env env, napi_value param, DeviceInfo &deviceInfo) uint32_t natValueUint32 = 0; if (UnwrapUint32ByPropertyName(env, param, "flags", natValueUint32)) { - HILOG_INFO("tag dsa %{public}s,flags: %{public}zu", __func__, natValueUint32); + HILOG_INFO("%{public}s,flags: %{public}zu", __func__, natValueUint32); deviceInfo.flags = natValueUint32; } HILOG_INFO("%{public}s,uri: %{public}s", __func__, deviceInfo.uri.ToString().c_str()); -- Gitee