Storage::FileDevice Class Reference

Read-only partition on a stream object. More...

#include <FileDevice.h>

Inheritance diagram for Storage::FileDevice:
[legend]
Collaboration diagram for Storage::FileDevice:
[legend]

Public Member Functions

 FileDevice (const String &name, IFS::IFileSystem &fileSys, IFS::FileHandle file, size_t size)
 
 FileDevice (const String &name, IFS::IFileSystem &fileSys, IFS::FileHandle file)
 
 ~FileDevice ()
 
String getName () const override
 Obtain unique device name. More...
 
Type getType () const override
 Obtain device type. More...
 
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 (uint32_t address, void *buffer, size_t len) override
 Read data from the storage device. More...
 
bool write (uint32_t address, const void *data, size_t len) override
 Write data to the storage device. More...
 
bool erase_range (uint32_t address, size_t len) override
 Erase a region of storage in preparation for writing. More...
 
- Public Member Functions inherited from Storage::CustomDevice
Partition createPartition (const Partition::Info &info)
 
Partition createPartition (const String &name, Partition::Type type, uint8_t subtype, uint32_t offset, size_t size, Partition::Flags flags=0)
 
template<typename SubType >
Partition createPartition (const String &name, SubType subtype, uint32_t offset, size_t size, Partition::Flags flags=0)
 
- Public Member Functions inherited from Storage::Device
 Device ()
 
 ~Device ()
 
bool operator== (const String &name) const
 
PartitionTablepartitions ()
 
const PartitionTablepartitions () const
 
bool loadPartitions (uint32_t tableOffset)
 Load partition table entries 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...
 
- Public Member Functions inherited from LinkedObjectTemplate< Device >
Device * getNext () const
 
Iterator begin () const
 
Iterator end () const
 
Iterator cbegin () const
 
Iterator cend () const
 
- Public Member Functions inherited from LinkedObject
virtual ~LinkedObject ()
 
virtual LinkedObjectnext () const
 
LinkedObjectgetNext () const
 
bool operator== (const LinkedObject &other) const
 
bool operator!= (const LinkedObject &other) const
 

Additional Inherited Members

- Public Types inherited from Storage::Device
enum  Type : uint8_t { Type::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 &>
 
- Protected Attributes inherited from Storage::Device
PartitionTable mPartitions
 

Detailed Description

Read-only partition on a stream object.

Note
Writes not possible as streams always append data, cannot do random writes

Constructor & Destructor Documentation

◆ FileDevice() [1/2]

Storage::FileDevice::FileDevice ( const String name,
IFS::IFileSystem fileSys,
IFS::FileHandle  file,
size_t  size 
)
inline

◆ FileDevice() [2/2]

Storage::FileDevice::FileDevice ( const String name,
IFS::IFileSystem fileSys,
IFS::FileHandle  file 
)
inline

◆ ~FileDevice()

Storage::FileDevice::~FileDevice ( )
inline

Member Function Documentation

◆ erase_range()

bool Storage::FileDevice::erase_range ( uint32_t  address,
size_t  size 
)
overridevirtual

Erase a region of storage in preparation for writing.

Parameters
addressWhere to start erasing
sizeSize of region to erase, in bytes
Return values
booltrue on success, false on error

Implements Storage::Device.

◆ getBlockSize()

size_t Storage::FileDevice::getBlockSize ( ) const
inlineoverridevirtual

Obtain smallest allocation unit for erase operations.

Implements Storage::Device.

◆ getName()

String Storage::FileDevice::getName ( ) const
inlineoverridevirtual

Obtain unique device name.

Implements Storage::Device.

◆ getSize()

size_t Storage::FileDevice::getSize ( ) const
inlineoverridevirtual

Obtain addressable size of this device.

Return values
size_tMust be at least as large as the value declared in the partition table

Implements Storage::Device.

◆ getType()

Type Storage::FileDevice::getType ( ) const
inlineoverridevirtual

Obtain device type.

Implements Storage::Device.

◆ read()

bool Storage::FileDevice::read ( uint32_t  address,
void *  dst,
size_t  size 
)
overridevirtual

Read data from the storage device.

Parameters
addressWhere to start reading
dstBuffer to store data
sizeSize of data to be read, in bytes.
Return values
booltrue on success, false on error

Implements Storage::Device.

◆ write()

bool Storage::FileDevice::write ( uint32_t  address,
const void *  src,
size_t  size 
)
overridevirtual

Write data to the storage device.

Parameters
addressWhere to start writing
srcData to write
sizeSize of data to be written, in bytes.
Return values
booltrue on success, false on error

Implements Storage::Device.


The documentation for this class was generated from the following file: