diff --git a/filemanagement/file_uri/BUILD.gn b/filemanagement/file_uri/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b2c218f77abb80bf7610d7215689d33eab480a4f --- /dev/null +++ b/filemanagement/file_uri/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2024 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("oh_file_uri_header") { + dest_dir = "$ndk_headers_out_dir/filemanagement/file_uri/" + sources = [ + "../fileio/include/error_code.h", + "./include/oh_file_uri.h", + ] +} + +ohos_ndk_library("libohfileuri") { + output_name = "ohfileuri" + output_extension = "so" + system_capability = "SystemCapability.FileManagement.AppFileService" + ndk_description_file = "./liboh_file_uri.ndk.json" + min_compact_version = "12" + system_capability_headers = [ "filemanagement/file_uri/oh_file_uri.h" ] +} diff --git a/filemanagement/file_uri/include/oh_file_uri.h b/filemanagement/file_uri/include/oh_file_uri.h new file mode 100644 index 0000000000000000000000000000000000000000..0753a56b9046cda25a1afc50de6a5da544c68411 --- /dev/null +++ b/filemanagement/file_uri/include/oh_file_uri.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2024 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_MANAGEMENT_OH_FILE_URI_H +#define FILE_MANAGEMENT_OH_FILE_URI_H + +/** + * @file oh_file_uri.h + * + * @brief uri verification and conversion + * @library libohfileuri.so + * @syscap SystemCapability.FileManagement.AppFileService + * @since 12 + */ + +#include "error_code.h" +#include "stdbool.h" +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get uri From path. + * + * @param path Input a pointer to the path string. + * @param length The length of the input path. + * @param result Output a pointer to a uri string. Please use free() to clear the resource. + * @return Returns the status code of the execution. + * @syscap SystemCapability.FileManagement.AppFileService + * @since 12 + */ +FileManagement_ErrCode OH_FileUri_GetUriFromPath(const char *path, unsigned int length, char **result); + +/** + * @brief Get path From uri. + * + * @param uri Input a pointer to the uri string. + * @param length The length of the input uri. + * @param result Output a pointer to a path string. Please use free() to clear the resource. + * @return Returns the status code of the execution. + * @syscap SystemCapability.FileManagement.AppFileService + * @since 12 + */ +FileManagement_ErrCode OH_FileUri_GetPathFromUri(const char *uri, unsigned int length, char **result); + +/** + * @brief Gets the uri of the path or directory where the uri is located. + * + * @param uri Input a pointer to the uri string. + * @param length The length of the input uri. + * @param result Output a pointer to a uri string. Please use free() to clear the resource. + * @return Returns the status code of the execution. + * @syscap SystemCapability.FileManagement.AppFileService + * @since 12 + */ +FileManagement_ErrCode OH_FileUri_GetFullDirectoryUri(const char *uri, unsigned int length, char **result); + +/** + * @brief Check that the incoming uri is valid + * + * @param uri Input a pointer to the uri string. + * @param length The length of the input uri. + * @return Returns true: Valid incoming uri, false: Invalid incoming uri. + * @syscap SystemCapability.FileManagement.AppFileService + * @since 12 + */ +bool OH_FileUri_IsValidUri(const char *uri, unsigned int length); +#ifdef __cplusplus +}; +#endif +#endif // FILE_MANAGEMENT_OH_FILE_URI_H diff --git a/filemanagement/file_uri/liboh_file_uri.ndk.json b/filemanagement/file_uri/liboh_file_uri.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..776c160a844e043392cb6a6d33d84b72bccfcac1 --- /dev/null +++ b/filemanagement/file_uri/liboh_file_uri.ndk.json @@ -0,0 +1,17 @@ +[ + { "first_introduced": "12", + "name":"OH_FileUri_GetUriFromPath" + }, + { + "first_introduced": "12", + "name":"OH_FileUri_GetPathFromUri" + }, + { + "first_introduced": "12", + "name":"OH_FileUri_GetFullDirectoryUri" + }, + { + "first_introduced": "12", + "name":"OH_FileUri_IsValidUri" + } +] \ No newline at end of file