ndk_add_environment

Signed-off-by: 18721213663 <zhuhongtao12@huawei.com>
This commit is contained in:
18721213663 2024-02-05 10:35:20 +08:00
parent cf26a90a20
commit 2e0807baee
8 changed files with 289 additions and 109 deletions

View File

@ -14,17 +14,20 @@
import("//build/ohos.gni")
import("//build/ohos/ndk/ndk.gni")
ohos_ndk_library("libenvironment_ndk") {
ohos_ndk_library("libohenvironment") {
ndk_description_file = "./libenvironment.ndk.json"
min_compact_version = "12"
output_name = "environment"
output_name = "ohenvironment"
output_extension = "so"
system_capability =
"SystemCapability.FileManagement.File.Environment.FolderObtain"
system_capability_headers = [ "filemanagement/environment/oh_environment.h" ]
}
ohos_ndk_headers("environment_header") {
dest_dir = "$ndk_headers_out_dir/environment/"
sources = [ "./include/environment.h" ]
system_capability = "SystemCapability.FileManagement.File.Environment.FolderObtain"
system_capability_headers = [
"environment/environment.h",
ohos_ndk_headers("oh_environment_header") {
dest_dir = "$ndk_headers_out_dir/filemanagement/environment/"
sources = [
"../fileio/include/error_code.h",
"./include/oh_environment.h",
]
}
}

View File

@ -1,96 +0,0 @@
/*
* 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 ENVIRONMENT_H
#define ENVIRONMENT_H_H
/**
* @addtogroup environment
*
* @brief This module provides the ability to access the environment directory and obtain the native interface
for public root directory.
* @since 12
*/
/**
* @file environment.h
*
* @brief Provides environment APIS.
* @library libenvironment_ndk.z.so
* @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
* @since 12
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enumerates the file location.
*
* @since 12
*/
typedef enum OH_Environment_FileLocation {
/**
* @brief Indicates the file located on the local.
*/
LOCAL = 1,
/**
* @brief Indicates the file located on the cloud.
*/
CLOUD = 2
} OH_Environment_FileLocation;
/**
* @brief Get the file location.
*
* @param uri Represents a pointer to a uri.
* @param uriLength Indicates the length of the uri.
* @return Returns the file location enum.
* @see OH_Environment_FileLocation
* @since 12
*/
OH_Environment_FileLocation OH_Environment_GetFileLocation(char *uri, int uriLength);
/**
* @brief Get the user Download directory.
*
* @param result Represents a pointer to a string.
* @param resultNum Indicates the length of the result string.
* @return Returns the status code of the execution.
* @since 12
*/
int OH_Environment_GetUserDownloadDir(char **result, int *resultLength);
/**
* @brief Get the user Desktop directory.
*
* @param result Represents a pointer to a string.
* @param resultNum Indicates the length of the result string.
* @return Returns the status code of the execution.
* @since 12
*/
int OH_Environment_GetUserDesktopDir(char **result, int *resultLength);
/**
* @brief Get the user Document directory.
*
* @param result Represents a pointer to a string.
* @param resultNum Indicates the length of the result string.
* @return Returns the status code of the execution.
* @since 12
*/
int OH_Environment_GetUserDocumentDir(char **result, int *resultLength);
#ifdef __cplusplus
};
#endif
#endif //FILE_SHARE_H

View File

@ -0,0 +1,74 @@
/*
* 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_ENVIRONMENT_OH_ENVIRONMENT_H
#define FILE_MANAGEMENT_ENVIRONMENT_OH_ENVIRONMENT_H
/**
* @addtogroup Environment
*
* @brief This module provides the ability to access the environment directory and obtain the native interface
for public root directory.
* @since 12
*/
/**
* @file oh_environment.h
*
* @brief Provide environment APIS.
* @library libohenvironment.so
* @syscap SystemCapability.FileManagement.File.Environment.FolderObtain
* @since 12
*/
#include "error_code.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Get the user Download directory.
*
* @permission ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY
* @param result Output a pointer to a string. Please use free() to clear the resource.
* @return Return the status code of the execution.
* @since 12
*/
FileManagement_ErrCode OH_Environment_GetUserDownloadDir(char **result);
/**
* @brief Get the user Desktop directory.
*
* @permission ohos.permission.READ_WRITE_DESKTOP_DIRECTORY
* @param result Output a pointer to a string. Please use free() to clear the resource.
* @return Return the status code of the execution.
* @since 12
*/
FileManagement_ErrCode OH_Environment_GetUserDesktopDir(char **result);
/**
* @brief Get the user Document directory.
*
* @permission ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY
* @param result Output a pointer to a string. Please use free() to clear the resource.
* @return Return the status code of the execution.
* @since 12
*/
FileManagement_ErrCode OH_Environment_GetUserDocumentDir(char **result);
#ifdef __cplusplus
};
#endif
#endif //FILE_MANAGEMENT_ENVIRONMENT_OH_ENVIRONMENT_H

