Tizen Native API
5.5
|
The STORAGE API provides functions to get storage information.
#include <storage.h>
The STORAGE API provides functions to get storage information.
The type of storage information includes:
The type of directory information includes:
This API is related with the following features:
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from feature element description.
Functions | |
int | storage_foreach_device_supported (storage_device_supported_cb callback, void *user_data) |
Retrieves all the storage in a device. | |
int | storage_get_root_directory (int storage_id, char **path) |
Gets the absolute path to the root directory of the given storage. | |
int | storage_get_directory (int storage_id, storage_directory_e type, char **path) |
Gets the absolute path to the each directory of the given storage. | |
int | storage_get_type (int storage_id, storage_type_e *type) |
Gets the type of the given storage. | |
int | storage_get_state (int storage_id, storage_state_e *state) |
Gets the current state of the given storage. | |
int | storage_set_state_changed_cb (int storage_id, storage_state_changed_cb callback, void *user_data) |
Registers a callback function to be invoked when the state of the storage changes. | |
int | storage_unset_state_changed_cb (int storage_id, storage_state_changed_cb callback) |
Unregisters the callback function. | |
int | storage_set_changed_cb (storage_type_e type, storage_changed_cb callback, void *user_data) |
Registers a callback function to be invoked when the state of the specified storage device type changes. | |
int | storage_unset_changed_cb (storage_type_e type, storage_changed_cb callback) |
Unregisters the callback function for storage type state changes. | |
int | storage_get_total_space (int storage_id, unsigned long long *bytes) |
Gets the total space of the given storage in bytes. | |
int | storage_get_available_space (int storage_id, unsigned long long *bytes) |
Gets the available space size of the given storage in bytes. | |
int | storage_get_type_dev (int storage_id, storage_type_e *type, storage_dev_e *dev) |
Gets the type and the kind of external device for the given storage id. | |
int | storage_get_internal_memory_size (struct statvfs *buf) |
Gets the internal memory size. | |
int | storage_get_external_memory_size (struct statvfs *buf) |
Gets the external memory size. | |
Typedefs | |
typedef bool(* | storage_device_supported_cb )(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data) |
Called to get information once for each supported storage. | |
typedef void(* | storage_state_changed_cb )(int storage_id, storage_state_e state, void *user_data) |
Called when the state of storage changes. | |
typedef void(* | storage_changed_cb )(int storage_id, storage_dev_e dev, storage_state_e state, const char *fstype, const char *fsuuid, const char *mountpath, bool primary, int flags, void *user_data) |
Called when the state of a storage type changes. |
typedef void(* storage_changed_cb)(int storage_id, storage_dev_e dev, storage_state_e state, const char *fstype, const char *fsuuid, const char *mountpath, bool primary, int flags, void *user_data) |
Called when the state of a storage type changes.
[in] | storage_id | The unique storage ID |
[in] | dev | The type of the external storage device |
[in] | state | The state of the storage |
[in] | fstype | The type of the file system |
[in] | fsuuid | The uuid of the file system |
[in] | mountpath | The mount path of the file system |
[in] | primary | The primary partition |
[in] | flags | The flags for the storage status |
[in] | user_data | The user data |
typedef bool(* storage_device_supported_cb)(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data) |
Called to get information once for each supported storage.
[in] | storage_id | The unique storage ID |
[in] | type | The type of the storage |
[in] | state | The current state of the storage |
[in] | path | The absolute path to the root directory of the storage |
[in] | user_data | The user data passed from the foreach function |
true
to continue with the next iteration of the loop, false
to break out of the loop typedef void(* storage_state_changed_cb)(int storage_id, storage_state_e state, void *user_data) |
Called when the state of storage changes.
[in] | storage_id | The unique storage ID |
[in] | state | The current state of the storage |
[in] | user_data | The user data passed from the foreach function |
enum storage_dev_e |
Enumeration for storage device types.
enum storage_directory_e |
Enumeration for the storage directory types.
enum storage_error_e |
enum storage_state_e |
Enumeration for storage devices state.
enum storage_type_e |
Enumeration for the storage types.
int storage_foreach_device_supported | ( | storage_device_supported_cb | callback, |
void * | user_data | ||
) |
Retrieves all the storage in a device.
This function invokes the callback function once for each storage in a device.
If storage_device_supported_cb() returns false
, then the iteration will be finished.
[in] | callback | The iteration callback function |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
int storage_get_available_space | ( | int | storage_id, |
unsigned long long * | bytes | ||
) |
Gets the available space size of the given storage in bytes.
[in] | storage_id | The storage device |
[out] | bytes | The available space size of the storage (bytes) |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_OUT_OF_MEMORY | Out of memory |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_get_directory | ( | int | storage_id, |
storage_directory_e | type, | ||
char ** | path | ||
) |
Gets the absolute path to the each directory of the given storage.
[in] | storage_id | The storage device |
[in] | type | The directory type |
[out] | path | The absolute path to the directory type |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_OUT_OF_MEMORY | Out of memory |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_get_external_memory_size | ( | struct statvfs * | buf | ) |
Gets the external memory size.
[out] | buf | A pointer to a statvfs structure |
0
on success, otherwise a negative error value on failure STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
... struct statvfs s; if (storage_get_external_memory_size(&s) < 0) dlog_print(DLOG_DEBUG, LOG_TAG, "Fail to get external memory size"); else dlog_print(DLOG_DEBUG, LOG_TAG, "Total mem : %lf, Avail mem : %lf", (double)s.f_frsize*s.f_blocks, (double)s.f_bsize*s.f_bavail); ...
int storage_get_internal_memory_size | ( | struct statvfs * | buf | ) |
Gets the internal memory size.
[out] | buf | A pointer to a statvfs structure |
0
on success, otherwise a negative error value on failure STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
... struct statvfs s; if (storage_get_internal_memory_size(&s) < 0) dlog_print(DLOG_DEBUG, LOG_TAG, "Fail to get internal memory size"); else dlog_print(DLOG_DEBUG, LOG_TAG, "Total mem : %lf, Avail mem : %lf", (double)s.f_frsize*s.f_blocks, (double)s.f_bsize*s.f_bavail); ...
int storage_get_root_directory | ( | int | storage_id, |
char ** | path | ||
) |
Gets the absolute path to the root directory of the given storage.
[in] | storage_id | The storage device |
[out] | path | The absolute path to the storage directory |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_OUT_OF_MEMORY | Out of memory |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_get_state | ( | int | storage_id, |
storage_state_e * | state | ||
) |
Gets the current state of the given storage.
[in] | storage_id | The storage device |
[out] | state | The current state of the storage |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_OUT_OF_MEMORY | Out of memory |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_get_total_space | ( | int | storage_id, |
unsigned long long * | bytes | ||
) |
Gets the total space of the given storage in bytes.
[in] | storage_id | The storage device |
[out] | bytes | The total space size of the storage (bytes) |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_OUT_OF_MEMORY | Out of memory |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_get_type | ( | int | storage_id, |
storage_type_e * | type | ||
) |
Gets the type of the given storage.
[in] | storage_id | The storage device |
[out] | type | The type of the storage |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_OUT_OF_MEMORY | Out of memory |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_get_type_dev | ( | int | storage_id, |
storage_type_e * | type, | ||
storage_dev_e * | dev | ||
) |
Gets the type and the kind of external device for the given storage id.
[in] | storage_id | The storage id |
[out] | type | The storage type (internal or external). If type is STORAGE_TYPE_INTERNAL, this function returns STORAGE_ERROR_INVALID_PARAMETER and dev is unchanged. |
[out] | dev | The storage device for external storage. |
0
on success, otherwise a negative error valueSTORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_OUT_OF_MEMORY | Out of memory |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_set_changed_cb | ( | storage_type_e | type, |
storage_changed_cb | callback, | ||
void * | user_data | ||
) |
Registers a callback function to be invoked when the state of the specified storage device type changes.
[in] | type | The type of the storage device |
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_set_state_changed_cb | ( | int | storage_id, |
storage_state_changed_cb | callback, | ||
void * | user_data | ||
) |
Registers a callback function to be invoked when the state of the storage changes.
[in] | storage_id | The storage device |
[in] | callback | The callback function to register |
[in] | user_data | The user data to be passed to the callback function |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_unset_changed_cb | ( | storage_type_e | type, |
storage_changed_cb | callback | ||
) |
Unregisters the callback function for storage type state changes.
[in] | type | The type of the the storage device |
[in] | callback | The callback function to unregister |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |
int storage_unset_state_changed_cb | ( | int | storage_id, |
storage_state_changed_cb | callback | ||
) |
Unregisters the callback function.
[in] | storage_id | The storage device to monitor |
[in] | callback | The callback function to register |
0
on success, otherwise a negative error value STORAGE_ERROR_NONE | Successful |
STORAGE_ERROR_INVALID_PARAMETER | Invalid parameter |
STORAGE_ERROR_NOT_SUPPORTED | Storage not supported |
STORAGE_ERROR_OPERATION_FAILED | Operation failed |