Core/FileSystem.h File Reference
#include <IFS/Helpers.h>
#include <IFS/File.h>
#include <IFS/Directory.h>
#include <spiffs_sming.h>
#include "WVector.h"
Include dependency graph for Core/FileSystem.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  File
 
class  Directory
 Directory stream class. More...
 

Namespaces

 SmingInternal
 

Macros

#define CHECK_FS(_method)
 

Typedefs

using file_t = IFS::FileHandle
 < More...
 
typedef SeekOrigin SeekOriginFlags
 
using FileHandle = IFS::FileHandle
 
using DirHandle = IFS::DirHandle
 
using FileOpenFlag = IFS::OpenFlag
 
using FileOpenFlags = IFS::OpenFlags
 
using FileAttribute = IFS::FileAttribute
 
using FileAttributes = IFS::FileAttributes
 
using FileStat = IFS::Stat
 
using FileNameStat = IFS::NameStat
 

Functions

IFS::FileSystemgetFileSystem ()
 Get the currently active file system, if any. More...
 
void fileSetFileSystem (IFS::IFileSystem *fileSystem)
 Sets the currently active file system. More...
 
void fileFreeFileSystem ()
 
bool spiffs_mount ()
 Mount the first available SPIFFS volume. More...
 
bool spiffs_mount (Storage::Partition partition)
 Mount SPIFFS volume from a specific partition. More...
 
bool fwfs_mount ()
 Mount the first available FWFS volume. More...
 
bool fwfs_mount (Storage::Partition partition)
 Mount SPIFFS volume from a specific partition. More...
 
bool hyfs_mount ()
 Mount the first available FWFS and SPIFFS partitions as a hybrid filesystem. More...
 
bool hyfs_mount (Storage::Partition fwfsPartition, Storage::Partition spiffsPartition)
 Mount the given FWFS and SPIFFS partitions as a hybrid filesystem. More...
 
file_t fileOpen (const char *name, FileOpenFlags flags=File::ReadOnly)
 Open file. More...
 
file_t fileOpen (const String &name, FileOpenFlags flags=File::ReadOnly)
 
file_t fileOpen (const FileStat &stat, FileOpenFlags flags=File::ReadOnly)
 
int fileClose (file_t file)
 Clode file. More...
 
int fileWrite (file_t file, const void *data, size_t size)
 Write to file. More...
 
int fileTouch (file_t file)
 Update file modification time. More...
 
int fileRead (file_t file, void *data, size_t size)
 Read from file. More...
 
int fileSeek (file_t file, int offset, SeekOrigin origin)
 Position file cursor. More...
 
bool fileIsEOF (file_t file)
 Check if at end of file. More...
 
int fileTell (file_t file)
 Get position in file. More...
 
int fileFlush (file_t file)
 Flush pending writes. More...
 
String fileGetErrorString (int err)
 get the text for a returned error code More...
 
template<typename TFileName >
int fileSetContent (const TFileName &fileName, const char *content, size_t length)
 Create or replace file with defined content. More...
 
template<typename TFileName , typename TContent >
int fileSetContent (const TFileName &fileName, TContent content)
 
template<typename TFileName >
uint32_t fileGetSize (const TFileName &fileName)
 Get size of file. More...
 
int fileTruncate (file_t file, size_t newSize)
 Truncate (reduce) the size of an open file. More...
 
int fileTruncate (file_t file)
 Truncate an open file at the current cursor position. More...
 
template<typename TFileName >
int fileTruncate (const TFileName &fileName, size_t newSize)
 Truncate (reduce) the size of a file. More...
 
int fileRename (const char *oldName, const char *newName)
 Rename file. More...
 
int fileRename (const String &oldName, const String &newName)
 
Vector< StringfileList ()
 Get list of files on file system. More...
 
template<typename TFileName >
String fileGetContent (const TFileName &fileName)
 Read content of a file. More...
 
template<typename TFileName >
size_t fileGetContent (const TFileName &fileName, char *buffer, size_t bufSize)
 Read content of a file. More...
 
template<typename TFileName >
size_t fileGetContent (const TFileName &fileName, char *buffer)
 
int fileStats (const char *fileName, FileStat &stat)
 Get file statistics. More...
 
int fileStats (const String &fileName, FileStat &stat)
 
int fileStats (file_t file, FileStat &stat)
 
int fileDelete (const char *fileName)
 Delete file. More...
 
int fileDelete (const String &fileName)
 
int fileDelete (file_t file)
 Delete file. More...
 
bool fileExist (const char *fileName)
 Check if a file exists on file system. More...
 
bool fileExist (const String &fileName)
 
int fileOpenDir (const char *dirName, DirHandle &dir)
 Open a named directory for reading. More...
 
int fileOpenDir (const String &dirName, DirHandle &dir)
 
int fileOpenRootDir (DirHandle &dir)
 
int fileOpenDir (const FileStat &stat, DirHandle &dir)
 Open a sub-directory for reading. More...
 
int fileCloseDir (DirHandle dir)
 close a directory object More...
 
int fileReadDir (DirHandle dir, FileStat &stat)
 Read a directory entry. More...
 
int fileRewindDir (DirHandle dir)
 Rewind to start of directory entries. More...
 
int fileGetSystemInfo (IFS::IFileSystem::Info &info)
 Get basic file system information. More...
 
IFS::IFileSystem::Type fileSystemType ()
 Get the type of file system currently mounted (if any) More...
 
int fileSystemFormat ()
 Format the active file system. More...
 
int fileSystemCheck ()
 Perform a consistency check/repair on the active file system. More...
 
int fileSetACL (file_t file, const IFS::ACL &acl)
 Set access control information. More...
 
int fileSetTime (file_t file, time_t mtime)
 Set access control information for file. More...
 
Set file attributes
Parameters
filename
attr
Return values
intError code
int fileSetAttr (const char *filename, FileAttributes attr)
 
int fileSetAttr (const String &filename, FileAttributes attr)
 

Variables

constexpr int FS_OK = IFS::FS_OK
 
constexpr SeekOrigin eSO_FileStart {SeekOrigin::Start}
 
constexpr SeekOrigin eSO_CurrentPos {SeekOrigin::Current}
 
constexpr SeekOrigin eSO_FileEnd {SeekOrigin::End}
 
IFS::IFileSystemSmingInternal::activeFileSystem
 Global file system instance. More...
 
constexpr FileOpenFlags eFO_ReadOnly {File::ReadOnly}
 
constexpr FileOpenFlags eFO_WriteOnly {File::WriteOnly}
 
constexpr FileOpenFlags eFO_ReadWrite {File::ReadWrite}
 
constexpr FileOpenFlags eFO_CreateIfNotExist {File::Create}
 
constexpr FileOpenFlags eFO_Append {File::Append}
 
constexpr FileOpenFlags eFO_Truncate {File::Truncate}
 
constexpr FileOpenFlags eFO_CreateNewAlways {File::CreateNewAlways}