theCore C++ embedded framework
ecl::fs::file_descriptor Class Referenceabstract

Abstract file descriptor. More...

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

Inheritance diagram for ecl::fs::file_descriptor:
Collaboration diagram for ecl::fs::file_descriptor:

Public Member Functions

 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...
 
virtual err read (uint8_t *buf, size_t &size)=0
 Reads data from a file to a buffer with given size. More...
 
virtual err write (const uint8_t *buf, size_t &size)=0
 Writes data to a file from buffer with given size. More...
 
virtual err seek (off_t offt, seekdir whence=seekdir::beg)=0
 Sets the file offset to a given value. More...
 
virtual err tell (off_t &offt)=0
 Gets current file offset. More...
 
virtual err close ()=0
 Closes the file descriptor. More...
 

Protected Attributes

inode_ptr m_inode
 Associated inode. More...
 

Detailed Description

Abstract file descriptor.

Constructor & Destructor Documentation

◆ file_descriptor()

file_descriptor::file_descriptor ( const inode_weak node)

Constructs the file descriptor from given weak pointer to inode.

Constructing the file descriptor acts as file opening.

Parameters
[in]nodeWeak smart pointer to the respective file inode.
Here is the call graph for this function:

◆ ~file_descriptor()

file_descriptor::~file_descriptor ( )
virtual

Closes and destructs the file descriptor.

Member Function Documentation

◆ read()

virtual err ecl::fs::file_descriptor::read ( uint8_t *  buf,
size_t &  size 
)
pure virtual

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.

Implemented in ecl::fat::file.

◆ write()

virtual err ecl::fs::file_descriptor::write ( const uint8_t *  buf,
size_t &  size 
)
pure virtual

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.

Implemented in ecl::fat::file.

◆ seek()

virtual err ecl::fs::file_descriptor::seek ( off_t  offt,
seekdir  whence = seekdir::beg 
)
pure virtual

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.

Implemented in ecl::fat::file.

◆ tell()

virtual err ecl::fs::file_descriptor::tell ( off_t &  offt)
pure virtual

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.

Implemented in ecl::fat::file.

◆ close()

virtual err ecl::fs::file_descriptor::close ( )
pure virtual

Closes the file descriptor.

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

Implemented in ecl::fat::file.

Field Documentation

◆ m_inode

inode_ptr ecl::fs::file_descriptor::m_inode
protected

Associated inode.


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