cppfs  1.2.0.5b71c2c98fb9
Cross-platform C++ file system library supporting multiple backends (Local-FS, SSH)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cppfs::LocalFileHandle Class Reference

File handle for the local file system. More...

#include <cppfs/include/cppfs/posix/LocalFileHandle.h>

Inheritance diagram for cppfs::LocalFileHandle:
Inheritance graph
[legend]
Collaboration diagram for cppfs::LocalFileHandle:
Collaboration graph
[legend]

Public Member Functions

 LocalFileHandle (std::shared_ptr< LocalFileSystem > fs, const std::string &path)
 Constructor. More...
 
 LocalFileHandle (std::shared_ptr< LocalFileSystem > fs, std::string &&path)
 Constructor. More...
 
virtual ~LocalFileHandle ()
 Destructor. More...
 
virtual std::unique_ptr< AbstractFileHandleBackendclone () const override
 Create a copy of this handle. More...
 
virtual AbstractFileSystemfs () const override
 Get file system. More...
 
virtual void updateFileInfo () override
 Update file information. More...
 
virtual std::string path () const override
 Get path. More...
 
virtual bool exists () const override
 Check if file or directory exists. More...
 
virtual bool isFile () const override
 Check if item is a file. More...
 
virtual bool isDirectory () const override
 Check if item is a directory. More...
 
virtual bool isSymbolicLink () const override
 Check if item is a symbolic link. More...
 
virtual std::vector< std::string > listFiles () const override
 List files in directory. More...
 
virtual std::unique_ptr< AbstractFileIteratorBackendbegin () const override
 Get iterator that points to the first directory entry. More...
 
virtual unsigned int size () const override
 Get file size. More...
 
virtual unsigned int accessTime () const override
 Get time of last access. More...
 
virtual unsigned int modificationTime () const override
 Get time of last modification. More...
 
virtual unsigned int userId () const override
 Get ID of owning user. More...
 
virtual void setUserId (unsigned int uid) override
 Set owning user. More...
 
virtual unsigned int groupId () const override
 Get ID of owning group. More...
 
virtual void setGroupId (unsigned int gid) override
 Set owning group. More...
 
virtual unsigned long permissions () const override
 Get file permissions. More...
 
virtual void setPermissions (unsigned long permissions) override
 Set file permissions. More...
 
virtual bool createDirectory () override
 Create directory. More...
 
virtual bool removeDirectory () override
 Remove directory. More...
 
virtual bool copy (AbstractFileHandleBackend &dest) override
 Copy file. More...
 
virtual bool move (AbstractFileHandleBackend &dest) override
 Move file. More...
 
virtual bool createLink (AbstractFileHandleBackend &dest) override
 Create hard link. More...
 
virtual bool createSymbolicLink (AbstractFileHandleBackend &dest) override
 Create symbolic link. More...
 
virtual bool rename (const std::string &filename) override
 Rename file or directory. More...
 
virtual bool remove () override
 Remove file. More...
 
virtual std::unique_ptr< std::istream > createInputStream (std::ios_base::openmode mode) const override
 Create input stream to read from the file. More...
 
virtual std::unique_ptr< std::ostream > createOutputStream (std::ios_base::openmode mode) override
 Create output stream to write to the file. More...
 
 LocalFileHandle (std::shared_ptr< LocalFileSystem > fs, const std::string &path)
 Constructor. More...
 
virtual ~LocalFileHandle ()
 Destructor. More...
 
virtual std::unique_ptr< AbstractFileHandleBackendclone () const override
 Create a copy of this handle. More...
 
virtual AbstractFileSystemfs () const override
 Get file system. More...
 
virtual void updateFileInfo () override
 Update file information. More...
 
virtual std::string path () const override
 Get path. More...
 
virtual bool exists () const override
 Check if file or directory exists. More...
 
virtual bool isFile () const override
 Check if item is a file. More...
 
virtual bool isDirectory () const override
 Check if item is a directory. More...
 
virtual bool isSymbolicLink () const override
 Check if item is a symbolic link. More...
 
virtual std::vector< std::string > listFiles () const override
 List files in directory. More...
 
virtual std::unique_ptr< AbstractFileIteratorBackendbegin () const override
 Get iterator that points to the first directory entry. More...
 
virtual unsigned int size () const override
 Get file size. More...
 
virtual unsigned int accessTime () const override
 Get time of last access. More...
 
virtual unsigned int modificationTime () const override
 Get time of last modification. More...
 
virtual unsigned int userId () const override
 Get ID of owning user. More...
 
virtual void setUserId (unsigned int uid) override
 Set owning user. More...
 
virtual unsigned int groupId () const override
 Get ID of owning group. More...
 
virtual void setGroupId (unsigned int gid) override
 Set owning group. More...
 
virtual unsigned long permissions () const override
 Get file permissions. More...
 
virtual void setPermissions (unsigned long permissions) override
 Set file permissions. More...
 
virtual bool createDirectory () override
 Create directory. More...
 
virtual bool removeDirectory () override
 Remove directory. More...
 
virtual bool copy (AbstractFileHandleBackend &dest) override
 Copy file. More...
 
virtual bool move (AbstractFileHandleBackend &dest) override
 Move file. More...
 
virtual bool createLink (AbstractFileHandleBackend &dest) override
 Create hard link. More...
 
virtual bool createSymbolicLink (AbstractFileHandleBackend &dest) override
 Create symbolic link. More...
 
virtual bool rename (const std::string &filename) override
 Rename file or directory. More...
 
virtual bool remove () override
 Remove file. More...
 
virtual std::unique_ptr< std::istream > createInputStream (std::ios_base::openmode mode) const override
 Create input stream to read from the file. More...
 
virtual std::unique_ptr< std::ostream > createOutputStream (std::ios_base::openmode mode) override
 Create output stream to write to the file. More...
 
- Public Member Functions inherited from cppfs::AbstractFileHandleBackend
 AbstractFileHandleBackend ()
 Constructor. More...
 
virtual ~AbstractFileHandleBackend ()
 Destructor. More...
 

Protected Member Functions

void readFileInfo () const
 
void readLinkInfo () const
 
void readFileInfo () const
 

Protected Attributes

std::shared_ptr< LocalFileSystemm_fs
 File system that created this handle. More...
 
std::string m_path
 Path to file or directory. More...
 
void * m_fileInfo
 Information about the current file (resolves links, created on demand) More...
 
void * m_linkInfo
 Information about the current file (does not resolve links, created on demand) More...
 

Detailed Description

File handle for the local file system.

Constructor & Destructor Documentation

cppfs::LocalFileHandle::LocalFileHandle ( std::shared_ptr< LocalFileSystem fs,
const std::string &  path 
)

Constructor.

Parameters
[in]fsFile system that created this handle
[in]pathPath to file or directory
cppfs::LocalFileHandle::LocalFileHandle ( std::shared_ptr< LocalFileSystem fs,
std::string &&  path 
)

Constructor.

Parameters
[in]fsFile system that created this handle
[in]pathPath to file or directory
virtual cppfs::LocalFileHandle::~LocalFileHandle ( )
virtual

Destructor.

cppfs::LocalFileHandle::LocalFileHandle ( std::shared_ptr< LocalFileSystem fs,
const std::string &  path 
)

Constructor.

Parameters
[in]fsFile system that created this handle
[in]pathPath to file or directory
virtual cppfs::LocalFileHandle::~LocalFileHandle ( )
virtual

Destructor.

Member Function Documentation

virtual std::unique_ptr<AbstractFileHandleBackend> cppfs::LocalFileHandle::clone ( ) const
overridevirtual

Create a copy of this handle.

Returns
File handle

Implements cppfs::AbstractFileHandleBackend.

virtual AbstractFileSystem* cppfs::LocalFileHandle::fs ( ) const
overridevirtual

Get file system.

Returns
File system (must NOT be null)

Implements cppfs::AbstractFileHandleBackend.

virtual void cppfs::LocalFileHandle::updateFileInfo ( )
overridevirtual

Update file information.

Implements cppfs::AbstractFileHandleBackend.

virtual std::string cppfs::LocalFileHandle::path ( ) const
overridevirtual

Get path.

Returns
Path to file or directory

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::exists ( ) const
overridevirtual

Check if file or directory exists.

Returns
'true' if it exists, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::isFile ( ) const
overridevirtual

Check if item is a file.

Returns
'true' if it is a file, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::isDirectory ( ) const
overridevirtual

Check if item is a directory.

Returns
'true' if it is a directory, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::isSymbolicLink ( ) const
overridevirtual

Check if item is a symbolic link.

Returns
'true' if it is a symbolic link, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual std::vector<std::string> cppfs::LocalFileHandle::listFiles ( ) const
overridevirtual

List files in directory.

Returns
List of files, empty list if this is not a valid directory

Implements cppfs::AbstractFileHandleBackend.

virtual std::unique_ptr<AbstractFileIteratorBackend> cppfs::LocalFileHandle::begin ( ) const
overridevirtual

Get iterator that points to the first directory entry.

Returns
Iterator backend, must NOT be null

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::size ( ) const
overridevirtual

Get file size.

Returns
Size if handle points to a file, else 0

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::accessTime ( ) const
overridevirtual

Get time of last access.

Returns
Time stamp

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::modificationTime ( ) const
overridevirtual

Get time of last modification.

Returns
Time stamp

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::userId ( ) const
overridevirtual

Get ID of owning user.

Returns
User ID

Implements cppfs::AbstractFileHandleBackend.

virtual void cppfs::LocalFileHandle::setUserId ( unsigned int  uid)
overridevirtual

Set owning user.

Parameters
[in]uidUser ID

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::groupId ( ) const
overridevirtual

Get ID of owning group.

Returns
Group ID

Implements cppfs::AbstractFileHandleBackend.

virtual void cppfs::LocalFileHandle::setGroupId ( unsigned int  gid)
overridevirtual

Set owning group.

Parameters
[in]gidGroup ID

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned long cppfs::LocalFileHandle::permissions ( ) const
overridevirtual

Get file permissions.

Returns
File permissions

Implements cppfs::AbstractFileHandleBackend.

virtual void cppfs::LocalFileHandle::setPermissions ( unsigned long  permissions)
overridevirtual

Set file permissions.

Parameters
[in]permissionsFile permissions

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::createDirectory ( )
overridevirtual

Create directory.

Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::removeDirectory ( )
overridevirtual

Remove directory.

Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::copy ( AbstractFileHandleBackend dest)
overridevirtual

Copy file.

Parameters
[in]destDestination file or directory (must be of the same type as this file handle)
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::move ( AbstractFileHandleBackend dest)
overridevirtual

Move file.

Parameters
[in]destDestination file or directory (must be of the same type as this file handle)
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::createLink ( AbstractFileHandleBackend dest)
overridevirtual

Create hard link.

Parameters
[in]destDestination file or directory (must be of the same type as this file handle)
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::createSymbolicLink ( AbstractFileHandleBackend dest)
overridevirtual

Create symbolic link.

Parameters
[in]destDestination file or directory (must be of the same type as this file handle)
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::rename ( const std::string &  filename)
overridevirtual

Rename file or directory.

Parameters
[in]filenameFile name
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::remove ( )
overridevirtual

Remove file.

Returns
'true' if successful, else 'false'
Remarks
Does only work if the handle points to a valid file, not a directory.

Implements cppfs::AbstractFileHandleBackend.

virtual std::unique_ptr<std::istream> cppfs::LocalFileHandle::createInputStream ( std::ios_base::openmode  mode) const
overridevirtual

Create input stream to read from the file.

Parameters
[in]modeOpening mode flags
Returns
Input stream, null on error
Remarks
The created stream object has to be destroyed be the caller.

Implements cppfs::AbstractFileHandleBackend.

virtual std::unique_ptr<std::ostream> cppfs::LocalFileHandle::createOutputStream ( std::ios_base::openmode  mode)
overridevirtual

Create output stream to write to the file.

Parameters
[in]modeOpening mode flags
Returns
Output stream, null on error
Remarks
The created stream object has to be destroyed be the caller.

Implements cppfs::AbstractFileHandleBackend.

void cppfs::LocalFileHandle::readFileInfo ( ) const
protected
void cppfs::LocalFileHandle::readLinkInfo ( ) const
protected
virtual std::unique_ptr<AbstractFileHandleBackend> cppfs::LocalFileHandle::clone ( ) const
overridevirtual

Create a copy of this handle.

Returns
File handle

Implements cppfs::AbstractFileHandleBackend.

virtual AbstractFileSystem* cppfs::LocalFileHandle::fs ( ) const
overridevirtual

Get file system.

Returns
File system (must NOT be null)

Implements cppfs::AbstractFileHandleBackend.

virtual void cppfs::LocalFileHandle::updateFileInfo ( )
overridevirtual

Update file information.

Implements cppfs::AbstractFileHandleBackend.

virtual std::string cppfs::LocalFileHandle::path ( ) const
overridevirtual

Get path.

Returns
Path to file or directory

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::exists ( ) const
overridevirtual

Check if file or directory exists.

Returns
'true' if it exists, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::isFile ( ) const
overridevirtual

Check if item is a file.

Returns
'true' if it is a file, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::isDirectory ( ) const
overridevirtual

Check if item is a directory.

Returns
'true' if it is a directory, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::isSymbolicLink ( ) const
overridevirtual

Check if item is a symbolic link.

Returns
'true' if it is a symbolic link, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual std::vector<std::string> cppfs::LocalFileHandle::listFiles ( ) const
overridevirtual

List files in directory.

Returns
List of files, empty list if this is not a valid directory

Implements cppfs::AbstractFileHandleBackend.

virtual std::unique_ptr<AbstractFileIteratorBackend> cppfs::LocalFileHandle::begin ( ) const
overridevirtual

Get iterator that points to the first directory entry.

Returns
Iterator backend, must NOT be null

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::size ( ) const
overridevirtual

Get file size.

Returns
Size if handle points to a file, else 0

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::accessTime ( ) const
overridevirtual

Get time of last access.

Returns
Time stamp

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::modificationTime ( ) const
overridevirtual

Get time of last modification.

Returns
Time stamp

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::userId ( ) const
overridevirtual

Get ID of owning user.

Returns
User ID

Implements cppfs::AbstractFileHandleBackend.

virtual void cppfs::LocalFileHandle::setUserId ( unsigned int  uid)
overridevirtual

Set owning user.

Parameters
[in]uidUser ID

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned int cppfs::LocalFileHandle::groupId ( ) const
overridevirtual

Get ID of owning group.

Returns
Group ID

Implements cppfs::AbstractFileHandleBackend.

virtual void cppfs::LocalFileHandle::setGroupId ( unsigned int  gid)
overridevirtual

Set owning group.

Parameters
[in]gidGroup ID

Implements cppfs::AbstractFileHandleBackend.

virtual unsigned long cppfs::LocalFileHandle::permissions ( ) const
overridevirtual

Get file permissions.

Returns
File permissions

Implements cppfs::AbstractFileHandleBackend.

virtual void cppfs::LocalFileHandle::setPermissions ( unsigned long  permissions)
overridevirtual

Set file permissions.

Parameters
[in]permissionsFile permissions

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::createDirectory ( )
overridevirtual

Create directory.

Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::removeDirectory ( )
overridevirtual

Remove directory.

Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::copy ( AbstractFileHandleBackend dest)
overridevirtual

Copy file.

Parameters
[in]destDestination file or directory (must be of the same type as this file handle)
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::move ( AbstractFileHandleBackend dest)
overridevirtual

Move file.

Parameters
[in]destDestination file or directory (must be of the same type as this file handle)
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::createLink ( AbstractFileHandleBackend dest)
overridevirtual

Create hard link.

Parameters
[in]destDestination file or directory (must be of the same type as this file handle)
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::createSymbolicLink ( AbstractFileHandleBackend dest)
overridevirtual

Create symbolic link.

Parameters
[in]destDestination file or directory (must be of the same type as this file handle)
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::rename ( const std::string &  filename)
overridevirtual

Rename file or directory.

Parameters
[in]filenameFile name
Returns
'true' if successful, else 'false'

Implements cppfs::AbstractFileHandleBackend.

virtual bool cppfs::LocalFileHandle::remove ( )
overridevirtual

Remove file.

Returns
'true' if successful, else 'false'
Remarks
Does only work if the handle points to a valid file, not a directory.

Implements cppfs::AbstractFileHandleBackend.

virtual std::unique_ptr<std::istream> cppfs::LocalFileHandle::createInputStream ( std::ios_base::openmode  mode) const
overridevirtual

Create input stream to read from the file.

Parameters
[in]modeOpening mode flags
Returns
Input stream, null on error
Remarks
The created stream object has to be destroyed be the caller.

Implements cppfs::AbstractFileHandleBackend.

virtual std::unique_ptr<std::ostream> cppfs::LocalFileHandle::createOutputStream ( std::ios_base::openmode  mode)
overridevirtual

Create output stream to write to the file.

Parameters
[in]modeOpening mode flags
Returns
Output stream, null on error
Remarks
The created stream object has to be destroyed be the caller.

Implements cppfs::AbstractFileHandleBackend.

void cppfs::LocalFileHandle::readFileInfo ( ) const
protected

Member Data Documentation

std::shared_ptr< LocalFileSystem > cppfs::LocalFileHandle::m_fs
protected

File system that created this handle.

std::string cppfs::LocalFileHandle::m_path
protected

Path to file or directory.

void * cppfs::LocalFileHandle::m_fileInfo
mutableprotected

Information about the current file (resolves links, created on demand)

Information about the current file (created on demand)

void* cppfs::LocalFileHandle::m_linkInfo
mutableprotected

Information about the current file (does not resolve links, created on demand)


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