mikroSDK Reference Manual
file_system.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2023 MikroElektronika d.o.o.
4 ** Contact: https://www.mikroe.com/contact
5 **
6 ** This file is part of the mikroSDK package
7 **
8 ** Commercial License Usage
9 **
10 ** Licensees holding valid commercial NECTO compilers AI licenses may use this
11 ** file in accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The MikroElektronika Company.
14 ** For licensing terms and conditions see
15 ** https://www.mikroe.com/legal/software-license-agreement.
16 ** For further information use the contact form at
17 ** https://www.mikroe.com/contact.
18 **
19 **
20 ** GNU Lesser General Public License Usage
21 **
22 ** Alternatively, this file may be used for
23 ** non-commercial projects under the terms of the GNU Lesser
24 ** General Public License version 3 as published by the Free Software
25 ** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26 **
27 ** The above copyright notice and this permission notice shall be
28 ** included in all copies or substantial portions of the Software.
29 **
30 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 ** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32 ** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 **
38 ****************************************************************************/
44 #ifndef _FILE_SYSTEM_H_
45 #define _FILE_SYSTEM_H_
46 
47 #ifdef __cplusplus
48 extern "C"{
49 #endif
50 
51 #include "physical_drive.h"
52 #include "cstdio.h"
53 
54 #ifdef __GNUC__
55 #define NOP() asm ("nop")
56 #else
57 #define NOP() asm nop
58 #endif
59 
78 #define FS_MAX_VOLUMES ((uint8_t)5)
79 
85 #define FS_MAX_OBJECTS ((uint8_t)10)
86  // file_system_config_group
88 
99 #define FSS_OK ((uint8_t)0)
100 
104 #define FSS_GENERAL_ERROR ((uint8_t)1)
105 
109 #define FSS_DRIVE_FULL ((uint8_t)2)
110 
114 #define FSS_END_OF_FILE ((uint8_t)3)
115 
119 #define FSS_END_OF_DIRECTORY ((uint8_t)4)
120 
124 #define FSS_NOT_IMPLEMENTED ((uint8_t)5)
125  // file_system_status_group
127 
128 
143 #define FS_FILE_READ 0x01
144 
148 #define FS_FILE_WRITE 0x02
149 
153 #define FS_FILE_OPEN_EXISTING 0x00
154 
158 #define FS_FILE_CREATE_NEW 0x04
159 
163 #define FS_FILE_CREATE_ALWAYS 0x08
164 
168 #define FS_FILE_OPEN_ALWAYS 0x10
169 
173 #define FS_FILE_OPEN_APPEND 0x30
174  // file_flags_group
176 
177 
184 typedef int8_t fs_status_t;
185 
186 
191 typedef enum {
194  SEEK_END,
196 
203 typedef void * fs_file_t;
204 
205 
212 typedef void * fs_dir_t;
213 
223 
224 
229 typedef enum {
233 
249 typedef struct {
252  uint8_t volume_id;
253  uint8_t object_count;
254  uint8_t error;
256  // logical_drive_group
258 
259 
285 fs_status_t file_system_format(const char * __generic_ptr path);
286 
320 fs_status_t file_system_mount(logical_drive_t * const ldrive_base, const char * __generic_ptr path, physical_drive_t * const pdrive_base);
321 
347 fs_status_t file_system_unmount(const char * __generic_ptr path);
348 
368 fs_status_t file_system_remove(const char * __generic_ptr path);
369 
394 fs_status_t file_system_rename(const char * __generic_ptr old_path, const char * __generic_ptr new_path);
395 
414 fs_status_t file_system_mkdir(const char * __generic_ptr path);
415  // file_system_management_group
417 
430 #ifdef __cplusplus
431 }
432 #endif
433 
434 #endif // !_FILE_SYSTEM_H_
fs_file_rw_pointer_t
fs_file_rw_pointer_t
: file_seek API Starting Offset
Definition: file_system.h:190
FS_TYPE_FATFS
Definition: file_system.h:230
file_system_mkdir
fs_status_t file_system_mkdir(const char *__generic_ptr path)
Make new Directory.
FS_TYPE_UNINITIALIZED
Definition: file_system.h:229
SEEK_CURRENT
Definition: file_system.h:192
physical_drive_t
Physical Drive Base Data Structure Reference.
Definition: physical_drive.h:127
file_system_format
fs_status_t file_system_format(const char *__generic_ptr path)
Format the Logical Drive.
fs_status_t
int8_t fs_status_t
: File System API return value
Definition: file_system.h:183
fs_dir_t
void * fs_dir_t
: Directory Data specific to a particular File System.
Definition: file_system.h:211
logical_drive_type_t
logical_drive_type_t
Logical Drive File System Type Enumerator.
Definition: file_system.h:228
file_system_rename
fs_status_t file_system_rename(const char *__generic_ptr old_path, const char *__generic_ptr new_path)
Renames a File or a Directory.
logical_drive_vector_table
Logical Drive Vector Table.
Definition: fs_common.h:72
logical_drive_t
Logical Drive Base Data Structure.
Definition: file_system.h:248
SEEK_END
Definition: file_system.h:193
file_system_mount
fs_status_t file_system_mount(logical_drive_t *const ldrive_base, const char *__generic_ptr path, physical_drive_t *const pdrive_base)
Mount Logical Drive to the File System.
fs_file_t
void * fs_file_t
: File data specific to a particular file system.
Definition: file_system.h:202
file_system_remove
fs_status_t file_system_remove(const char *__generic_ptr path)
Removes a File or a Directory.
file_system_unmount
fs_status_t file_system_unmount(const char *__generic_ptr path)
Unmount Logical Drive from the File System.
SEEK_START
Definition: file_system.h:191