Google Cloud IoT device SDK for embedded C  1.0.2
iotc_bsp_io_fs.h File Reference

Go to the source code of this file.

Data Structures

struct  iotc_bsp_io_fs_stat_s
 

Typedefs

typedef intptr_t iotc_bsp_io_fs_resource_handle_t
 
typedef enum iotc_bsp_io_fs_state_e iotc_bsp_io_fs_state_t
 
typedef enum iotc_bsp_io_fs_resource_type_e iotc_bsp_io_fs_resource_type_t
 
typedef struct iotc_bsp_io_fs_stat_s iotc_bsp_io_fs_stat_t
 
typedef enum iotc_bsp_io_fs_open_flags iotc_bsp_io_fs_open_flags_t
 

Enumerations

enum  iotc_bsp_io_fs_state_e {
  IOTC_BSP_IO_FS_STATE_OK = 0, IOTC_BSP_IO_FS_ERROR = 1, IOTC_BSP_IO_FS_INVALID_PARAMETER = 2, IOTC_BSP_IO_FS_RESOURCE_NOT_AVAILABLE = 3,
  IOTC_BSP_IO_FS_OUT_OF_MEMORY = 4, IOTC_BSP_IO_FS_NOT_IMPLEMENTED = 5, IOTC_BSP_IO_FS_OPEN_ERROR = 6, IOTC_BSP_IO_FS_OPEN_READ_ONLY = 7,
  IOTC_BSP_IO_FS_REMOVE_ERROR = 8, IOTC_BSP_IO_FS_WRITE_ERROR = 9, IOTC_BSP_IO_FS_READ_ERROR = 10, IOTC_BSP_IO_FS_CLOSE_ERROR = 11
}
 
enum  iotc_bsp_io_fs_resource_type_e { IOTC_BSP_IO_FS_CERTIFICATE = 0 }
 
enum  iotc_bsp_io_fs_open_flags { IOTC_BSP_IO_FS_OPEN_READ = 1 << 0, IOTC_BSP_IO_FS_OPEN_WRITE = 1 << 1, IOTC_BSP_IO_FS_OPEN_APPEND = 1 << 2 }
 

Functions

iotc_bsp_io_fs_state_t iotc_bsp_io_fs_stat (const char *const resource_name, iotc_bsp_io_fs_stat_t *resource_stat)
 
iotc_bsp_io_fs_state_t iotc_bsp_io_fs_open (const char *const resource_name, const size_t size, const iotc_bsp_io_fs_open_flags_t open_flags, iotc_bsp_io_fs_resource_handle_t *resource_handle_out)
 
iotc_bsp_io_fs_state_t iotc_bsp_io_fs_read (const iotc_bsp_io_fs_resource_handle_t resource_handle, const size_t offset, const uint8_t **buffer, size_t *const buffer_size)
 
iotc_bsp_io_fs_state_t iotc_bsp_io_fs_write (const iotc_bsp_io_fs_resource_handle_t resource_handle, const uint8_t *const buffer, const size_t buffer_size, const size_t offset, size_t *const bytes_written)
 
iotc_bsp_io_fs_state_t iotc_bsp_io_fs_close (const iotc_bsp_io_fs_resource_handle_t resource_handle)
 
iotc_bsp_io_fs_state_t iotc_bsp_io_fs_remove (const char *const resource_name)
 

Detailed Description

Manages files.

Definition in file iotc_bsp_io_fs.h.

Typedef Documentation

◆ iotc_bsp_io_fs_open_flags_t

◆ iotc_bsp_io_fs_resource_handle_t

A pointer to an open file.

Definition at line 36 of file iotc_bsp_io_fs.h.

◆ iotc_bsp_io_fs_resource_type_t

The resource type of TLS certificates.

See also
iotc_bsp_io_fs_resource_type_e

◆ iotc_bsp_io_fs_stat_t

The size of TLS server authentication certificates.

See also
iotc_bsp_io_fs_stat_s

◆ iotc_bsp_io_fs_state_t

The file management function states.

See also
iotc_bsp_io_fs_state_e

Enumeration Type Documentation

◆ iotc_bsp_io_fs_open_flags

Enumerator
IOTC_BSP_IO_FS_OPEN_READ 

Open and read the file.

IOTC_BSP_IO_FS_OPEN_WRITE 

Open and write to the file.

IOTC_BSP_IO_FS_OPEN_APPEND 

Open and append to the file.

Definition at line 107 of file iotc_bsp_io_fs.h.

