Storage::FileDevice Class Reference
Create custom storage device using backing file. More...
#include <FileDevice.h>
Inheritance diagram for Storage::FileDevice:
Collaboration diagram for Storage::FileDevice:
Public Member Functions | |
FileDevice (const String &name, IFS::IFileSystem &fileSys, IFS::FileHandle file, storage_size_t size) | |
Construct a file device with custom size. More... | |
FileDevice (const String &name, IFS::IFileSystem &fileSys, IFS::FileHandle file) | |
Construct a device using existing file. More... | |
~FileDevice () | |
String | getName () const override |
Obtain unique device name. More... | |
Type | getType () const override |
Obtain device type. More... | |
storage_size_t | getSize () const override |
Obtain addressable size of this device. More... | |
size_t | getBlockSize () const override |
Obtain smallest allocation unit for erase operations. More... | |
bool | read (storage_size_t address, void *buffer, size_t len) override |
Read data from the storage device. More... | |
bool | write (storage_size_t address, const void *data, size_t len) override |
Write data to the storage device. More... | |
bool | erase_range (storage_size_t address, storage_size_t len) override |
Erase a region of storage in preparation for writing. More... | |
Public Member Functions inherited from Storage::Device | |
Device () | |
~Device () | |
bool | operator== (const String &name) const |
const PartitionTable & | partitions () const |
Provide read-only access to partition table. More... | |
PartitionTable & | editablePartitions () |
Provide full access to partition table. More... | |
bool | loadPartitions (uint32_t tableOffset) |
Load partition table entries @tableOffset Location of partition table to read. More... | |
bool | loadPartitions (Device &source, uint32_t tableOffset) |
Load partition table entries from another table. More... | |
virtual uint32_t | getId () const |
Obtain device ID. More... | |
virtual uint16_t | getSectorSize () const |
Get sector size, the unit of allocation for block-access devices. More... | |
virtual storage_size_t | getSectorCount () const |
Obtain total number of sectors on this device. More... | |
virtual bool | sync () |
Flush any pending writes to the physical media. More... | |
size_t | printTo (Print &p) const |
Public Member Functions inherited from LinkedObjectTemplate< Device > | |
Device * | getNext () const |
bool | insertAfter (Device *object) |
Iterator | begin () const |
Iterator | end () const |
Iterator | cbegin () const |
Iterator | cend () const |
Public Member Functions inherited from LinkedObject | |
virtual | ~LinkedObject () |
virtual LinkedObject * | next () const |
bool | insertAfter (LinkedObject *object) |
bool | operator== (const LinkedObject &other) const |
bool | operator!= (const LinkedObject &other) const |
Additional Inherited Members | |
Public Types inherited from Storage::Device | |
enum class | Type : uint8_t { partitionType = uint8_t(Partition::Type::storage) , XX } |
Storage type. More... | |
using | List = LinkedObjectListTemplate< Device > |
using | OwnedList = OwnedLinkedObjectListTemplate< Device > |
Public Types inherited from LinkedObjectTemplate< Device > | |
using | Iterator = IteratorTemplate< Device, Device *, Device & > |
using | ConstIterator = IteratorTemplate< const Device, const Device *, const Device & > |
Static Public Attributes inherited from Storage::Device | |
static constexpr uint16_t | defaultSectorSize {512} |
Protected Attributes inherited from Storage::Device | |
PartitionTable | mPartitions |
Detailed Description
Create custom storage device using backing file.
Constructor & Destructor Documentation
◆ FileDevice() [1/2]
|
inline |
Construct a file device with custom size.
- Parameters
-
name Name of device fileSys File system where file is located file Handle to open file size Size of device in bytes
◆ FileDevice() [2/2]
|
inline |
Construct a device using existing file.
- Parameters
-
name Name of device fileSys File system where file is located file Handle to open file
Device will match size of existing file
◆ ~FileDevice()
|
inline |
Member Function Documentation
◆ erase_range()
|
overridevirtual |
Erase a region of storage in preparation for writing.
- Parameters
-
address Where to start erasing size Size of region to erase, in bytes
- Return values
-
bool true on success, false on error
Implements Storage::Device.
◆ getBlockSize()
|
inlineoverridevirtual |
Obtain smallest allocation unit for erase operations.
Implements Storage::Device.
◆ getName()
|
inlineoverridevirtual |
Obtain unique device name.
Implements Storage::Device.
◆ getSize()
|
inlineoverridevirtual |
Obtain addressable size of this device.
- Return values
-
storage_size_t Must be at least as large as the value declared in the hardware configuration
Implements Storage::Device.
◆ getType()
|
inlineoverridevirtual |
Obtain device type.
Implements Storage::Device.
◆ read()
|
overridevirtual |
Read data from the storage device.
- Parameters
-
address Where to start reading dst Buffer to store data size Size of data to be read, in bytes.
- Return values
-
bool true on success, false on error
Implements Storage::Device.
◆ write()
|
overridevirtual |
Write data to the storage device.
- Parameters
-
address Where to start writing src Data to write size Size of data to be written, in bytes.
- Return values
-
bool true on success, false on error
Implements Storage::Device.
The documentation for this class was generated from the following file: