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

Abstract class holding metadata about the file in the filesystem. More...

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

Inheritance diagram for ecl::fs::inode:
Collaboration diagram for ecl::fs::inode:

Public Types

enum  type { type::file = 0, type::dir = 1 }
 Possible filesystem entity types. More...
 

Public Member Functions

 inode ()
 Constructs inode. More...
 
virtual ~inode ()
 Destroys inode. More...
 
virtual inode::type get_type () const =0
 Gets type of entity, represented by the curent inode. More...
 
virtual file_ptr open ()
 Returns the file descriptor, if this inode represents file. More...
 
virtual dir_ptr open_dir ()
 Returns the descriptor associated with this directory. More...
 
virtual err size (size_t &sz) const =0
 Returns size of a file or number of entries in the directory. More...
 
virtual err get_name (char *buf, size_t &buf_sz) const =0
 Gets a name of an entity. More...
 
void set_weak (const fs::inode_ptr &ptr)
 Assigns weak reference to the inode. More...
 

Protected Attributes

fs::inode_weak my_ptr
 Weak self-pointer. More...
 

Detailed Description

Abstract class holding metadata about the file in the filesystem.

Member Enumeration Documentation

◆ type

enum ecl::fs::inode::type
strong

Possible filesystem entity types.

Enumerator
file 

File entity.

dir 

Dir entity.

Constructor & Destructor Documentation

◆ inode()

inode::inode ( )

Constructs inode.

◆ ~inode()

inode::~inode ( )
virtual

Destroys inode.

Member Function Documentation

◆ get_type()

virtual inode::type ecl::fs::inode::get_type ( ) const
pure virtual

Gets type of entity, represented by the curent inode.

Returns
Type of the entity.

Implemented in ecl::fat::dir_inode, and ecl::fat::file_inode.

◆ open()

file_ptr inode::open ( )
virtual

Returns the file descriptor, if this inode represents file.

Precondition
inode representing file entity.

Meaningless if used on the dir inode.

Returns
Pointer to file descriptor.

Reimplemented in ecl::fat::file_inode.

◆ open_dir()

dir_ptr inode::open_dir ( )
virtual

Returns the descriptor associated with this directory.

Precondition
inode representing dir entity.

Meaningless if used on file inode.

Returns
Pointer to dir descriptor.

Reimplemented in ecl::fat::dir_inode.

◆ size()

virtual err ecl::fs::inode::size ( size_t &  sz) const
pure virtual

Returns size of a file or number of entries in the directory.

Parameters
[out]szParameter to store either file size (if this inode represents a file) or count of etries in the directory (if this inode represents a dir).
Returns
Status of operation.

Implemented in ecl::fat::dir_inode, and ecl::fat::file_inode.

◆ get_name()

virtual err ecl::fs::inode::get_name ( char *  buf,
size_t &  buf_sz 
) const
pure virtual

Gets a name of an entity.

Parameters
[in]bufBuffer to store name to.
[in,out]buf_szOn entry: size of a buffer. On exit: bytes written excluding null character. If truncation occur then it will store amount of bytes that would have been written if enough space had been avaliable.
Returns
Status of operation.

Implemented in ecl::fat::dir_inode, and ecl::fat::file_inode.

◆ set_weak()

void inode::set_weak ( const fs::inode_ptr ptr)

Assigns weak reference to the inode.

Every file or dir descriptor is associated with inode. To simplify memory management, descriptors holds a smart pointer to inode. But descriptor creation is managed inside the same inode, which reference should be passed to the descriptor. Thus, self-reference is required. Setting weak reference helps avoid cyclic dependency. It then can be passed to descriptors in open() and open_dir() methods.

Here is the call graph for this function:

Field Documentation

◆ my_ptr

fs::inode_weak ecl::fs::inode::my_ptr
protected

Weak self-pointer.


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