OpenOCD
jtag/drivers/libjaylink/libjaylink/fileio.c File Reference

File I/O functions. More...

Include dependency graph for jtag/drivers/libjaylink/libjaylink/fileio.c:

Go to the source code of this file.

Functions

JAYLINK_API int jaylink_file_delete (struct jaylink_device_handle *devh, const char *filename)
 Delete a file. More...
 
JAYLINK_API int jaylink_file_get_size (struct jaylink_device_handle *devh, const char *filename, uint32_t *size)
 Retrieve the size of a file. More...
 
JAYLINK_API 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. More...
 
JAYLINK_API 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. More...
 

Detailed Description

File I/O functions.

Definition in file jtag/drivers/libjaylink/libjaylink/fileio.c.

Function Documentation

◆ jaylink_file_delete()

JAYLINK_API int jaylink_file_delete ( struct jaylink_device_handle devh,
const char *  filename 
)

Delete a file.

Note
This function must only be used if the device has the JAYLINK_DEV_CAP_FILE_IO capability.
Parameters
[in,out]devhDevice handle.
[in]filenameName of the file to delete. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERR_DEVUnspecified device error, or the file was not found.
JAYLINK_ERROther error conditions.
Since
0.1.0

Definition at line 430 of file jtag/drivers/libjaylink/libjaylink/fileio.c.

References buffer_get_u32(), jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_ERR_DEV, JAYLINK_FILE_NAME_MAX_LENGTH, JAYLINK_OK, jaylink_strerror(), length, log_err(), transport_read(), transport_start_read(), transport_start_write(), and transport_write().

◆ jaylink_file_get_size()

JAYLINK_API 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]devhDevice handle.
[in]filenameName of the file to retrieve the size of. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes.
[out]sizeSize of the file in bytes on success, and undefined on failure.
Return values
JAYLINK_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERR_DEVUnspecified device error, or the file was not found.
JAYLINK_ERROther error conditions.
Since
0.1.0

Definition at line 338 of file jtag/drivers/libjaylink/libjaylink/fileio.c.

References buffer_get_u32(), jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_ERR_DEV, JAYLINK_FILE_NAME_MAX_LENGTH, JAYLINK_OK, jaylink_strerror(), length, log_err(), transport_read(), transport_start_read(), transport_start_write(), and transport_write().

◆ jaylink_file_read()

JAYLINK_API 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]devhDevice handle.
[in]filenameName of the file to read from. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes.
[out]bufferBuffer to store read data on success. Its content is undefined on failure
[in]offsetOffset in bytes relative to the beginning of the file from where to start reading.
[in,out]lengthNumber 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_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERR_DEVUnspecified device error, or the file was not found.
JAYLINK_ERROther error conditions.
Since
0.1.0

Definition at line 77 of file jtag/drivers/libjaylink/libjaylink/fileio.c.

References buffer_get_u32(), buffer_set_u32(), jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_ERR_DEV, JAYLINK_FILE_MAX_TRANSFER_SIZE, JAYLINK_FILE_NAME_MAX_LENGTH, JAYLINK_OK, jaylink_strerror(), log_err(), transport_read(), transport_start_read(), transport_start_write(), and transport_write().

◆ jaylink_file_write()

JAYLINK_API 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]devhDevice handle.
[in]filenameName of the file to write to. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes.
[in]bufferBuffer to write data from.
[in]offsetOffset in bytes relative to the beginning of the file from where to start writing.
[in,out]lengthNumber 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_OKSuccess.
JAYLINK_ERR_ARGInvalid arguments.
JAYLINK_ERR_TIMEOUTA timeout occurred.
JAYLINK_ERR_IOInput/output error.
JAYLINK_ERR_DEVUnspecified device error, or the file was not found.
JAYLINK_ERROther error conditions.
Since
0.1.0

Definition at line 212 of file jtag/drivers/libjaylink/libjaylink/fileio.c.

References buffer_get_u32(), buffer_set_u32(), jaylink_device::ctx, jaylink_device_handle::dev, JAYLINK_ERR_ARG, JAYLINK_ERR_DEV, JAYLINK_FILE_MAX_TRANSFER_SIZE, JAYLINK_FILE_NAME_MAX_LENGTH, JAYLINK_OK, jaylink_strerror(), log_err(), transport_read(), transport_start_read(), transport_start_write(), and transport_write().