Google Cloud IoT device SDK for embedded C  1.0.2
iotc_bsp_io_fs.h
Go to the documentation of this file.
1 /* Copyright 2018-2020 Google LLC
2  *
3  * This is part of the Google Cloud IoT Device SDK for Embedded C.
4  * It is licensed under the BSD 3-Clause license; you may not use this file
5  * except in compliance with the License.
6  *
7  * You may obtain a copy of the License at:
8  * https://opensource.org/licenses/BSD-3-Clause
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __IOTC_BSP_IO_FS_H__
18 #define __IOTC_BSP_IO_FS_H__
19 
24 #include <iotc_error.h>
25 #include <stdint.h>
26 #include <stdlib.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
37 
39 #define IOTC_BSP_IO_FS_INVALID_RESOURCE_HANDLE -1
40 
41 #define iotc_bsp_io_fs_init_resource_handle() \
42  IOTC_BSP_IO_FS_INVALID_RESOURCE_HANDLE
43 
50 typedef enum iotc_bsp_io_fs_state_e {
76 
87 
96 typedef struct iotc_bsp_io_fs_stat_s {
98  size_t resource_size;
100 
115 
123  const char* const resource_name, iotc_bsp_io_fs_stat_t* resource_stat);
124 
136  const char* const resource_name, const size_t size,
137  const iotc_bsp_io_fs_open_flags_t open_flags,
138  iotc_bsp_io_fs_resource_handle_t* resource_handle_out);
139 
162  const iotc_bsp_io_fs_resource_handle_t resource_handle, const size_t offset,
163  const uint8_t** buffer, size_t* const buffer_size);
164 
178  const iotc_bsp_io_fs_resource_handle_t resource_handle,
179  const uint8_t* const buffer, const size_t buffer_size, const size_t offset,
180  size_t* const bytes_written);
181 
190  const iotc_bsp_io_fs_resource_handle_t resource_handle);
191 
197 iotc_bsp_io_fs_state_t iotc_bsp_io_fs_remove(const char* const resource_name);
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif /* __IOTC_BSP_IO_FS_H__ */
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_stat(const char *const resource_name, iotc_bsp_io_fs_stat_t *resource_stat)
Gets the size of a file.
enum iotc_bsp_io_fs_state_e iotc_bsp_io_fs_state_t
The file management function states.
Can't be read file.
The function isn't implmented on your platform.
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.
struct iotc_bsp_io_fs_stat_s iotc_bsp_io_fs_stat_t
The size of TLS server authentication certificates.
enum iotc_bsp_io_fs_resource_type_e iotc_bsp_io_fs_resource_type_t
The resource type of TLS certificates.
intptr_t iotc_bsp_io_fs_resource_handle_t
A pointer to an open file.
enum iotc_bsp_io_fs_open_flags iotc_bsp_io_fs_open_flags_t
The file operations.
The file can't be removed.
Something went wrong.
size_t resource_size
The size, in bytes, of the resource.
iotc_bsp_io_fs_resource_type_e
iotc_bsp_io_fs_state_t iotc_bsp_io_fs_remove(const char *const resource_name)
Deletes a file.
Can't write data to file.
A TLS certificate resource.
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_e
The size of TLS server authentication certificates.
Open and read the file.
The file management function succeeded.
iotc_bsp_io_fs_open_flags
A parameter is invalid.
The device is out of memory.
Open and append to the file.
Open and write to the file.
The file is read-only so the SDK can't open it.
iotc_bsp_io_fs_state_t iotc_bsp_io_fs_close(const iotc_bsp_io_fs_resource_handle_t resource_handle)