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