File I/O functions.
More...
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "libjaylink.h"
#include "libjaylink-internal.h"
|
int | jaylink_file_read (struct jaylink_device_handle *devh, const char *filename, uint8_t *buffer, uint32_t offset, uint32_t *length) |
| Read from a file.
|
|
int | jaylink_file_write (struct jaylink_device_handle *devh, const char *filename, const uint8_t *buffer, uint32_t offset, uint32_t *length) |
| Write to a file.
|
|
int | jaylink_file_get_size (struct jaylink_device_handle *devh, const char *filename, uint32_t *size) |
| Retrieve the size of a file.
|
|
int | jaylink_file_delete (struct jaylink_device_handle *devh, const char *filename) |
| Delete a file.
|
|
◆ jaylink_file_delete()
Delete a file.
- Note
- This function must only be used if the device has the JAYLINK_DEV_CAP_FILE_IO capability.
- Parameters
-
[in,out] | devh | Device handle. |
[in] | filename | Name of the file to delete. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes. |
- Return values
-
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error, or the file was not found. |
JAYLINK_ERR | Other error conditions. |
- Since
- 0.1.0
◆ jaylink_file_get_size()
int jaylink_file_get_size |
( |
struct jaylink_device_handle * | devh, |
|
|
const char * | filename, |
|
|
uint32_t * | size ) |
Retrieve the size of a file.
- Note
- This function must only be used if the device has the JAYLINK_DEV_CAP_FILE_IO capability.
- Parameters
-
[in,out] | devh | Device handle. |
[in] | filename | Name of the file to retrieve the size of. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes. |
[out] | size | Size of the file in bytes on success, and undefined on failure. |
- Return values
-
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error, or the file was not found. |
JAYLINK_ERR | Other error conditions. |
- Since
- 0.1.0
◆ jaylink_file_read()
int jaylink_file_read |
( |
struct jaylink_device_handle * | devh, |
|
|
const char * | filename, |
|
|
uint8_t * | buffer, |
|
|
uint32_t | offset, |
|
|
uint32_t * | length ) |
Read from a file.
The maximum amount of data that can be read from a file at once is JAYLINK_FILE_MAX_TRANSFER_SIZE bytes. Multiple reads in conjunction with the offset
parameter are needed for larger files.
- Note
- This function must only be used if the device has the JAYLINK_DEV_CAP_FILE_IO capability.
- Parameters
-
[in,out] | devh | Device handle. |
[in] | filename | Name of the file to read from. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes. |
[out] | buffer | Buffer to store read data on success. Its content is undefined on failure |
[in] | offset | Offset in bytes relative to the beginning of the file from where to start reading. |
[in,out] | length | Number of bytes to read. On success, the value gets updated with the actual number of bytes read. The value is undefined on failure. |
- Return values
-
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error, or the file was not found. |
JAYLINK_ERR | Other error conditions. |
- Since
- 0.1.0
◆ jaylink_file_write()
int jaylink_file_write |
( |
struct jaylink_device_handle * | devh, |
|
|
const char * | filename, |
|
|
const uint8_t * | buffer, |
|
|
uint32_t | offset, |
|
|
uint32_t * | length ) |
Write to a file.
If a file does not exist, a new file is created.
The maximum amount of data that can be written to a file at once is JAYLINK_FILE_MAX_TRANSFER_SIZE bytes. Multiple writes in conjunction with the offset
parameter are needed for larger files.
- Note
- This function must only be used if the device has the JAYLINK_DEV_CAP_FILE_IO capability.
- Parameters
-
[in,out] | devh | Device handle. |
[in] | filename | Name of the file to write to. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes. |
[in] | buffer | Buffer to write data from. |
[in] | offset | Offset in bytes relative to the beginning of the file from where to start writing. |
[in,out] | length | Number of bytes to write. On success, the value gets updated with the actual number of bytes written. The value is undefined on failure. |
- Return values
-
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error, or the file was not found. |
JAYLINK_ERR | Other error conditions. |
- Since
- 0.1.0