mikroSDK Reference Manual
file_system.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2024 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
48extern "C"{
49#endif
50
51#include "physical_drive.h"
52#include "cstdio.h"
53#include "assembly.h"
54
55#define NOP() assembly(nop)
56
75#define FS_MAX_VOLUMES ((uint8_t)5)
76
82#define FS_MAX_OBJECTS ((uint8_t)10)
83
84 // file_system_config_group
85
96#define FSS_OK ((uint8_t)0)
97
101#define FSS_GENERAL_ERROR ((uint8_t)1)
102
106#define FSS_DRIVE_FULL ((uint8_t)2)
107
111#define FSS_END_OF_FILE ((uint8_t)3)
112
116#define FSS_END_OF_DIRECTORY ((uint8_t)4)
117
121#define FSS_NOT_IMPLEMENTED ((uint8_t)5)
122
123 // file_system_status_group
124
125
140#define FS_FILE_READ 0x01
141
145#define FS_FILE_WRITE 0x02
146
150#define FS_FILE_OPEN_EXISTING 0x00
151
155#define FS_FILE_CREATE_NEW 0x04
156
160#define FS_FILE_CREATE_ALWAYS 0x08
161
165#define FS_FILE_OPEN_ALWAYS 0x10
166
170#define FS_FILE_OPEN_APPEND 0x30
171
172 // file_flags_group
173
174
181typedef int8_t fs_status_t;
182
183
193
200typedef void * fs_file_t;
201
202
209typedef void * fs_dir_t;
210
220
221
230
253
254 // logical_drive_group
255
256
282fs_status_t file_system_format(const char * __generic_ptr path);
283
317fs_status_t file_system_mount(logical_drive_t * const ldrive_base, const char * __generic_ptr path, physical_drive_t * const pdrive_base);
318
344fs_status_t file_system_unmount(const char * __generic_ptr path);
345
365fs_status_t file_system_remove(const char * __generic_ptr path);
366
391fs_status_t file_system_rename(const char * __generic_ptr old_path, const char * __generic_ptr new_path);
392
411fs_status_t file_system_mkdir(const char * __generic_ptr path);
412
413 // file_system_management_group
414
427#ifdef __cplusplus
428}
429#endif
430
431#endif // !_FILE_SYSTEM_H_
fs_file_rw_pointer_t
: file_seek API Starting Offset
Definition file_system.h:188
@ SEEK_END
Definition file_system.h:191
@ SEEK_CURRENT
Definition file_system.h:190
@ SEEK_START
Definition file_system.h:189
logical_drive_type_t
Logical Drive File System Type Enumerator.
Definition file_system.h:226
@ FS_TYPE_FATFS
Definition file_system.h:228
@ FS_TYPE_UNINITIALIZED
Definition file_system.h:227
void * fs_file_t
: File data specific to a particular file system.
Definition file_system.h:200
void * fs_dir_t
: Directory Data specific to a particular File System.
Definition file_system.h:209
int8_t fs_status_t
: File System API return value
Definition file_system.h:181
fs_status_t file_system_mkdir(const char *__generic_ptr path)
Make new Directory.
fs_status_t file_system_remove(const char *__generic_ptr path)
Removes a File or a Directory.
fs_status_t file_system_format(const char *__generic_ptr path)
Format the Logical Drive.
fs_status_t file_system_unmount(const char *__generic_ptr path)
Unmount Logical Drive from the File System.
fs_status_t file_system_rename(const char *__generic_ptr old_path, const char *__generic_ptr new_path)
Renames a File or a Directory.
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.
Logical Drive Base Data Structure.
Definition file_system.h:246
logical_drive_type_t type
Definition file_system.h:248
uint8_t volume_id
Definition file_system.h:249
uint8_t object_count
Definition file_system.h:250
uint8_t error
Definition file_system.h:251
logical_drive_vector_table_t * vtptr
Definition file_system.h:247
Logical Drive Vector Table.
Definition fs_common.h:73
Physical Drive Base Data Structure Reference.
Definition physical_drive.h:127