◆ iotc_bsp_io_fs_resource_type_e

Enumerator
IOTC_BSP_IO_FS_CERTIFICATE 

A TLS certificate resource.

Definition at line 83 of file iotc_bsp_io_fs.h.

◆ iotc_bsp_io_fs_state_e

Enumerator
IOTC_BSP_IO_FS_STATE_OK 

The file management function succeeded.

IOTC_BSP_IO_FS_ERROR 

Something went wrong.

IOTC_BSP_IO_FS_INVALID_PARAMETER 

A parameter is invalid.

IOTC_BSP_IO_FS_RESOURCE_NOT_AVAILABLE 

The file isn't available.

IOTC_BSP_IO_FS_OUT_OF_MEMORY 

The device is out of memory.

IOTC_BSP_IO_FS_NOT_IMPLEMENTED 

The function isn't implmented on your platform.

IOTC_BSP_IO_FS_OPEN_ERROR 

Can't open file.

IOTC_BSP_IO_FS_OPEN_READ_ONLY 

The file is read-only so the SDK can't open it.

IOTC_BSP_IO_FS_REMOVE_ERROR 

The file can't be removed.

IOTC_BSP_IO_FS_WRITE_ERROR 

Can't write data to file.

IOTC_BSP_IO_FS_READ_ERROR 

Can't be read file.

IOTC_BSP_IO_FS_CLOSE_ERROR 

Can't close file.

Definition at line 50 of file iotc_bsp_io_fs.h.

Function Documentation

◆ iotc_bsp_io_fs_close()

iotc_bsp_io_fs_state_t iotc_bsp_io_fs_close ( const iotc_bsp_io_fs_resource_handle_t  resource_handle)

Closes a file and frees all of the resources from reading or writing to the file.

Parameters
[in]resource_handleA handle to an open file.

◆ iotc_bsp_io_fs_open()

iotc_bsp_io_fs_state_t iotc_bsp_io_fs_open ( const char *const  resource_name,
const size_t  size,
const iotc_bsp_io_fs_open_flags_t  open_flags,
iotc_bsp_io_fs_resource_handle_t resource_handle_out 
)

Opens a file.

Parameters
[in]resource_nameThe filename.
[in]sizeThe size, in bytes, of the file.
[in]open_flagsA file operation bitmask.
[out]resource_handle_outA handle to an open file.

◆ iotc_bsp_io_fs_read()

iotc_bsp_io_fs_state_t iotc_bsp_io_fs_read ( const iotc_bsp_io_fs_resource_handle_t  resource_handle,
const size_t  offset,
const uint8_t **  buffer,
size_t *const  buffer_size 
)

Reads a file.

The function must fill the buffer at offset 0. The function can allocate buffers by:

  • Allocating the buffer once, reusing it at each function call, and freeing it when the file closes.
  • Creating a new buffer each time the function is called and freeing the old buffer before the function returns.

For example, see the POSIX implementation of this function.

Parameters
[in]resource_handleA handle to an open file.
[in]offsetThe position within the resource, in bytes, from which to start read operations.
[out]bufferA pointer to a buffer with the bytes read from the file. The buffer is already allocated by the SDK.
[out]buffer_sizeThe number of bytes read from the file and stored in the buffer.

◆ iotc_bsp_io_fs_remove()

iotc_bsp_io_fs_state_t iotc_bsp_io_fs_remove ( const char *const  resource_name)

Deletes a file.

Parameters
[in]resource_nameThe filename.

◆ iotc_bsp_io_fs_stat()

iotc_bsp_io_fs_state_t iotc_bsp_io_fs_stat ( const char *const  resource_name,
iotc_bsp_io_fs_stat_t resource_stat 
)

Gets the size of a file.

Parameters
[in]resource_nameThe file name.
[out]resource_statThe size, in bytes, of the file.

◆ iotc_bsp_io_fs_write()

iotc_bsp_io_fs_state_t iotc_bsp_io_fs_write ( const iotc_bsp_io_fs_resource_handle_t  resource_handle,
const uint8_t *const  buffer,
const size_t  buffer_size,
const size_t  offset,
size_t *const  bytes_written 
)

Writes to a file.

Parameters
[in]resource_handleA handle to an open file.
[in]bufferA pointer to a byte array with the data to write to the file.
[in]buffer_sizeThe size, in bytes of the buffer.
[in]offsetThe position within the resource, in bytes, from which to start to the write operation.
[out]bytes_writtenThe number of bytes written to the file.