zipios::FilePath(3) | zipios | zipios::FilePath(3) |
NAME¶
zipios::FilePath - Handle a file path and name and its statistics.
SYNOPSIS¶
#include <filepath.hpp>
Public Member Functions¶
FilePath (std::string const &path=std::string())
Initialize a FilePath object. void clear ()
Clear the filename. bool empty () const
Check whether the filename is empty. bool exists () const
Check whether the file exists. std::string filename () const
Retrieve the basename. size_t fileSize () const
Get the size of the file. bool isBlockSpecial () const
Check whether the file is a block special file. bool isCharSpecial ()
const
Check whether the file is a character special file. bool isDirectory ()
const
Check whether the file is a directory. bool isFifo () const
Check whether the file is a pipe. bool isRegular () const
Check whether the file is a regular file. bool isSocket () const
Check whether the file is a socket. std::time_t lastModificationTime ()
const
Get the last modification time of the file. size_t length () const
Get the length of the string. operator std::string () const
Retrieve the path. FilePath operator+ (FilePath const
&name) const
Append the a child name to this path. FilePath & operator=
(std::string const &path)
Replace the path with a new path. bool operator== (char const *rhs)
const
Check whether two FilePath represent the same file. bool
operator== (FilePath const &rhs) const
Check whether two FilePath represent the same file. bool
operator== (std::string const &rhs) const
Check whether two FilePath represent the same file. size_t size
() const
Get the length of the string.
Private Member Functions¶
void check () const
Read the file mode.
Private Attributes¶
bool m_checked = false
bool m_exists = false
std::string m_path = std::string()
os_stat_t m_stat = {}
Friends¶
bool operator== (char const *lhs, FilePath const
&rhs)
Check whether two FilePath represent the same file. bool
operator== (std::string const &lhs, FilePath const
&rhs)
Check whether two FilePath represent the same file.
Detailed Description¶
The FilePath class represents a path to a file or directory name. FilePath has member functions to check if the file path is a valid file system entity, and to check what kind of file system entity it is, e.g. is it a file, a directory, a pipe, etc.
It also knows of the last modification time and size of the file.
Warning
Definition at line 46 of file filepath.hpp.
Constructor & Destructor Documentation¶
zipios::FilePath::FilePath (std::string const & path = std::string())¶
The constructor saves the path and if check_exists is true, read the file statistics, especially the st_mode.
Parameters
See also
pruneTrailingSeparator()
Definition at line 102 of file filepath.cpp.
Member Function Documentation¶
void zipios::FilePath::check () const [private]¶
This function sets m_checked to true, stat()'s the path, to see if it exists and to determine what type of file it is. All the query functions call check() before they test a flag to make sure it is set appropriately.
This means stat()'ing is deferred until it becomes necessary. But also it is cached meaning that if the file changes in between we get the old flags.
Todo
See zipios/zipios-config.hpp.in
Definition at line 119 of file filepath.cpp.
References m_checked, m_exists, m_path, and m_stat.
Referenced by exists(), fileSize(), isBlockSpecial(), isCharSpecial(), isDirectory(), isFifo(), isRegular(), isSocket(), and lastModificationTime().
void zipios::FilePath::clear ()¶
This function clears the path to an empty string.
Definition at line 301 of file filepath.cpp.
References m_checked, and m_path.
Referenced by zipios::DirectoryCollection::close().
bool zipios::FilePath::empty () const¶
This function returns true if the filename is empty. In other words, this function returns true if the filename is not currently defined.
Note
Warning
if(file_path.fileSize() == 0) ...empty file...
Returns
See also
fileSize()
Definition at line 381 of file filepath.cpp.
References m_path.
bool zipios::FilePath::exists () const¶
This function calls check() and then returns true if the file exists on disk.
Returns
Definition at line 394 of file filepath.cpp.
References check(), and m_exists.
std::string zipios::FilePath::filename () const¶
This function returns the filename part of the FilePath object by pruning the path off.
Returns
Definition at line 315 of file filepath.cpp.
References zipios::g_separator, and m_path.
Referenced by zipios::DirectoryEntry::computeCRC32(), and zipios::FileEntry::getFileName().
size_t zipios::FilePath::fileSize () const¶
This function returns the size of the file. The size may be a 64 bit size on 64 bit systems.
Note
If the file is not considered valid, the size returned is zero.
Warning
Returns
See also
Definition at line 504 of file filepath.cpp.
References check(), and m_stat.
Referenced by zipios::DirectoryEntry::DirectoryEntry().
bool zipios::FilePath::isBlockSpecial () const¶
This function returns true if the file exists and is a block special file.
Returns
Definition at line 450 of file filepath.cpp.
References check(), m_exists, and m_stat.
bool zipios::FilePath::isCharSpecial () const¶
This function returns true if the file exists and is a character special file.
Returns
Definition at line 436 of file filepath.cpp.
References check(), m_exists, and m_stat.
bool zipios::FilePath::isDirectory () const¶
This function returns true if the file exists and is a directory.
Returns
Definition at line 422 of file filepath.cpp.
References check(), m_exists, and m_stat.
Referenced by zipios::DirectoryCollection::DirectoryCollection(), zipios::DirectoryEntry::DirectoryEntry(), zipios::DirectoryEntry::computeCRC32(), zipios::FileEntry::isDirectory(), and zipios::DirectoryCollection::loadEntries().
bool zipios::FilePath::isFifo () const¶
This function returns true if the file exists and is a pipe file.
Returns
Definition at line 478 of file filepath.cpp.
References check(), m_exists, and m_stat.
bool zipios::FilePath::isRegular () const¶
This function returns true if the file exists and is a regular file.
Returns
Definition at line 408 of file filepath.cpp.
References check(), m_exists, and m_stat.
Referenced by zipios::DirectoryCollection::DirectoryCollection(), and zipios::DirectoryEntry::DirectoryEntry().
bool zipios::FilePath::isSocket () const¶
This function returns true if the file exists and is a socket file.
Returns
Definition at line 464 of file filepath.cpp.
References check(), m_exists, and m_stat.
std::time_t zipios::FilePath::lastModificationTime () const¶
This function returns the last modification time of the specified file.
Note
Returns
Definition at line 521 of file filepath.cpp.
References check(), and m_stat.
Referenced by zipios::DirectoryEntry::DirectoryEntry().
size_t zipios::FilePath::length () const¶
This function returns the length of the string used to represent this FilePath path and filename.
Returns
See also
Definition at line 336 of file filepath.cpp.
References m_path.
Referenced by zipios::ZipCentralDirectoryEntry::getHeaderSize(), zipios::ZipLocalEntry::getHeaderSize(), size(), zipios::ZipCentralDirectoryEntry::write(), and zipios::ZipLocalEntry::write().
zipios::FilePath::operator std::string () const¶
This operator can be used to retrieve a copy of the path.
Returns
Definition at line 163 of file filepath.cpp.
FilePath zipios::FilePath::operator+ (FilePath const & rhs) const¶
This function concatenates two FilePath objects and returns another FilePath.
A file separator is inserted between both names if appropriate.
Warning
Parameters
Returns
Definition at line 185 of file filepath.cpp.
References zipios::g_separator, and m_path.
FilePath & zipios::FilePath::operator= (std::string const & path)¶
This function replaces the internal path of this FilePath with the new specified path.
Parameters
Returns
Definition at line 149 of file filepath.cpp.
References m_checked, and m_path.
bool zipios::FilePath::operator== (char const * rhs) const¶
This function compares a FilePath object (this) and a C-string to know whether the two are the same.
A null pointer as the C-string is viewed as an empty string.
Parameters
See also
Definition at line 217 of file filepath.cpp.
References m_path.
bool zipios::FilePath::operator== (FilePath const & rhs) const¶
This function compares two FilePath objects (this and rhs) to know whether the two are the same.
Note
Parameters
See also
operator == (std::string const & rhs);
Definition at line 291 of file filepath.cpp.
References m_path.
bool zipios::FilePath::operator== (std::string const & rhs) const¶
This function compares a FilePath object (this) against a string representing a path to know whether the two are the equal.
Parameters
See also
Definition at line 251 of file filepath.cpp.
References m_path.
size_t zipios::FilePath::size () const¶
This function returns the length of the string used to represent this FilePath path and filename.
Note
Returns
See also
Definition at line 356 of file filepath.cpp.
References length().
Friends And Related Symbol Documentation¶
bool operator== (char const * lhs, FilePath const & rhs) [friend]¶
This function compares a FilePath object (this) and a C-string to know whether the two are the same.
A null pointer as the C-string is viewed as an empty string.
Parameters
rhs The right hand side to compare with.
See also
Definition at line 235 of file filepath.cpp.
bool operator== (std::string const & lhs, FilePath const & rhs) [friend]¶
This function compares a FilePath object (this) against a string representing a path to know whether the two are the equal.
Parameters
rhs The right hand side to compare with.
See also
Definition at line 268 of file filepath.cpp.
Member Data Documentation¶
bool zipios::FilePath::m_checked = false [mutable], [private]¶
Definition at line 80 of file filepath.hpp.
Referenced by check(), clear(), and operator=().
bool zipios::FilePath::m_exists = false [mutable], [private]¶
Definition at line 81 of file filepath.hpp.
Referenced by check(), exists(), isBlockSpecial(), isCharSpecial(), isDirectory(), isFifo(), isRegular(), and isSocket().
std::string zipios::FilePath::m_path = std::string() [private]¶
Definition at line 78 of file filepath.hpp.
Referenced by check(), clear(), empty(), filename(), length(), operator+(), operator=(), operator==(), operator==(), and operator==().
os_stat_t zipios::FilePath::m_stat = {} [mutable], [private]¶
Definition at line 79 of file filepath.hpp.
Referenced by check(), fileSize(), isBlockSpecial(), isCharSpecial(), isDirectory(), isFifo(), isRegular(), isSocket(), and lastModificationTime().
Author¶
Generated automatically by Doxygen for zipios from the source code.
Sat Dec 30 2023 01:18:29 | Version 2.3.2 |