APIs for executing file operations on Mobiles or the Cloud. More...
Functions | |
void | s2c_file_set_cloud_settings (const char *host, const char *cert_filename) |
Sets the S2C server settings. More... | |
zos_result_t | s2c_file_open (s2c_file_target_t target, s2c_file_t *file, s2c_file_handle_t *handle_ptr) |
Open a file for reading. More... | |
zos_result_t | s2c_file_create (s2c_file_target_t target, const s2c_file_t *file, s2c_file_flag_t flags, s2c_file_handle_t *handle_ptr) |
Open a file for writing. More... | |
zos_result_t | s2c_file_read (const s2c_file_handle_t *handle, void *data, uint32_t max_size, uint32_t *bytes_read) |
Read file data. More... | |
zos_result_t | s2c_file_write (const s2c_file_handle_t *handle, void *data, uint32_t size) |
Write file data. More... | |
zos_result_t | s2c_file_close (const s2c_file_handle_t *handle, zos_result_t result, uint32_t timeout_ms) |
Close previously opened file. More... | |
zos_result_t | s2c_file_stat (s2c_file_target_t target, const char *filename, s2c_file_t *file_info) |
Return information about file. More... | |
zos_result_t | s2c_file_delete (s2c_file_target_t target, const char *filename) |
Delete file on Mobile or Cloud. More... | |
zos_result_t | s2c_file_list (s2c_file_target_t target, const s2c_file_list_parameters_t *parameters, s2c_file_t **file_list_ptr) |
List files on Mobile or Cloud. More... | |
void | s2c_file_list_destroy (s2c_file_t *list) |
Destroy linked-list. More... | |
zos_result_t | s2c_file_upload (s2c_file_target_t target, const char *local_filename, const char *remote_filename) |
Upload local file to cloud or Mobile client. More... | |
zos_result_t | s2c_file_download (s2c_file_target_t target, const char *remote_filename, const char *local_filename) |
Download remote file on cloud or Mobile client to local file system. More... | |
Detailed Description
APIs for executing file operations on Mobiles or the Cloud.
Function Documentation
zos_result_t s2c_file_close | ( | const s2c_file_handle_t * | handle, |
zos_result_t | result, |
||
uint32_t | timeout_ms |
||
) |
Close previously opened file.
This closes a file opened with s2c_file_open() or s2c_file_create()
- Parameters
-
handle
Handle of opened file. result
Result of the file operation (
- Note
- this is only used for a S2C_FILE_TARGET_MOBILE target)
- Parameters
-
timeout_ms
Time in milliseconds to wait for target to finish operation (
- Note
- this is only used for a S2C_FILE_TARGET_MOBILE target)
- Returns
- Result of API call, see zos_result_t
zos_result_t s2c_file_create | ( | s2c_file_target_t | target, |
const s2c_file_t * | file, |
||
s2c_file_flag_t | flags, |
||
s2c_file_handle_t * | handle_ptr |
||
) |
Open a file for writing.
This creates a file on a Mobile client or Cloud, target should be one of the following:
- S2C_FILE_TARGET_CLOUD : create file from the S2C cloud
- S2C_FILE_TARGET_DMS_DEVICE : Device Management Server (DMS) device
- S2C_FILE_TARGET_MOBILE : create file from locally connected mobile client
If the API returns successfully, a handle is returned. The s2c_file_write() API should be used to write the file's data.
Issue the s2c_file_close() API when finished writing the file.
The s2c_file_t argument should contain information about the file to create including:
- Filename
- File size in bytes
- Optionally the CRC of the file's data. The target will verify the CRC after the file is written. Leave as UINT32_MAX if unused.
- Parameters
-
target
The target of the write operation, see s2c_file_target_t file
Information about file to create, see s2c_file_t flags
File creation flags, see s2c_file_flag_t handle_ptr
Pointer to hold handle of opened file
- Returns
- Result of API call, see zos_result_t
zos_result_t s2c_file_delete | ( | s2c_file_target_t | target, |
const char * | filename |
||
) |
Delete file on Mobile or Cloud.
This deletes a file on a Mobile client or Cloud, target should be one of the following:
- S2C_FILE_TARGET_CLOUD : S2C cloud
- S2C_FILE_TARGET_DMS_DEVICE : Device Management Server (DMS) device
- S2C_FILE_TARGET_MOBILE : locally connected mobile client
- Parameters
-
target
The target of the delete operation, see s2c_file_target_t filename
Name of file to delete
- Returns
- Result of API call, see zos_result_t
zos_result_t s2c_file_download | ( | s2c_file_target_t | target, |
const char * | remote_filename, |
||
const char * | local_filename |
||
) |
Download remote file on cloud or Mobile client to local file system.
This downloads a remote file on the Mobile client or Cloud to the local file system, target should be one of the following:
- S2C_FILE_TARGET_CLOUD : S2C cloud
- S2C_FILE_TARGET_DMS_DEVICE : Device Management Server (DMS) device
- S2C_FILE_TARGET_DMS_PRODUCT : Device Management Server (DMS) device product
- S2C_FILE_TARGET_MOBILE : locally connected mobile client
- Parameters
-
[in] target
Target of file operation [in] remote_filename
File name/path of remote file [in] local_filename
Optional, name of locally created file, leave NULL to use remote_filename as local_filename
- Returns
- Result of API, see zos_result_t
zos_result_t s2c_file_list | ( | s2c_file_target_t | target, |
const s2c_file_list_parameters_t * | parameters, |
||
s2c_file_t ** | file_list_ptr |
||
) |
List files on Mobile or Cloud.
This lists files on a Mobile client or Cloud, target should be one of the following:
- S2C_FILE_TARGET_CLOUD : S2C cloud
- S2C_FILE_TARGET_DMS_DEVICE : Device Management Server (DMS) device
- S2C_FILE_TARGET_DMS_PRODUCT : Device Management Server (DMS) device product
- S2C_FILE_TARGET_MOBILE : locally connected mobile client
Optional parameters can be given to limit the returns file listing.
- Note
- s2c_file_list_destroy() MUST be used to cleanup the returned file listing.
- Parameters
-
target
The target of the list operation, see s2c_file_target_t parameters
Optional parameters to limit the returned file listing, see s2c_file_list_parameters_t file_list_ptr
Pointer to hold linked-list of s2c_file_t containing file listing
- Returns
- Result of API call, see zos_result_t
void s2c_file_list_destroy | ( | s2c_file_t * | list | ) |
Destroy linked-list.
This frees the memory allocated by the file listing returned by s2c_file_list()
- Parameters
-
list
File listing to cleanup
zos_result_t s2c_file_open | ( | s2c_file_target_t | target, |
s2c_file_t * | file, |
||
s2c_file_handle_t * | handle_ptr |
||
) |
Open a file for reading.
This opens a file on a Mobile client or Cloud, target should be one of the following:
- S2C_FILE_TARGET_CLOUD : read file from the S2C cloud
- S2C_FILE_TARGET_DMS_DEVICE : Device Management Server (DMS) device
- S2C_FILE_TARGET_DMS_PRODUCT : Device Management Server (DMS) device product
- S2C_FILE_TARGET_MOBILE : read file from locally connected mobile client
If the API returns successfully, a handle is returned. The s2c_file_read() API should be used to read the file's data.
Issue the s2c_file_close() API when finished reading the file.
- Note
- The
file
argument is a s2c_file_t which should have the filename specified. If the file is successfully opened, the s2c_file_t argument will be updated with the file's size and CRC determined from the remote side.
- Parameters
-
[in] target
The target of the read operation, see s2c_file_target_t [in,out] file
s2c_file_t containing filename to open on remote side, the file size and CRC will be update if the file is opened [out] handle_ptr
Pointer to hold handle of opened file
- Returns
- Result of API call, see zos_result_t
zos_result_t s2c_file_read | ( | const s2c_file_handle_t * | handle, |
void * | data, |
||
uint32_t | max_size, |
||
uint32_t * | bytes_read |
||
) |
Read file data.
This reads file data of opened file. The file should have been previously opened using s2c_file_open()
- Parameters
-
handle
Handle of opened file data
Buffer to hold read file data max_size
Size of supplied data buffer bytes_read
Pointer to hold number of bytes actually read, leave NULL if unused
- Returns
- Result of API call, see zos_result_t
void s2c_file_set_cloud_settings | ( | const char * | host, |
const char * | cert_filename |
||
) |
Sets the S2C server settings.
- Parameters
-
host
The URL of the S2C server, e.g. https://cloud.zentri.com cert_filename
The TLS CA certificate of the S2C server
zos_result_t s2c_file_stat | ( | s2c_file_target_t | target, |
const char * | filename, |
||
s2c_file_t * | file_info |
||
) |
Return information about file.
This returns information about a file on a Mobile client or Cloud, target should be one of the following:
- S2C_FILE_TARGET_CLOUD : S2C cloud
- S2C_FILE_TARGET_DMS_DEVICE : Device Management Server (DMS) device
- S2C_FILE_TARGET_DMS_PRODUCT : Device Management Server (DMS) device product
- S2C_FILE_TARGET_MOBILE : locally connected mobile client
- Parameters
-
target
The target of the stat operation, see s2c_file_target_t filename
Name of file to gain information about file_info
s2c_file_t to hold information about file
- Returns
- Result of API call, see zos_result_t
zos_result_t s2c_file_upload | ( | s2c_file_target_t | target, |
const char * | local_filename, |
||
const char * | remote_filename |
||
) |
Upload local file to cloud or Mobile client.
This uploads a local file to the Mobile client or Cloud, target should be one of the following:
- S2C_FILE_TARGET_CLOUD : S2C cloud
- S2C_FILE_TARGET_DMS_DEVICE : Device Management Server (DMS) device
- S2C_FILE_TARGET_MOBILE : locally connected mobile client
- Parameters
-
[in] target
Target of file operation [in] local_filename
Name of file on local file system to upload [in] remote_filename
Optional, name of created file on remote side, leave NULL to use local_filename as remote_filename
- Returns
- Result of API, see zos_result_t
zos_result_t s2c_file_write | ( | const s2c_file_handle_t * | handle, |
void * | data, |
||
uint32_t | size |
||
) |
Write file data.
This writes file data of file opened for writing. The file should have been previously opened using s2c_file_create()
- Parameters
-
handle
Handle of opened file data
Buffer holding data to write to file size
Number of bytes to write to file
- Returns
- Result of API call, see zos_result_t