Members | Descriptions |
---|---|
class Arduino_UnifiedStorage |
Abstract class representing the common features of the supported storage methods |
class Folder |
Class representing a directory. |
class InternalStorage |
Represents internal storage using the Arduino Unified Storage library. |
class Partitioning |
|
class SDStorage |
Represents an SD card storage using the Arduino Unified Storage library. |
class UFile |
Class representing a File |
class USBStorage |
USBStorage class provides an interface to access USB storage devices. It inherits from the Arduino_UnifiedStorage class and implements its pure virtual functions. |
struct Partition |
Abstract class representing the common features of the supported storage methods
Members | Descriptions |
---|---|
begin |
Initializes the storage. |
begin |
Initializes the storage with the specified file system. |
unmount |
Unmounts the storage. |
getRootFolder |
Retrieves the root folder of the storage. |
format |
Formats the storage with the selected file system. |
debugPrint |
|
testPrint |
bool begin()
Initializes the storage.
true if successful, false if failed.
bool begin(FileSystems fs)
Initializes the storage with the specified file system.
fs
The desired file system (FS_FAT or FS_LITTLEFS).
true if successful, false if failed.
bool unmount()
Unmounts the storage.
true if successful, false if failed.
Folder getRootFolder()
Retrieves the root folder of the storage.
The root folder as a Folder object.
bool format(FileSystems fs)
Formats the storage with the selected file system.
true if successful, false if failed.
static void debugPrint(String message)
static void testPrint(String message)
Class representing a directory.
Members | Descriptions |
---|---|
Folder |
Creates an empty Folder object. Please note that any operation on this object will fail until a valid directory is assigned to it. |
Folder |
Creates a directory with the specified name. If the directory already exists, it returns a Folder object representing the existing directory. Otherwise, it tries to create a new directory with the specified name. If it fails the path property of the Folder object will be null. |
Folder |
Creates a directory with the specified name. If the directory already exists, it returns a Folder object representing the existing directory. Otherwise, it tries to create a new directory with the specified name. If it fails the path property of the Folder object will be empty. |
createFile |
Creates a file inside the directory. |
createFile |
Creates a file inside the directory. |
remove |
Removes a directory. |
rename |
Renames a directory. |
rename |
Renames a directory. |
exists |
Checks if the directory exists. |
getPath |
Returns the path of the file. |
getPathAsString |
Returns the path of the file. |
createSubfolder |
Creates a subfolder in the directory. |
createSubfolder |
Creates a subfolder in the directory. |
getFiles |
Returns File objects for all files in the current directory. |
getFolders |
Returns Folder objects for all files in the current directory. |
copyTo |
Copies the current directory. |
copyTo |
Copies the current directory. |
copyTo |
Copies the current directory. |
moveTo |
Moves the current directory. |
moveTo |
Moves the current directory. |
moveTo |
Move the current directory. |
Folder()
Creates an empty Folder object. Please note that any operation on this object will fail until a valid directory is assigned to it.
Folder(const char * dirname)
Creates a directory with the specified name. If the directory already exists, it returns a Folder object representing the existing directory. Otherwise, it tries to create a new directory with the specified name. If it fails the path
property of the Folder object will be null.
const
char * dirname - The name of the directory.
Folder(String dirname)
Creates a directory with the specified name. If the directory already exists, it returns a Folder object representing the existing directory. Otherwise, it tries to create a new directory with the specified name. If it fails the path
property of the Folder object will be empty.
String
dirname - The name of the directory.
UFile createFile(const char * fileName, FileMode fmode)
Creates a file inside the directory.
const
char * fileName - The name of the file to create.
A File object if successful, NULL if not.
UFile createFile(String fileName, FileMode fmode)
Creates a file inside the directory.
String
fileName - The name of the file to create.
A File object if successful, NULL if not.
bool remove()
Removes a directory.
True if the directory was removed successfully, false otherwise.
bool rename(const char * newDirname)
Renames a directory.
const
char * newDirname The new name of the directory.
True if the directory was renamed successfully, false otherwise.
bool rename(String newDirname)
Renames a directory.
String
newDirname The new name of the directory.
True if the directory was renamed successfully, false otherwise.
bool exists()
Checks if the directory exists.
True if the directory exists, false otherwise.
const char * getPath()
Returns the path of the file.
The path of the file as a const char *
String getPathAsString()
Returns the path of the file.
The path of the file as an Arduino String
Folder createSubfolder(const char * subfolderName, bool overwrite)
Creates a subfolder in the directory.
-
const
char * subfolderName - he name of the subfolder to create. -
overwrite
- behaviour in case the folder already exists, default is false
The created subfolder.
Folder createSubfolder(String subfolderName, bool overwrite)
Creates a subfolder in the directory.
-
String
subfolderName - he name of the subfolder to create. -
overwrite
- behaviour in case the folder already exists, default is false
The created subfolder.
std::vector< UFile > getFiles()
Returns File objects for all files in the current directory.
A std::vector of File objects representing the files in the directory.
std::vector< Folder > getFolders()
Returns Folder objects for all files in the current directory.
A std::vector of Folder objects representing the files in the directory.
bool copyTo( Folder destination, bool overwrite)
Copies the current directory.
[Folder](#class_folder)
destination - a Folder object representing the destination
True upon success, false otherwise.
bool copyTo(const char * destination, bool overwrite)
Copies the current directory.
-
const
char * destination - the path of the destination location -
overwrite
- behaviour in case the folder already exists, default is false
True upon success, false otherwise.
bool copyTo(String destination, bool overwrite)
Copies the current directory.
-
String
destination - the path of the destination location -
overwrite
- behaviour in case the folder already exists, default is false
True upon success, false otherwise.
bool moveTo( Folder destination, bool overwrite)
Moves the current directory.
-
[Folder](#class_folder)
destination - a Folder object representing the destination -
overwrite
- behaviour in case the folder already exists, default is false
True upon success, false otherwise.
bool moveTo(const char * destination, bool overwrite)
Moves the current directory.
-
const
char * destination - the path of the destination location -
overwrite
- behaviour in case the folder already exists, default is false
True upon success, false otherwise.
bool moveTo(String destination, bool overwrite)
Move the current directory.
-
String
destination - the path of the destination location -
overwrite
- behaviour in case the folder already exists, default is false
True upon success, false otherwise.
class InternalStorage
: public Arduino_UnifiedStorage
Represents internal storage using the Arduino Unified Storage library.
Members | Descriptions |
---|---|
InternalStorage |
Constructs an InternalStorage object with default settings. If no partitions are available, it restores the default partitioning scheme (See restoreDefaultPartitions() for more info). If partitions are available, it sets the partition number, file system type, and partition name based on the last partition available. When using the default partitioning scheme the last partition would be the user partition. |
InternalStorage |
Constructs an InternalStorage object with the specified partition, name, and file system. |
begin |
Initializes the internal storage. |
begin |
Initializes the internal storage with the specified file system. |
unmount |
Unmounts the internal storage. |
getRootFolder |
Retrieves the root folder of the internal storage. |
format |
Formats the internal storage with the selected file system. |
getBlockDevice |
Retrieves the block device associated with the internal storage. |
partition |
Partitions the internal storage according to the partitioning scheme given in the partitions parameter erasing the existing partitions |
partition |
Creates one partition spanning over the whole size of the internal storage drive erasing the existing partitions. |
restoreDefaultPartitions |
Restores the default partitioning scheme (1MB FAT32 for Certificates, 5MB FAT32 for OTA, 8MB user storage) to the internal storage drive erasing the existing partitions. |
readPartitions |
Reads the partitioning scheme from the MBR sector of the internal storage drive and returns a vector of structs of type Partition that represents the partitioning scheme |
InternalStorage()
Constructs an InternalStorage object with default settings. If no partitions are available, it restores the default partitioning scheme (See restoreDefaultPartitions() for more info). If partitions are available, it sets the partition number, file system type, and partition name based on the last partition available. When using the default partitioning scheme the last partition would be the user partition.
InternalStorage(int partition, const char * name, FileSystems fs)
Constructs an InternalStorage object with the specified partition, name, and file system.
-
partition
The partition number. -
name
The name of the partition. -
fs
The desired file system (FS_FAT or FS_LITTLEFS).
virtual bool begin()
Initializes the internal storage.
true if successful, false if failed.
virtual bool begin(FileSystems fs)
Initializes the internal storage with the specified file system.
fs
The desired file system (FS_FAT or FS_LITTLEFS).
true if successful, false if failed.
virtual bool unmount()
Unmounts the internal storage.
true if successful, false if failed.
virtual Folder getRootFolder()
Retrieves the root folder of the internal storage.
The root folder as a Folder object.
virtual bool format(FileSystems fs)
Formats the internal storage with the selected file system.
true if successful, false if failed.
BlockDeviceType * getBlockDevice()
Retrieves the block device associated with the internal storage.
The block device as a BlockDevice object.
static bool partition(std::vector< Partition > partitions)
Partitions the internal storage according to the partitioning scheme given in the partitions
parameter erasing the existing partitions
partitions
- vector of structs of type Partition that represents the partitioning scheme
true if successful, false if failed.
static bool partition()
Creates one partition spanning over the whole size of the internal storage drive erasing the existing partitions.
true if successful, false if failed.
static bool restoreDefaultPartitions()
Restores the default partitioning scheme (1MB FAT32 for Certificates, 5MB FAT32 for OTA, 8MB user storage) to the internal storage drive erasing the existing partitions.
true if successful, false if failed.
static std::vector< Partition > readPartitions()
Reads the partitioning scheme from the MBR sector of the internal storage drive and returns a vector of structs of type Partition that represents the partitioning scheme
vector of structs of type Partition
Members | Descriptions |
---|---|
eraseMBRSector |
Erases the first block (4096 bytes) of the BlockDevice to delete any already existing MBR partition table |
partitionDrive |
Partitions the BlockDevice according to the partitioning schemme given by the vector of Partition structs |
readPartitions |
Reads and unpacks the MBR partition information and returns a list of partitions it can find on the drive |
static bool eraseMBRSector(BlockDeviceType * blockDevice)
Erases the first block (4096 bytes) of the BlockDevice to delete any already existing MBR partition table
The
BlockDevice on which the MBR sector is situated.
True upon success, False on failure
static bool partitionDrive(BlockDeviceType * blockDevice, std::vector< Partition > partitions)
Partitions the BlockDevice according to the partitioning schemme given by the vector of Partition structs
-
blockDevice
- the BlockDevice which we would like to partition. -
partitions
- a vector of Partition structs that represents the partitioning scheme
True upon success, False on failure
static std::vector< Partition > readPartitions(BlockDeviceType * blockDevice)
Reads and unpacks the MBR partition information and returns a list of partitions it can find on the drive
blockDevice
on which the MBR sector is situated.
std::vector of Partition containing size and filesystem information about each partition
class SDStorage
: public Arduino_UnifiedStorage
Represents an SD card storage using the Arduino Unified Storage library.
Members | Descriptions |
---|---|
SDStorage |
Default constructor for the SDStorage class. |
begin |
Initializes the SD card storage. |
begin |
Initializes the SD card storage with the specified file system. |
unmount |
Unmounts the SD card storage. |
getRootFolder |
Retrieves the root folder of the SD card storage. |
format |
Formats the SD card storage with the selected file system. |
SDStorage()
Default constructor for the SDStorage class.
virtual bool begin()
Initializes the SD card storage.
true if successful, false if failed.
virtual bool begin(FileSystems fs)
Initializes the SD card storage with the specified file system.
fs
The desired file system (FS_FAT or FS_LITTLEFS).
true if successful, false if failed.
virtual bool unmount()
Unmounts the SD card storage.
true if successful, false if failed.
virtual Folder getRootFolder()
Retrieves the root folder of the SD card storage.
The root folder as a Folder object.
virtual bool format(FileSystems fs)
Formats the SD card storage with the selected file system.
true if successful, false if failed.
Class representing a File
Members | Descriptions |
---|---|
UFile |
Constructor. |
UFile |
Constructor. |
~UFile |
|
changeMode |
Closes the file, and opens it again with a new file mode. |
open |
Opens a file with the specified mode. |
open |
Opens a file with the specified mode. |
close |
Closes the file and releases any allocated resources. |
seek |
Seeks to a specific position in the file. |
read |
Reads data from the file into a buffer. |
readAsString |
Reads the contents of the file as an Arduino String. |
write |
Writes data to the file from a buffer. |
write |
Writes a string to the file. |
remove |
Removes the file. |
rename |
Renames the file. |
rename |
Renames the file. |
exists |
Checks if the file exists. |
copyTo |
Copies the file to the specified destination path. |
copyTo |
Copies the file to the specified destination path. |
copyTo |
Copies the file to the specified destination path. |
moveTo |
Moves the file to the specified destination path. |
moveTo |
Moves the file to the specified destination path. |
moveTo |
Copies the file to the specified destination folder. |
getParentFolder |
Returns a reference to the parent folder of the current folder. |
getPath |
Returns the path of the directory. |
getPathAsString |
Returns the path of the directory. |
available |
Returns the number of bytes available to read. |
read |
Returns one byte from the file. |
write |
Writes one byte to the file. |
UFile()
Constructor.
UFile(const char * path)
Constructor.
const
char * path - path of the file
~UFile()
bool changeMode(FileMode mode)
Closes the file, and opens it again with a new file mode.
mode
The file mode (READ, WRITE, or APPEND).
True if operation was successful, false otherwise.
bool open(const char * filename, FileMode mode)
Opens a file with the specified mode.
-
const
char * filename - The name of the file to open. -
mode
The file mode (READ, WRITE, or APPEND).
True if the file was opened successfully, false otherwise.
bool open(String filename, FileMode mode)
Opens a file with the specified mode.
-
String
filename - The name of the file to open. -
mode
The file mode (READ, WRITE, or APPEND).
True if the file was opened successfully, false otherwise.
void close()
Closes the file and releases any allocated resources.
bool seek(size_t offset)
Seeks to a specific position in the file.
offset
The offset from the beginning of the file.
True if the seek operation was successful, false otherwise.
size_t read(uint8_t * buffer, size_t size)
Reads data from the file into a buffer.
-
buffer
The buffer to read data into. -
size
The size of the buffer.
The number of bytes read from the file.
String readAsString()
Reads the contents of the file as an Arduino String.
The file contents as a String.
size_t write(const uint8_t * buffer, size_t size)
Writes data to the file from a buffer.
-
buffer
The buffer containing the data to write. -
size
The size of the data to write.
The number of bytes written to the file.
size_t write(String)
Writes a string to the file.
data
The string to write.
The number of bytes written to the file.
bool remove()
Removes the file.
True if the file was removed successfully, false otherwise.
bool rename(const char * newFilename)
Renames the file.
const
char * newFilename The new name of the file.
True if the file was renamed successfully, false otherwise.
bool rename(String newFilename)
Renames the file.
String
newFilename The new name of the file.
True if the file was renamed successfully, false otherwise.
bool exists()
Checks if the file exists.
True if the file exists, false otherwise.
bool copyTo(const char * destinationPath, bool overwrite)
Copies the file to the specified destination path.
const
char * destinationPath - The destination path to copy the file to.
True upon success, false otherwise.
bool copyTo(String destinationPath, bool overwrite)
Copies the file to the specified destination path.
String
destinationPath The destination path to copy the file to.
True upon success, false otherwise.
bool copyTo( Folder destinationFolder, bool overwrite)
Copies the file to the specified destination path.
[Folder](#class_folder)
destinationPath - The destination folder to copy the file to.
True upon success, false otherwise.
bool moveTo(const char * destinationPath, bool overwrite)
Moves the file to the specified destination path.
const
char * destinationPath The destination path to move the file to.
True upon success, false otherwise.
bool moveTo(String destinationPath, bool overwrite)
Moves the file to the specified destination path.
String
destinationPath The destination path to move the file to.
True upon success, false otherwise.
bool moveTo( Folder destinationFolder, bool overwrite)
Copies the file to the specified destination folder.
[Folder](#class_folder)
destinationFolder The destination directory to move the file to.
True upon success, false otherwise.
Folder getParentFolder()
Returns a reference to the parent folder of the current folder.
A directory object representing the current folder.
const char * getPath()
Returns the path of the directory.
The path of the file as a const char *
String getPathAsString()
Returns the path of the directory.
The path of the file as a String
uint32_t available()
Returns the number of bytes available to read.
The number of bytes available to read as int
int read()
Returns one byte from the file.
An int representing one byte from the file
size_t write(uint8_t value)
Writes one byte to the file.
a
uint8_t value representing the byte to write
class USBStorage
: public Arduino_UnifiedStorage
USBStorage class provides an interface to access USB storage devices. It inherits from the Arduino_UnifiedStorage class and implements its pure virtual functions.
Members | Descriptions |
---|---|
USBStorage |
Default constructor for the USBStorage class. |
begin |
Initializes the USB storage. |
begin |
Initializes the USB storage with the specified file system. |
unmount |
Unmounts the USB storage. |
getRootFolder |
Retrieves the root folder of the USB storage. |
format |
Formats the USB storage with the selected file system. |
isMounted |
Checks if the USB storage is mounted. |
onConnect |
Sets the callback function to be called when a USB connection is established. |
removeOnConnectCallback |
Removes the callback function that is executed when the USB storage device is connected. |
onDisconnect |
Sets a callback function to be called when the USB storage device is disconnected. |
removeOnDisconnectCallback |
Removes the callback function that is called when the USB storage device is disconnected. |
USBStorage()
Default constructor for the USBStorage class.
virtual bool begin()
Initializes the USB storage.
true if successful, false if failed.
virtual bool begin(FileSystems fs)
Initializes the USB storage with the specified file system.
fs
The desired file system (FS_FAT or FS_LITTLEFS).
true if successful, false if failed.
virtual bool unmount()
Unmounts the USB storage.
true if successful, false if failed.
virtual Folder getRootFolder()
Retrieves the root folder of the USB storage.
The root folder as a Folder object.
virtual bool format(FileSystems fs)
Formats the USB storage with the selected file system.
true if successful, false if failed.
bool isMounted()
Checks if the USB storage is mounted.
true if mounted, false otherwise.
void onConnect(void(*)() callbackFunction)
Sets the callback function to be called when a USB connection is established.
callbackFunction
A pointer to the function to be called when a USB connection is established.
void removeOnConnectCallback()
Removes the callback function that is executed when the USB storage device is connected.
void onDisconnect(void(*)() callbackFunction)
Sets a callback function to be called when the USB storage device is disconnected.
callbackFunction
A pointer to the function to be called when the USB storage device is disconnected.
void removeOnDisconnectCallback()
Removes the callback function that is called when the USB storage device is disconnected.
Members | Descriptions |
---|---|
size |
|
fileSystemType |
int size
FileSystems fileSystemType