fs_port_fatfs.h
Go to the documentation of this file.
1 /**
2  * @file fs_port_fatfs.h
3  * @brief File system abstraction layer (FatFs)
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.4
27  **/
28 
29 #ifndef _FS_PORT_FATFS_H
30 #define _FS_PORT_FATFS_H
31 
32 //Dependencies
33 #include "os_port.h"
34 #include "ff.h"
35 
36 //Number of files that can be opened simultaneously
37 #ifndef FS_MAX_FILES
38  #define FS_MAX_FILES 8
39 #elif (FS_MAX_FILES < 1)
40  #error FS_MAX_FILES parameter is not valid
41 #endif
42 
43 //Number of directories that can be opened simultaneously
44 #ifndef FS_MAX_DIRS
45  #define FS_MAX_DIRS 8
46 #elif (FS_MAX_DIRS < 1)
47  #error FS_MAX_DIRS parameter is not valid
48 #endif
49 
50 //C++ guard
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 
56 /**
57  * @brief File descriptor
58  **/
59 
60 typedef void FsFile;
61 
62 
63 /**
64  * @brief Directory descriptor
65  **/
66 
67 typedef void FsDir;
68 
69 
70 //File system abstraction layer
71 error_t fsInit(void);
72 
73 bool_t fsFileExists(const char_t *path);
74 error_t fsGetFileSize(const char_t *path, uint32_t *size);
75 error_t fsGetFileStat(const char_t *path, FsFileStat *fileStat);
76 error_t fsRenameFile(const char_t *oldPath, const char_t *newPath);
77 error_t fsDeleteFile(const char_t *path);
78 
79 FsFile *fsOpenFile(const char_t *path, uint_t mode);
80 error_t fsSeekFile(FsFile *file, int_t offset, uint_t origin);
81 error_t fsWriteFile(FsFile *file, void *data, size_t length);
82 error_t fsReadFile(FsFile *file, void *data, size_t size, size_t *length);
83 void fsCloseFile(FsFile *file);
84 
85 bool_t fsDirExists(const char_t *path);
86 error_t fsCreateDir(const char_t *path);
87 error_t fsRemoveDir(const char_t *path);
88 
89 FsDir *fsOpenDir(const char_t *path);
90 error_t fsReadDir(FsDir *dir, FsDirEntry *dirEntry);
91 void fsCloseDir(FsDir *dir);
92 
93 //C++ guard
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif
int bool_t
Definition: compiler_port.h:53
signed int int_t
Definition: compiler_port.h:49
bool_t fsDirExists(const char_t *path)
Check whether a directory exists.
uint8_t data[]
Definition: ethernet.h:222
void fsCloseFile(FsFile *file)
Close a file.
bool_t fsFileExists(const char_t *path)
Check whether a file exists.
error_t fsReadDir(FsDir *dir, FsDirEntry *dirEntry)
Read an entry from the specified directory stream.
Directory descriptor.
Definition: fs_port_posix.h:60
error_t fsDeleteFile(const char_t *path)
Delete a file.
error_t
Error codes.
Definition: error.h:43
void fsCloseDir(FsDir *dir)
Close a directory stream.
error_t fsRemoveDir(const char_t *path)
Remove a directory.
error_t fsCreateDir(const char_t *path)
Create a directory.
File status.
Definition: fs_port.h:96
error_t fsReadFile(FsFile *file, void *data, size_t size, size_t *length)
Read data from the specified file.
uint8_t length
Definition: tcp.h:368
error_t fsRenameFile(const char_t *oldPath, const char_t *newPath)
Rename the specified file.
error_t fsWriteFile(FsFile *file, void *data, size_t length)
Write data to the specified file.
char char_t
Definition: compiler_port.h:48
void FsDir
Directory descriptor.
Definition: fs_port_fatfs.h:67
error_t fsGetFileSize(const char_t *path, uint32_t *size)
Retrieve the size of the specified file.
error_t fsInit(void)
File system initialization.
Directory entry.
Definition: fs_port.h:108
FsDir * fsOpenDir(const char_t *path)
Open a directory stream.
uint8_t file[128]
Definition: dhcp_common.h:223
error_t fsSeekFile(FsFile *file, int_t offset, uint_t origin)
Move to specified position in file.
FsFile * fsOpenFile(const char_t *path, uint_t mode)
Open the specified file for reading or writing.
unsigned int uint_t
Definition: compiler_port.h:50
error_t fsGetFileStat(const char_t *path, FsFileStat *fileStat)
Retrieve the attributes of the specified file.
RTOS abstraction layer.
void FsFile
File descriptor.
Definition: fs_port_fatfs.h:60