File system abstraction layer (POSIX) More...
#include <string.h>
#include "fs_port.h"
#include "fs_port_posix.h"
#include "str.h"
#include "path.h"
#include "error.h"
#include "debug.h"
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Go to the source code of this file.
Functions | |
error_t | fsInit (void) |
File system initialization. More... | |
bool_t | fsFileExists (const char_t *path) |
Check whether a file exists. More... | |
error_t | fsGetFileSize (const char_t *path, uint32_t *size) |
Retrieve the size of the specified file. More... | |
error_t | fsGetFileStat (const char_t *path, FsFileStat *fileStat) |
Retrieve the attributes of the specified file. More... | |
error_t | fsRenameFile (const char_t *oldPath, const char_t *newPath) |
Rename the specified file. More... | |
error_t | fsDeleteFile (const char_t *path) |
Delete a file. More... | |
FsFile * | fsOpenFile (const char_t *path, uint_t mode) |
Open the specified file for reading or writing. More... | |
error_t | fsSeekFile (FsFile *file, int_t offset, uint_t origin) |
Move to specified position in file. More... | |
error_t | fsWriteFile (FsFile *file, void *data, size_t length) |
Write data to the specified file. More... | |
error_t | fsReadFile (FsFile *file, void *data, size_t size, size_t *length) |
Read data from the specified file. More... | |
void | fsCloseFile (FsFile *file) |
Close a file. More... | |
bool_t | fsDirExists (const char_t *path) |
Check whether a directory exists. More... | |
error_t | fsCreateDir (const char_t *path) |
Create a directory. More... | |
error_t | fsRemoveDir (const char_t *path) |
Remove a directory. More... | |
FsDir * | fsOpenDir (const char_t *path) |
Open a directory stream. More... | |
error_t | fsReadDir (FsDir *dir, FsDirEntry *dirEntry) |
Read an entry from the specified directory stream. More... | |
void | fsCloseDir (FsDir *dir) |
Close a directory stream. More... | |
Detailed Description
File system abstraction layer (POSIX)
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.4.4
Definition in file fs_port_posix.c.
Function Documentation
◆ fsCloseDir()
void fsCloseDir | ( | FsDir * | dir | ) |
Close a directory stream.
- Parameters
-
[in] dir Handle that identifies the directory to be closed
Definition at line 683 of file fs_port_posix.c.
◆ fsCloseFile()
void fsCloseFile | ( | FsFile * | file | ) |
Close a file.
- Parameters
-
[in] file Handle that identifies the file to be closed
Definition at line 425 of file fs_port_posix.c.
◆ fsCreateDir()
Create a directory.
- Parameters
-
[in] path NULL-terminated string specifying the directory path
- Returns
- Error code
Definition at line 475 of file fs_port_posix.c.
◆ fsDeleteFile()
Delete a file.
- Parameters
-
[in] path NULL-terminated string specifying the filename
- Returns
- Error code
Definition at line 220 of file fs_port_posix.c.
◆ fsDirExists()
Check whether a directory exists.
- Parameters
-
[in] path NULL-terminated string specifying the directory path
- Returns
- The function returns TRUE if the directory exists. Otherwise FALSE is returned
Definition at line 442 of file fs_port_posix.c.
◆ fsFileExists()
Check whether a file exists.
- Parameters
-
[in] path NULL-terminated string specifying the filename
- Returns
- The function returns TRUE if the file exists. Otherwise FALSE is returned
Definition at line 66 of file fs_port_posix.c.
◆ fsGetFileSize()
Retrieve the size of the specified file.
- Parameters
-
[in] path NULL-terminated string specifying the filename [out] size Size of the file in bytes
- Returns
- Error code
Definition at line 104 of file fs_port_posix.c.
◆ fsGetFileStat()
error_t fsGetFileStat | ( | const char_t * | path, |
FsFileStat * | fileStat | ||
) |
Retrieve the attributes of the specified file.
- Parameters
-
[in] path NULL-terminated string specifying the filename [out] fileStat File attributes
- Returns
- Error code
Definition at line 135 of file fs_port_posix.c.
◆ fsInit()
error_t fsInit | ( | void | ) |
◆ fsOpenDir()
Open a directory stream.
- Parameters
-
[in] path NULL-terminated string specifying the directory path
- Returns
- Directory handle
Definition at line 549 of file fs_port_posix.c.
◆ fsOpenFile()
Open the specified file for reading or writing.
- Parameters
-
[in] path NULL-terminated string specifying the filename [in] mode Type of access permitted (FS_FILE_MODE_READ, FS_FILE_MODE_WRITE or FS_FILE_MODE_CREATE)
- Returns
- File handle
Definition at line 255 of file fs_port_posix.c.
◆ fsReadDir()
error_t fsReadDir | ( | FsDir * | dir, |
FsDirEntry * | dirEntry | ||
) |
Read an entry from the specified directory stream.
- Parameters
-
[in] dir Handle that identifies the directory [out] dirEntry Pointer to a directory entry
- Returns
- Error code
Definition at line 599 of file fs_port_posix.c.
◆ fsReadFile()
Read data from the specified file.
- Parameters
-
[in] file Handle that identifies the file to be read [in] data Pointer to the buffer where to copy the data [in] size Size of the buffer, in bytes [out] length Number of data bytes that have been read
- Returns
- Error code
Definition at line 383 of file fs_port_posix.c.
◆ fsRemoveDir()
Remove a directory.
- Parameters
-
[in] path NULL-terminated string specifying the directory path
- Returns
- Error code
Definition at line 512 of file fs_port_posix.c.
◆ fsRenameFile()
Rename the specified file.
- Parameters
-
[in] oldPath NULL-terminated string specifying the pathname of the file to be renamed [in] newPath NULL-terminated string specifying the new filename
- Returns
- Error code
Definition at line 187 of file fs_port_posix.c.
◆ fsSeekFile()
Move to specified position in file.
- Parameters
-
[in] file Handle that identifies the file [in] offset Number of bytes to move from origin [in] origin Position used as reference for the offset (FS_SEEK_SET, FS_SEEK_CUR or FS_SEEK_END)
- Returns
- Error code
Definition at line 293 of file fs_port_posix.c.
◆ fsWriteFile()
Write data to the specified file.
- Parameters
-
[in] file Handle that identifies the file to be written [in] data Pointer to a buffer containing the data to be written [in] length Number of data bytes to write
- Returns
- Error code
Definition at line 345 of file fs_port_posix.c.