PAL file system - platform. This file contains the file system APIs that need to be implemented in the platform layer. More...
#include "pal_fileSystem.h"
Go to the source code of this file.
Functions | |
palStatus_t | pal_plat_fsMkdir (const char *pathName) |
This function attempts to create a directory named pathName . More... | |
palStatus_t | pal_plat_fsRmdir (const char *pathName) |
This function deletes a directory. More... | |
palStatus_t | pal_plat_fsFopen (const char *pathName, pal_fsFileMode_t mode, palFileDescriptor_t *fd) |
This function opens the file whose name is specified in the parameter pathName and associates it with a stream that can be identified in future operations by the fd pointer returned. More... | |
palStatus_t | pal_plat_fsFclose (palFileDescriptor_t *fd) |
This function closes an open file object. More... | |
palStatus_t | pal_plat_fsFread (palFileDescriptor_t *fd, void *buffer, size_t numOfBytes, size_t *numberOfBytesRead) |
This function reads an array of bytes from the stream and stores them in the block of memory specified by the buffer. More... | |
palStatus_t | pal_plat_fsFwrite (palFileDescriptor_t *fd, const void *buffer, size_t numOfBytes, size_t *numberOfBytesWritten) |
This function starts to write data from the buffer to the file at the position pointed by the read/write pointer. More... | |
palStatus_t | pal_plat_fsFseek (palFileDescriptor_t *fd, off_t offset, pal_fsOffset_t whence) |
This function moves the file read/write pointer without any read/write operation to the file. More... | |
palStatus_t | pal_plat_fsFtell (palFileDescriptor_t *fd, off_t *pos) |
This function gets the current read/write pointer of a file. More... | |
palStatus_t | pal_plat_fsUnlink (const char *pathName) |
This function deletes a single file from the file system. More... | |
palStatus_t | pal_plat_fsRmFiles (const char *pathName) |
This function deletes all files in a folder from the file system (FLAT remove only). More... | |
palStatus_t | pal_plat_fsCpFolder (const char *pathNameSrc, char *pathNameDest) |
This function copies all files from a source folder to a destination folder (FLAT copy only). More... | |
const char * | pal_plat_fsGetDefaultRootFolder (pal_fsStorageID_t dataID) |
This function gets the default value for the root directory. More... | |
size_t | pal_plat_fsSizeCheck (const char *stringToChk) |
This function finds the length of the string received. More... | |
palStatus_t | pal_plat_fsFormat (pal_fsStorageID_t dataID) |
This function formats the chosen SD partition. More... | |
PAL file system - platform. This file contains the file system APIs that need to be implemented in the platform layer.
g_esfsRootFolder
to all files and folders. To change this, call pal_plat_fsSetEsfsRootFolder()
. palStatus_t pal_plat_fsCpFolder | ( | const char * | pathNameSrc, |
char * | pathNameDest | ||
) |
This function copies all files from a source folder to a destination folder (FLAT copy only).
[in] | pathNameSrc | A pointer to a null-terminated string that specifies the source folder. |
[in] | pathNameDest | A pointer to a null-terminated string that specifies the destination folder. The destination folder MUST exist. |
palError_t
.palStatus_t pal_plat_fsFclose | ( | palFileDescriptor_t * | fd | ) |
This function closes an open file object.
[in] | fd | A pointer to the open file object structure to be closed. |
palError_t
.palStatus_t pal_plat_fsFopen | ( | const char * | pathName, |
pal_fsFileMode_t | mode, | ||
palFileDescriptor_t * | fd | ||
) |
This function opens the file whose name is specified in the parameter pathName
and associates it with a stream that can be identified in future operations by the fd
pointer returned.
[out] | fd | A file descriptor for the file entered in the pathName . |
[in] | *pathName | A pointer to the null-terminated string that specifies the file name to open or create. |
[in] | mode | A mode flag that specifies the type of access and open method for the file. |
palError_t
.pal_plat_fclose()
frees that buffer. pal_fsFileMode_t
and each platform needs to replace them with the proper values. palStatus_t pal_plat_fsFormat | ( | pal_fsStorageID_t | dataID | ) |
This function formats the chosen SD partition.
Mapping the ID to an actual partition is done in the porting layer.
[in] | dataID | The ID of the partition to be formatted. |
palError_t
. palStatus_t pal_plat_fsFread | ( | palFileDescriptor_t * | fd, |
void * | buffer, | ||
size_t | numOfBytes, | ||
size_t * | numberOfBytesRead | ||
) |
This function reads an array of bytes from the stream and stores them in the block of memory specified by the buffer.
The position indicator of the stream is advanced by the total amount of bytes read.
[in] | fd | A pointer to the open file object structure. |
[in] | buffer | A buffer for storing the read data. |
[in] | numOfBytes | The number of bytes to read. |
[out] | numberOfBytesRead | The number of bytes read. |
palError_t
.numberOfBytesRead
should be checked to detect end of the file. If numberOfBytesRead
is less than numOfBytes
, the read/write pointer has reached the end of the file during the read operation or an error has occurred. palStatus_t pal_plat_fsFseek | ( | palFileDescriptor_t * | fd, |
off_t | offset, | ||
pal_fsOffset_t | whence | ||
) |
This function moves the file read/write pointer without any read/write operation to the file.
[in] | fd | A pointer to the open file object structure. |
[in] | offset | The byte offset from whence to set the read/write pointer. |
[out] | whence | The offset is relative to this. |
whence
options are:PAL_ERR_FS_SEEKSET
- relative to the start of the file.PAL_ERR_FS_SEEKCUR
- relative to the current position indicator.PAL_ERR_FS_SEEKEND
- relative to the end-of-file.whence
argument. If you need to implement the whence
argument:fseek()
needs to verify that the offset is smaller than the file end or start.palError_t
. palStatus_t pal_plat_fsFtell | ( | palFileDescriptor_t * | fd, |
off_t * | pos | ||
) |
This function gets the current read/write pointer of a file.
[in] | fd | A pointer to the open file object structure. |
[out] | pos | A pointer to a variable that receives the current file position. |
palError_t
. palStatus_t pal_plat_fsFwrite | ( | palFileDescriptor_t * | fd, |
const void * | buffer, | ||
size_t | numOfBytes, | ||
size_t * | numberOfBytesWritten | ||
) |
This function starts to write data from the buffer
to the file at the position pointed by the read/write pointer.
[in] | fd | A pointer to the open file object structure. |
[in] | buffer | A pointer to the data to be written. |
[in] | numOfBytes | The number of bytes to write. |
[out] | numberOfBytesWritten | The number of bytes written. |
palError_t
.numberOfBytesWritten
should be checked to detect if the disk is full. If numberOfBytesWritten
is less than numOfBytes
, the volume became full during the write operation. const char* pal_plat_fsGetDefaultRootFolder | ( | pal_fsStorageID_t | dataID | ) |
This function gets the default value for the root directory.
[in] | dataID | - ID of the data to get the root folder for. |
palStatus_t pal_plat_fsMkdir | ( | const char * | pathName | ) |
This function attempts to create a directory named pathName
.
[in] | *pathName | A pointer to the null-terminated string that specifies the directory name to create. |
palError_t
.PAL_ERR_FS_rmdir
.Example
palStatus_t pal_plat_fsRmdir | ( | const char * | pathName | ) |
This function deletes a directory.
[in] | *pathName | A pointer to the null-terminated string that specifies the name of the directory to be deleted. |
palError_t
...
, the function changes the root directory to one directory down and deletes the working directory. palStatus_t pal_plat_fsRmFiles | ( | const char * | pathName | ) |
This function deletes all files in a folder from the file system (FLAT remove only).
[in] | pathName | A pointer to a null-terminated string that specifies the folder. |
palError_t
./
. pal_plat_fsUnlink
until all files are removed. size_t pal_plat_fsSizeCheck | ( | const char * | stringToChk | ) |
This function finds the length of the string received.
[in] | stringToChk | A pointer to the string received with a null terminator. |
palStatus_t pal_plat_fsUnlink | ( | const char * | pathName | ) |
This function deletes a single file from the file system.
[in] | pathName | A pointer to a null-terminated string that specifies the file to be removed. |
palError_t
.