diff options
-rwxr-xr-x | include/app.h | 115 | ||||
-rwxr-xr-x | src/app_path.c | 74 |
2 files changed, 189 insertions, 0 deletions
diff --git a/include/app.h b/include/app.h index c47ca83..35d2939 100755 --- a/include/app.h +++ b/include/app.h @@ -545,6 +545,121 @@ char* app_get_data_directory(char *buffer, int size); /** + * @brief Gets the absolute path to the application's data directory which is used to store private + * data of the application. + * @details An application can read and write its own files in the application's data directory. + * @remarks The returned path should be released. + * + * @return The absolute path to the application's data directory, @n + * else @a null pointer if the memory is insufficient + */ +char *app_get_data_path(void); + +/** + * @brief Gets the absolute path to the application's cache directory which is used to store + * temporary data of the application. + * @details An application can read and write its own files in the application's cache directory. + * @remarks The returned path should be released. @n + * The files stored in the application's cache directory can be removed by Setting + * application or platform while the application is running. + * + * @return The absolute path to the application's cache directory, @n + * else @a null pointer if the memory is insufficient + */ +char *app_get_cache_path(void); + +/** + * @brief Gets the absolute path to the application resource directory. The resource files + * are delivered with the application package. + * @details An application can only read its own files in the application's resource directory. + * @remarks The returned path should be released. + * + * @return The absolute path to the application's resource directory, @n + * else @a null pointer if the memory is insufficient + */ +char *app_get_resource_path(void); + +/** + * @brief Gets the absolute path to the application's shared data directory which is used to share + * data with other applications. + * @details An application can read and write its own files in the application's shared data + * directory and others can only read the files. + * @remarks The returned path should be released. + * + * @return The absolute path to the application's shared data directory, @n + * else @a null pointer if the memory is insufficient + */ +char *app_get_shared_data_path(void); + +/** + * @brief Gets the absolute path to the application's shared resource directory which is used to + * share resources with other applications. + * @details An application can read its own files in the application's shared resource directory + * and others can only read the files. + * @remarks The returned path should be released. + * + * @return The absolute path to the application's shared resource directory, @n + * else @a null pointer if the memory is insufficient + */ +char *app_get_shared_resource_path(void); + +/** + * @brief Gets the absolute path to the application's shared trusted directory which is used to share data + * with family of trusted applications + * @details An application can read and write its own files in the application's shared trusted directory + * and the family applications signed with the same certificate can read and write the files in the + * shared trusted directory. + * @remarks The returned path should be released. + * + * @return The absolute path to the application's shared trusted directory, @n + * else @a null pointer if the memory is insufficient + */ +char *app_get_shared_trusted_path(void); + +/** + * @brief Gets the absolute path to the application's external data directory which is used to + * store data of the application. + * @details An application can read and write its own files in the application's external data + * directory. + * @remarks The returned path should be released. @n + * The important files stored in the application's external data directory should be + * encrypted because they can be exported via the external sdcard. + * + * @return The absolute path to the application's external data directory, @n + * else @a null pointer if the memory is insufficient + */ +char *app_get_external_data_path(void); + +/** + * @brief Gets the absolute path to the application's external cache directory which is used to + * store temporary data of the application. + * @details An application can read and write its own files in the application's external cache + * directory. + * @remarks The returned path should be released. @n + * The files stored in the application's external cache directory can be removed by + * Setting application while the application is running. @n + * The important files stored in the application's external cache directory should be + * encrypted because they can be exported via the external sdcard. + * + * @return The absolute path to the application's external cache directory, @n + * else @a null pointer if the memory is insufficient + */ +char *app_get_external_cache_path(void); + +/** + * @brief Gets the absolute path to the application's external shared data directory which is + * used to share data with other applications. + * @details An application can read and write its own files in the application's external shared + * data directory and others can only read the files. + * @remarks The specified @a path should be released. + * + * @return The absolute path to the application's external shared data directory, @n + * else @a null pointer if the memory is insufficient + */ +char *app_get_external_shared_data_path(void); + + +/** * @brief Gets the current device orientation. * * @return The current device orientation diff --git a/src/app_path.c b/src/app_path.c new file mode 100755 index 0000000..82b2a9b --- /dev/null +++ b/src/app_path.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 <string.h> +#include <aul.h> + +#define _STRDUP(s) ((s) ? strdup(s) : NULL) + +char *app_get_data_path(void) +{ + const char *buf = aul_get_app_data_path(); + return _STRDUP(buf); +} + +char *app_get_cache_path(void) +{ + const char *buf = aul_get_app_cache_path(); + return _STRDUP(buf); +} + +char *app_get_resource_path(void) +{ + const char *buf = aul_get_app_resource_path(); + return _STRDUP(buf); +} + +char *app_get_shared_data_path(void) +{ + const char *buf = aul_get_app_shared_data_path(); + return _STRDUP(buf); +} + +char *app_get_shared_resource_path(void) +{ + const char *buf = aul_get_app_shared_resource_path(); + return _STRDUP(buf); +} + +char *app_get_shared_trusted_path(void) +{ + const char *buf = aul_get_app_shared_trusted_path(); + return _STRDUP(buf); +} + +char *app_get_external_data_path(void) +{ + const char *buf = aul_get_app_external_data_path(); + return _STRDUP(buf); +} + +char *app_get_external_cache_path(void) +{ + const char *buf = aul_get_app_external_cache_path(); + return _STRDUP(buf); +} + +char *app_get_external_shared_data_path(void) +{ + const char *buf = aul_get_app_external_shared_data_path(); + return _STRDUP(buf); +} |