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