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
handleHandle of opened file.
resultResult of the file operation (
Note
this is only used for a S2C_FILE_TARGET_MOBILE target)
Parameters
timeout_msTime 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:

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
targetThe target of the write operation, see s2c_file_target_t
fileInformation about file to create, see s2c_file_t
flagsFile creation flags, see s2c_file_flag_t
handle_ptrPointer 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:

Parameters
targetThe target of the delete operation, see s2c_file_target_t
filenameName 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:

Parameters
[in]targetTarget of file operation
[in]remote_filenameFile name/path of remote file
[in]local_filenameOptional, 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:

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
targetThe target of the list operation, see s2c_file_target_t
parametersOptional parameters to limit the returned file listing, see s2c_file_list_parameters_t
file_list_ptrPointer 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
listFile 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:

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]targetThe target of the read operation, see s2c_file_target_t
[in,out]files2c_file_t containing filename to open on remote side, the file size and CRC will be update if the file is opened
[out]handle_ptrPointer 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
handleHandle of opened file
dataBuffer to hold read file data
max_sizeSize of supplied data buffer
bytes_readPointer 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
hostThe URL of the S2C server, e.g. https://cloud.zentri.com
cert_filenameThe 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:

Parameters
targetThe target of the stat operation, see s2c_file_target_t
filenameName of file to gain information about
file_infos2c_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:

Parameters
[in]targetTarget of file operation
[in]local_filenameName of file on local file system to upload
[in]remote_filenameOptional, 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
handleHandle of opened file
dataBuffer holding data to write to file
sizeNumber of bytes to write to file
Returns
Result of API call, see zos_result_t