View File

@ -1,6 +1,14 @@
[
{"name":"OH_Environment_GetUserDownloadDir" },
{"name":"OH_Environment_GetUserDesktopDir" },
{"name":"OH_Environment_GetUserDownloadDir" },
{"name":"OH_Environment_GetFileLocation" }
{
"first_introduced": "12",
"name":"OH_Environment_GetUserDownloadDir"
},
{
"first_introduced": "12",
"name":"OH_Environment_GetUserDesktopDir"
},
{
"first_introduced": "12",
"name":"OH_Environment_GetUserDocumentDir"
}
]

View File

@ -0,0 +1,32 @@
# 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_library("libohfileio") {
ndk_description_file = "./libfileio.ndk.json"
min_compact_version = "12"
output_name = "ohfileio"
output_extension = "so"
system_capability = "SystemCapability.FileManagement.File.FileIO"
system_capability_headers = [ "filemanagement/fileio/oh_fileio.h" ]
}
ohos_ndk_headers("oh_fileio_header") {
dest_dir = "$ndk_headers_out_dir/filemanagement/fileio/"
sources = [
"./include/error_code.h",
"./include/oh_fileio.h",
]
}

View File

@ -0,0 +1,78 @@
/*
* 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_FILEIO_ERROR_CODE_H
#define FILE_MANAGEMENT_FILEIO_ERROR_CODE_H
/**
* @addtogroup FileIO
* @{
*
* @brief Provide the definition of the error codes.
* @since 12
*/
/**
* @file error_code.h
*
* @brief Declare the error codes of file management module.
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 12
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief error codes of file management
* @since 12
*/
typedef enum FileManagement_ErrCode {
/**
* operation completed successfully.
*/
ERR_OK = 0,
/**
* permission verification failed.
*/
ERR_PERMISSION_ERROR = 201,
/**
* device not supported.
*/
ERR_DEVICE_NOT_SUPPORTED = 801,
/**
* operation not permitted.
*/
ERR_EPERM = 13900001,
/**
* no such file or directory.
*/
ERR_ENOENT = 13900002,
/**
* out of memory.
*/
ERR_ENOMEM = 139000011,
/**
* unknown error.
*/
ERR_UNKNOWN = 13900042
} FileManagement_ErrCode;
#ifdef __cplusplus
}
#endif
#endif // FILE_MANAGEMENT_FILEIO_ERROR_CODE_H

View File

@ -0,0 +1,75 @@
/*
* 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_FILEIO_OH_FILEIO_H
#define FILE_MANAGEMENT_FILEIO_OH_FILEIO_H
/**
* @addtogroup FileIO
*
* @brief This module provides the basic file operations.
* @since 12
*/
/**
* @file oh_fileio.h
*
* @brief Provide fileio APIS.
* @library libohfileio.so
* @syscap SystemCapability.FileManagement.File.FileIO
* @since 12
*/
#include "error_code.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enumerates the file location.
* @since 12
*/
typedef enum FileIO_FileLocation {
/**
* @brief Indicates the file located on the local.
*/
LOCAL = 1,
/**
* @brief Indicates the file located on the cloud.
*/
CLOUD = 2,
/**
* @brief Indicates the file located on the local and cloud.
*/
LOCAL_AND_CLOUD = 3
} FileIO_FileLocation;
/**
* @brief Get the file location.
*
* @param uri Input a pointer to a uri.
* @param uriLength Input the length of the uri.
* @param location Output the result of file location.
* @return Return the status code of the execution.
* @since 12
*/
FileManagement_ErrCode OH_FileIO_GetFileLocation(char *uri, int uriLength,
FileIO_FileLocation *location);
#ifdef __cplusplus
};
#endif
#endif //FILE_MANAGEMENT_FILEIO_OH_FILEIO_H

View File

@ -0,0 +1,6 @@
[
{
"first_introduced": "12",
"name":"OH_FileIO_GetFileLocation"
}
]