theCore C++ embedded framework
ecl::fat::file Class Reference

FATFS file descriptor. More...

#include </home/travis/build/forGGe/theCore/lib/fs/fat/export/ecl/fat/file.hpp>

Inheritance diagram for ecl::fat::file:
Collaboration diagram for ecl::fat::file:

Public Member Functions

 file (const fs::inode_weak &node, FATFS *fs)
 Constructs the FATFS file descriptor. More...
 
 ~file ()
 Closes and destructs the file descriptor. More...
 
err read (uint8_t *buf, size_t &size) override
 Reads data from a file to a buffer with given size. More...
 
err write (const uint8_t *buf, size_t &size) override
 Writes data to a file from buffer with given size. More...
 
err seek (off_t offt, fs::seekdir whence=fs::seekdir::beg) override
 Sets the file offset to a given value. More...
 
err tell (off_t &offt) override
 Gets current file offset. More...
 
err close () override
 Closes the file descriptor. More...
 
fileoperator= (file &)=delete
 
 file (const file &)=delete
 
- Public Member Functions inherited from ecl::fs::file_descriptor
 file_descriptor (const inode_weak &node)
 Constructs the file descriptor from given weak pointer to inode. More...
 
virtual ~file_descriptor ()
 Closes and destructs the file descriptor. More...
 

Additional Inherited Members

- Protected Attributes inherited from ecl::fs::file_descriptor
inode_ptr m_inode
 Associated inode. More...
 

Detailed Description

FATFS file descriptor.

Constructor & Destructor Documentation

◆ file() [1/2]

file::file ( const fs::inode_weak node,
FATFS *  fs 
)

Constructs the FATFS file descriptor.

Parameters
[in]nodeWeak smart pointer to the respective file inode.
[in]fsPetite FATFS object.

◆ ~file()

file::~file ( )

Closes and destructs the file descriptor.

◆ file() [2/2]

ecl::fat::file::file ( const file )
delete

Member Function Documentation

◆ read()

ecl::err file::read ( uint8_t *  buf,
size_t &  size 
)
overridevirtual

Reads data from a file to a buffer with given size.

Precondition
Valid and opened file descriptor.

Current read/write offset is advanced to an amount of bytes read.

Parameters
[in]bufBuffer to store data into. Must not be NULL.
[in,out]sizeSize of a buffer on entry, bytes read from a file on exit. In case of returned values is less than provided one, it means the read pointer has reached end of the file during read operation.
Returns
Status of operation.
Return values
err::notsupOperation is not supported on a given filesystem.

Implements ecl::fs::file_descriptor.

◆ write()

ecl::err file::write ( const uint8_t *  buf,
size_t &  size 
)
overridevirtual

Writes data to a file from buffer with given size.

Precondition
Valid and opened file descriptor.

Current read/write offset is advanced to an amount of bytes written.

Parameters
[in]bufBuffer to copy data from. Must not be NULL.
[in,out]sizeSize of a buffer on entry, bytes written to a file on exit.
Returns
Status of operation.
Return values
err::notsupOperation is not supported on a given filesystem.

Implements ecl::fs::file_descriptor.

◆ seek()

ecl::err file::seek ( off_t  offt,
fs::seekdir  whence = fs::seekdir::beg 
)
overridevirtual

Sets the file offset to a given value.

Precondition
Valid and opened file descriptor.
Parameters
[in]offtNew offset value.
[in]whenceDirects how to change offset:
  • If set to seekdir::beg, the file offset shall be set to offset bytes.
  • If set to seekdir::cur, the file offset shall be set to its current location plus offset.
  • If set to is seekdir::end, the file offset shall be set to the size of the file plus offset.
Returns
Status of operation.
Return values
err::notsupOperation is not supported on a given filesystem.

Implements ecl::fs::file_descriptor.

◆ tell()

ecl::err file::tell ( off_t &  offt)
overridevirtual

Gets current file offset.

Precondition
Valid and opened file descriptor.
Parameters
[out]offtParameter to store offset into.
Returns
Status of operation.
Return values
err::notsupOperation is not supported on a given filesystem.

Implements ecl::fs::file_descriptor.

◆ close()

ecl::err file::close ( )
overridevirtual

Closes the file descriptor.

Precondition
Valid and opened file descriptor.
Postcondition
File descriptor is closed.
Returns
Status of operation.

Implements ecl::fs::file_descriptor.

◆ operator=()

file& ecl::fat::file::operator= ( file )
delete

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