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-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_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 error_t fsGetFileAttr(const char_t *path, uint32_t *attributes,
70  uint32_t *size, DateTime *modified);
71 
72 bool_t fsFileExists(const char_t *path);
73 error_t fsGetFileSize(const char_t *path, uint32_t *size);
74 error_t fsRenameFile(const char_t *oldPath, const char_t *newPath);
75 error_t fsDeleteFile(const char_t *path);
76 
77 FsFile *fsOpenFile(const char_t *path, uint_t mode);
78 error_t fsSeekFile(FsFile *file, int_t offset, uint_t origin);
79 error_t fsWriteFile(FsFile *file, void *data, size_t length);
80 error_t fsReadFile(FsFile *file, void *data, size_t size, size_t *length);
81 void fsCloseFile(FsFile *file);
82 
83 bool_t fsDirExists(const char_t *path);
84 error_t fsCreateDir(const char_t *path);
85 error_t fsRemoveDir(const char_t *path);
86 
87 FsDir *fsOpenDir(const char_t *path);
88 error_t fsReadDir(FsDir *dir, FsDirEntry *dirEntry);
89 void fsCloseDir(FsDir *dir);
90 
91 //C++ guard
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #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
void * handle
Definition: fs_port_posix.h:61
error_t fsGetFileAttr(const char_t *path, uint32_t *attributes, uint32_t *size, DateTime *modified)
Retrieve the attributes of the specified file.
Definition: fs_port_posix.c:62
FsFile * fsOpenFile(const char_t *path, uint_t mode)
Open the specified file for reading or writing.
bool_t fsDirExists(const char_t *path)
Check whether a directory exists.
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:59
FsDir * fsOpenDir(const char_t *path)
Open a directory stream.
error_t
Error codes.
Definition: error.h:42
error_t fsInit(void)
File system initialization.
error_t fsDeleteFile(const char_t *path)
Delete a file.
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.
Date and time representation.
Definition: date_time.h:46
void FsFile
File descriptor.
Definition: fs_port_posix.h:52
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:43
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:95
uint8_t file[128]
Definition: dhcp_common.h:213
uint8_t mode
Definition: ntp_common.h:149
unsigned int uint_t
Definition: compiler_port.h:45
uint8_t data[]
Definition: dtls_misc.h:176
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