ion_file.h
Go to the documentation of this file.
1 /******************************************************************************/
36 /******************************************************************************/
37 
38 #if !defined(ION_FILE_H_)
39 #define ION_FILE_H_
40 
41 #if defined(__cplusplus)
42 extern "C" {
43 #endif
44 
45 #include "../key_value/kv_system.h"
46 
47 typedef long ion_file_offset_t;
48 
49 #define ION_FILE_START SEEK_SET
50 #define ION_FILE_END SEEK_END
51 
52 #if defined(ARDUINO)
53 
54 #include "sd_stdio_c_iface.h"
55 
56 #define ION_NOFILE \
57  ((ion_file_handle_t) { NULL, -1 } \
58  )
59 
60 typedef struct file_handle {
61  SD_FILE *file;
63 
64 #else /* Clause ARDUINO */
65 
66 #include "stdio.h"
67 #include "unistd.h"
68 
69 typedef FILE *ion_file_handle_t;
70 
71 #define ION_NOFILE ((ion_file_handle_t) (NULL))
72 
73 #endif /* Clause ARDUINO */
74 
75 #define ION_FILE_NULL -1
76 
79  char *name
80 );
81 
82 ion_file_handle_t
83 ion_fopen(
84  char *name
85 );
86 
89  ion_file_handle_t file
90 );
91 
94  char *name
95 );
96 
98 ion_fseek(
99  ion_file_handle_t file,
100  ion_file_offset_t seek_to,
101  int origin
102 );
103 
104 ion_file_offset_t
105 ion_ftell(
106  ion_file_handle_t file
107 );
108 
109 ion_file_offset_t
110 ion_fend(
111  ion_file_handle_t file
112 );
113 
114 ion_err_t
115 ion_fwrite(
116  ion_file_handle_t file,
117  unsigned int num_bytes,
118  ion_byte_t *to_write
119 );
120 
121 ion_err_t
123  ion_file_handle_t file,
124  ion_file_offset_t offset,
125  unsigned int num_bytes,
126  ion_byte_t *to_write
127 );
128 
129 ion_err_t
130 ion_fread(
131  ion_file_handle_t file,
132  unsigned int num_bytes,
133  ion_byte_t *write_to
134 );
135 
136 ion_err_t
138  ion_file_handle_t file,
139  ion_file_offset_t offset,
140  unsigned int num_bytes,
141  ion_byte_t *write_to
142 );
143 
144 #if defined(__cplusplus)
145 }
146 #endif
147 
148 #endif
unsigned char ion_byte_t
A byte type.
Definition: kv_system.h:232
ion_err_t ion_fread(ion_file_handle_t file, unsigned int num_bytes, ion_byte_t *write_to)
Definition: ion_file.c:214
ion_err_t ion_fseek(ion_file_handle_t file, ion_file_offset_t seek_to, int origin)
Definition: ion_file.c:109
ion_err_t ion_fwrite(ion_file_handle_t file, unsigned int num_bytes, ion_byte_t *to_write)
Definition: ion_file.c:158
This code contains definitions for stdio.h file functions for Arduino flash libraries.
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
FILE * ion_file_handle_t
Definition: ion_file.h:69
ion_err_t ion_fremove(char *name)
Definition: ion_file.c:93
ion_file_offset_t ion_ftell(ion_file_handle_t file)
Definition: ion_file.c:132
ion_boolean_t ion_fexists(char *name)
Definition: ion_file.c:40
ion_err_t ion_fclose(ion_file_handle_t file)
Definition: ion_file.c:80
long ion_file_offset_t
Definition: ion_file.h:47
ion_file_handle_t ion_fopen(char *name)
Definition: ion_file.c:51
ion_err_t ion_fwrite_at(ion_file_handle_t file, ion_file_offset_t offset, unsigned int num_bytes, ion_byte_t *to_write)
Definition: ion_file.c:177
ion_err_t ion_fread_at(ion_file_handle_t file, ion_file_offset_t offset, unsigned int num_bytes, ion_byte_t *write_to)
Definition: ion_file.c:237
char ion_boolean_t
A boolean type.
Definition: kv_system.h:269
ion_file_offset_t ion_fend(ion_file_handle_t file)
Definition: ion_file.c:143