fs_port.h
Go to the documentation of this file.
1 /**
2  * @file fs_port.h
3  * @brief File system abstraction layer
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 2.4.0
27  **/
28 
29 #ifndef _FS_PORT_H
30 #define _FS_PORT_H
31 
32 //Dependencies
33 #include "fs_port_config.h"
34 #include "os_port.h"
35 #include "date_time.h"
36 #include "error.h"
37 
38 //Maximum filename length
39 #ifndef FS_MAX_NAME_LEN
40  #define FS_MAX_NAME_LEN 127
41 #elif (FS_MAX_NAME_LEN < 11)
42  #error FS_MAX_NAME_LEN parameter is not valid
43 #endif
44 
45 //C++ guard
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 
51 /**
52  * @brief File attributes
53  **/
54 
55 typedef enum
56 {
64 
65 
66 /**
67  * @brief File access mode
68  **/
69 
70 typedef enum
71 {
77 
78 
79 /**
80  * @brief File seek origin
81  **/
82 
83 typedef enum
84 {
87  FS_SEEK_END = 2
89 
90 
91 /**
92  * @brief File status
93  **/
94 
95 typedef struct
96 {
97  uint32_t attributes;
98  uint32_t size;
100 } FsFileStat;
101 
102 
103 /**
104  * @brief Directory entry
105  **/
106 
107 typedef struct
108 {
109  uint32_t attributes;
110  uint32_t size;
113 } FsDirEntry;
114 
115 
116 //FatFs port?
117 #if defined(USE_FATFS)
118  #include "fs_port_fatfs.h"
119 //Keil RL-FlashFS port?
120 #elif defined(USE_RL_FS)
121  #include "fs_port_rl_fs.h"
122 //SPIFFS port?
123 #elif defined(USE_SPIFFS)
124  #include "fs_port_spiffs.h"
125 //Segger emFile port?
126 #elif defined(USE_EMFILE)
127  #include "fs_port_emfile.h"
128 //Windows port?
129 #elif defined(_WIN32)
130  #include "fs_port_posix.h"
131 //POSIX port?
132 #elif defined(__linux__) || defined(__FreeBSD__)
133  #include "fs_port_posix.h"
134 //Custom port?
135 #elif defined(USE_CUSTOM_FS)
136  #include "fs_port_custom.h"
137 #endif
138 
139 //C++ guard
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif
char char_t
Definition: compiler_port.h:48
Date and time management.
Error codes description.
FsFileMode
File access mode.
Definition: fs_port.h:71
@ FS_FILE_MODE_CREATE
Definition: fs_port.h:74
@ FS_FILE_MODE_READ
Definition: fs_port.h:72
@ FS_FILE_MODE_TRUNC
Definition: fs_port.h:75
@ FS_FILE_MODE_WRITE
Definition: fs_port.h:73
#define FS_MAX_NAME_LEN
Definition: fs_port.h:40
FsFileAttributes
File attributes.
Definition: fs_port.h:56
@ FS_FILE_ATTR_HIDDEN
Definition: fs_port.h:58
@ FS_FILE_ATTR_READ_ONLY
Definition: fs_port.h:57
@ FS_FILE_ATTR_DIRECTORY
Definition: fs_port.h:61
@ FS_FILE_ATTR_ARCHIVE
Definition: fs_port.h:62
@ FS_FILE_ATTR_VOLUME_NAME
Definition: fs_port.h:60
@ FS_FILE_ATTR_SYSTEM
Definition: fs_port.h:59
FsSeekOrigin
File seek origin.
Definition: fs_port.h:84
@ FS_SEEK_END
Definition: fs_port.h:87
@ FS_SEEK_CUR
Definition: fs_port.h:86
@ FS_SEEK_SET
Definition: fs_port.h:85
File system abstraction layer (FatFs)
File system abstraction layer (POSIX)
File system abstraction layer (RL-FlashFS)
RTOS abstraction layer.
char_t name[]
Date and time representation.
Definition: date_time.h:47
Directory entry.
Definition: fs_port.h:108
uint32_t attributes
Definition: fs_port.h:109
uint32_t size
Definition: fs_port.h:110
DateTime modified
Definition: fs_port.h:111
File status.
Definition: fs_port.h:96
uint32_t attributes
Definition: fs_port.h:97
uint32_t size
Definition: fs_port.h:98
DateTime modified
Definition: fs_port.h:99