Tag Parser 12.3.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
The BasicFileInfo class provides basic file information such as file name, extension, directory and size for a specified file. More...
#include <basicfileinfo.h>
Public Member Functions | |
BasicFileInfo () | |
Constructs a new BasicFileInfo for the specified file. | |
BasicFileInfo (std::string &&path) | |
Constructs a new BasicFileInfo for the specified file. | |
BasicFileInfo (std::string_view path) | |
Constructs a new BasicFileInfo for the specified file. | |
BasicFileInfo (const BasicFileInfo &)=delete | |
BasicFileInfo & | operator= (const BasicFileInfo &)=delete |
virtual | ~BasicFileInfo () |
Destroys the BasicFileInfo. | |
void | open (bool readOnly=false) |
Opens a std::fstream for the current file. | |
void | reopen (bool readOnly=false) |
Opens a std::fstream for the current file. | |
bool | isOpen () const |
Indicates whether a std::fstream is open for the current file. | |
bool | isReadOnly () const |
Indicates whether the last open()/reopen() call was read-only. | |
void | close () |
A possibly opened std::fstream will be closed. | |
void | invalidate () |
Invalidates the file info manually. | |
CppUtilities::NativeFileStream & | stream () |
Returns the std::fstream for the current instance. | |
const CppUtilities::NativeFileStream & | stream () const |
Returns the std::fstream for the current instance. | |
const std::string & | path () const |
Returns the path of the current file. | |
void | setPath (std::string_view path) |
Sets the current file. | |
void | setPath (std::string &&path) |
Sets the current file. | |
std::string | fileName (bool cutExtension=false) const |
Returns the file name of the current file. | |
std::string | extension () const |
Returns the extension of the current file. | |
std::string | pathWithoutExtension () const |
Returns the path of the current file without the extension/suffix. | |
std::string | containingDirectory () const |
Returns the path of the directory containing the current file. | |
std::uint64_t | size () const |
Returns size of the current file in bytes. | |
void | reportSizeChanged (std::uint64_t newSize) |
Call this function to report that the size changed. | |
void | reportPathChanged (std::string_view newPath) |
Call this function to report that the path changed. | |
void | reportPathChanged (std::string &&newPath) |
Call this function to report that the path changed. | |
Static Public Member Functions | |
static std::string | fileName (std::string_view path, bool cutExtension=false) |
Returns the file name of the given file. | |
static std::string | extension (std::string_view path) |
Returns the extension of the given file. | |
static std::string | pathWithoutExtension (std::string_view fullPath) |
Returns a copy of the given path without the extension/suffix. | |
static std::string | containingDirectory (std::string_view path) |
Returns the path of the directory containing the given file. | |
static std::string_view | pathForOpen (std::string_view url) |
Returns removes the "file:/" prefix from url to be able to pass it to functions like open(), stat() and truncate(). | |
Protected Member Functions | |
virtual void | invalidated () |
This function is called when the BasicFileInfo gets invalidated. | |
The BasicFileInfo class provides basic file information such as file name, extension, directory and size for a specified file.
Definition at line 14 of file basicfileinfo.h.
|
explicit |
Constructs a new BasicFileInfo for the specified file.
path | Specifies the absolute or relative path of the file. |
Definition at line 23 of file basicfileinfo.cpp.
|
explicit |
Constructs a new BasicFileInfo for the specified file.
path | Specifies the absolute or relative path of the file. |
Definition at line 35 of file basicfileinfo.cpp.
|
explicit |
Constructs a new BasicFileInfo for the specified file.
path | Specifies the absolute or relative path of the file. |
Definition at line 48 of file basicfileinfo.cpp.
|
delete |
|
virtual |
Destroys the BasicFileInfo.
A possibly opened std::fstream will be closed.
Definition at line 61 of file basicfileinfo.cpp.
void TagParser::BasicFileInfo::close | ( | ) |
A possibly opened std::fstream will be closed.
All flags of the stream will be cleared.
Definition at line 97 of file basicfileinfo.cpp.
string TagParser::BasicFileInfo::containingDirectory | ( | ) | const |
Returns the path of the directory containing the current file.
The returned path is relative if the path of the file (specified using the setPath() method) is relative.
Definition at line 247 of file basicfileinfo.cpp.
|
static |
Returns the path of the directory containing the given file.
Definition at line 220 of file basicfileinfo.cpp.
std::string TagParser::BasicFileInfo::extension | ( | ) | const |
Returns the extension of the current file.
Definition at line 195 of file basicfileinfo.cpp.
|
static |
Returns the extension of the given file.
path | Specifies the path of the file. |
Definition at line 182 of file basicfileinfo.cpp.
std::string TagParser::BasicFileInfo::fileName | ( | bool | cutExtension = false | ) | const |
Returns the file name of the current file.
cutExtension | Indicates whether the extension should be cut. |
Definition at line 172 of file basicfileinfo.cpp.
|
static |
Returns the file name of the given file.
path | Specifies the path of the file. |
cutExtension | Indicates whether the extension/suffix should be cut. |
Definition at line 149 of file basicfileinfo.cpp.
void TagParser::BasicFileInfo::invalidate | ( | ) |
Invalidates the file info manually.
Definition at line 108 of file basicfileinfo.cpp.
|
protectedvirtual |
This function is called when the BasicFileInfo gets invalidated.
This is the case when the current file changes or is reopened.
When subclassing and overwriting this virtual method invoke the base implementation by calling BasicFileInfo::invalidated() before the reimplemented code.
Reimplemented in TagParser::MediaFileInfo.
Definition at line 259 of file basicfileinfo.cpp.
|
inline |
Indicates whether a std::fstream is open for the current file.
Definition at line 69 of file basicfileinfo.h.
|
inline |
Indicates whether the last open()/reopen() call was read-only.
Definition at line 77 of file basicfileinfo.h.
void TagParser::BasicFileInfo::open | ( | bool | readOnly = false | ) |
Opens a std::fstream for the current file.
Does nothing a stream is already open.
readOnly | Indicates whether the stream should be opend as read-only. |
Throws | std::ios_base::failure when an IO error occurs. |
Definition at line 71 of file basicfileinfo.cpp.
|
delete |
|
inline |
Returns the path of the current file.
Definition at line 103 of file basicfileinfo.h.
|
inlinestatic |
Returns removes the "file:/" prefix from url to be able to pass it to functions like open(), stat() and truncate().
Definition at line 153 of file basicfileinfo.h.
std::string TagParser::BasicFileInfo::pathWithoutExtension | ( | ) | const |
Returns the path of the current file without the extension/suffix.
Definition at line 212 of file basicfileinfo.cpp.
|
static |
Returns a copy of the given path without the extension/suffix.
Definition at line 203 of file basicfileinfo.cpp.
void TagParser::BasicFileInfo::reopen | ( | bool | readOnly = false | ) |
Opens a std::fstream for the current file.
Closes a possibly already opened stream and clears all flags before.
readOnly | Indicates whether the stream should be opend as read-only. |
Throws | std::ios_base::failure when an IO error occurs. |
Definition at line 84 of file basicfileinfo.cpp.
|
inline |
Call this function to report that the path changed.
Definition at line 142 of file basicfileinfo.h.
|
inline |
Call this function to report that the path changed.
Definition at line 133 of file basicfileinfo.h.
|
inline |
Call this function to report that the size changed.
Definition at line 124 of file basicfileinfo.h.
void TagParser::BasicFileInfo::setPath | ( | std::string && | path | ) |
Sets the current file.
A possibly opened std::fstream will be closed and invalidated() will be called.
path | Specifies the absolute or relative path of the file to be set. |
Definition at line 135 of file basicfileinfo.cpp.
void TagParser::BasicFileInfo::setPath | ( | std::string_view | path | ) |
Sets the current file.
A possibly opened std::fstream will be closed and invalidated() will be called.
path | Specifies the absolute or relative path of the file to be set. |
Definition at line 120 of file basicfileinfo.cpp.
|
inline |
Returns size of the current file in bytes.
Definition at line 115 of file basicfileinfo.h.
|
inline |
Returns the std::fstream for the current instance.
Definition at line 85 of file basicfileinfo.h.
|
inline |
Returns the std::fstream for the current instance.
Definition at line 93 of file basicfileinfo.h.