diff --git a/bundle.json b/bundle.json index 5186429d476a18c67759da7b3cda54feed498e65..878e81cbf8581f1bbafb9f132973e021aeb0ac8b 100644 --- a/bundle.json +++ b/bundle.json @@ -74,6 +74,15 @@ "header_base": "//foundation/filemanagement/app_file_service/interfaces/innerkits/native/file_share/include" } }, + { + "name": "//foundation/filemanagement/app_file_service/interfaces/innerkits/native:fileuri_native", + "header": { + "header_files": [ + "file_uri.h" + ], + "header_base": "//foundation/filemanagement/app_file_service/interfaces/innerkits/native/file_uri/include" + } + }, { "name": "//foundation/filemanagement/app_file_service/interfaces/innerkits/native:remote_file_share_native", "header": { diff --git a/interfaces/innerkits/native/BUILD.gn b/interfaces/innerkits/native/BUILD.gn index 833d8305d1c057174d87b31485740f11bfc14745..c575811e2333dfba0282fe5e7d88b56dbb049ac0 100644 --- a/interfaces/innerkits/native/BUILD.gn +++ b/interfaces/innerkits/native/BUILD.gn @@ -23,6 +23,11 @@ config("file_share_config") { ] } +config("file_uri_config") { + visibility = [ ":*" ] + include_dirs = [ "file_uri/include" ] +} + ohos_shared_library("fileshare_native") { sources = [ "../../common/src/common_func.cpp", @@ -45,6 +50,21 @@ ohos_shared_library("fileshare_native") { subsystem_name = "filemanagement" } +ohos_shared_library("fileuri_native") { + sources = [ "file_uri/src/file_uri.cpp" ] + + public_configs = [ ":file_uri_config" ] + + external_deps = [ + "ability_base:zuri", + "c_utils:utils", + "hilog:libhilog", + ] + + part_name = "app_file_service" + subsystem_name = "filemanagement" +} + ohos_prebuilt_etc("file_share_sandbox.json") { source = "../../common/file_share_sandbox.json" part_name = "app_file_service" @@ -90,6 +110,7 @@ ohos_shared_library("remote_file_share_native") { group("app_file_service_native") { deps = [ ":fileshare_native", + ":fileuri_native", ":remote_file_share_native", ] } diff --git a/interfaces/innerkits/native/file_uri/include/file_uri.h b/interfaces/innerkits/native/file_uri/include/file_uri.h new file mode 100644 index 0000000000000000000000000000000000000000..59bbc4fc63667d90e5dd7a5c0aae292881565a5a --- /dev/null +++ b/interfaces/innerkits/native/file_uri/include/file_uri.h @@ -0,0 +1,39 @@ +/* + * 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 + * + * 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 APP_FILE_SERVICE_FILE_URI_FILE_URI_H +#define APP_FILE_SERVICE_FILE_URI_FILE_URI_H + +#include + +#include "uri.h" +namespace OHOS { +namespace AppFileService { +namespace ModuleFileUri { +class FileUri { +public: + std::string GetName(); + std::string GetPath(); + std::string ToString(); + + explicit FileUri(const std::string &uriOrPath); + ~FileUri() = default; +private: + Uri uri_; +}; +} // namespace ModuleFileUri +} // namespace AppFileService +} // namespace OHOS +#endif // APP_FILE_SERVICE_FILE_URI_FILE_URI_H \ No newline at end of file diff --git a/interfaces/innerkits/native/file_uri/src/file_uri.cpp b/interfaces/innerkits/native/file_uri/src/file_uri.cpp new file mode 100644 index 0000000000000000000000000000000000000000..816bf7186d9ffb018df860b8667398aa18d873a9 --- /dev/null +++ b/interfaces/innerkits/native/file_uri/src/file_uri.cpp @@ -0,0 +1,40 @@ +/* + * 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 + * + * 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_uri.h" + +using namespace std; +namespace OHOS { +namespace AppFileService { +namespace ModuleFileUri { +string FileUri::GetName() +{ + return uri_.GetPath(); +} + +string FileUri::GetPath() +{ + return uri_.GetPath(); +} + +string FileUri::ToString() +{ + return uri_.ToString(); +} + +FileUri::FileUri(const std::string &uriOrPath) : uri_(Uri(uriOrPath)) {} +} // namespace ModuleFileUri +} // namespace AppFileService +} // namespace OHOS \ No newline at end of file