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-2019 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 1.9.6
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 fsRenameFile(const char_t *oldPath, const char_t *newPath);
76 error_t fsDeleteFile(const char_t *path);
77 
78 FsFile *fsOpenFile(const char_t *path, uint_t mode);
79 error_t fsSeekFile(FsFile *file, int_t offset, uint_t origin);
80 error_t fsWriteFile(FsFile *file, void *data, size_t length);
81 error_t fsReadFile(FsFile *file, void *data, size_t size, size_t *length);
82 void fsCloseFile(FsFile *file);
83 
84 bool_t fsDirExists(const char_t *path);
85 error_t fsCreateDir(const char_t *path);
86 error_t fsRemoveDir(const char_t *path);
87 
88 FsDir *fsOpenDir(const char_t *path);
89 error_t fsReadDir(FsDir *dir, FsDirEntry *dirEntry);
90 void fsCloseDir(FsDir *dir);
91 
92 //C++ guard
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif
uint8_t length
Definition: dtls_misc.h:149
int bool_t
Definition: compiler_port.h:49
signed int int_t
Definition: compiler_port.h:44
bool_t fsDirExists(const char_t *path)
Check whether a directory exists.
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:59
error_t fsDeleteFile(const char_t *path)
Delete a file.
error_t
Error codes.
Definition: error.h:42
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.
error_t fsReadFile(FsFile *file, void *data, size_t size, size_t *length)
Read data from the specified file.
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:43
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:95
FsDir * fsOpenDir(const char_t *path)
Open a directory stream.
uint8_t file[128]
Definition: dhcp_common.h:213
error_t fsSeekFile(FsFile *file, int_t offset, uint_t origin)
Move to specified position in file.
uint8_t mode
Definition: ntp_common.h:149
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:45
uint8_t data[]
Definition: dtls_misc.h:176
RTOS abstraction layer.
void FsFile
File descriptor.
Definition: fs_port_fatfs.h:60