Tag Parser
6.5.0
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 (const std::string &path=std::string()) | |
Constructs a new BasicFileInfo for the specified file. More... | |
BasicFileInfo (const BasicFileInfo &)=delete | |
BasicFileInfo & | operator= (const BasicFileInfo &)=delete |
virtual | ~BasicFileInfo () |
Destroys the BasicFileInfo. More... | |
void | open (bool readOnly=false) |
Opens a std::fstream for the current file. More... | |
void | reopen (bool readonly=false) |
Opens a std::fstream for the current file. More... | |
bool | isOpen () const |
Indicates whether a std::fstream is open for the current file. More... | |
bool | isReadOnly () const |
Indicates whether the last open()/reopen() call was read-only. More... | |
void | close () |
A possibly opened std::fstream will be closed. More... | |
void | invalidate () |
Invalidates the file info manually. More... | |
IoUtilities::NativeFileStream & | stream () |
Returns the std::fstream for the current instance. More... | |
const IoUtilities::NativeFileStream & | stream () const |
Returns the std::fstream for the current instance. More... | |
const std::string & | path () const |
Returns the path of the current file. More... | |
void | setPath (const std::string &path) |
Sets the current file. More... | |
std::string | fileName (bool cutExtension=false) const |
Returns the file name of the current file. More... | |
std::string | extension () const |
Returns the extension of the current file. More... | |
std::string | pathWithoutExtension () const |
Returns the path of the current file without the extension/suffix. More... | |
std::string | containingDirectory () const |
Returns the path of the directory containing the current file. More... | |
uint64 | size () const |
Returns size of the current file in bytes. More... | |
void | reportSizeChanged (uint64 newSize) |
Call this function to report that the size changed. More... | |
void | reportPathChanged (const std::string &newPath) |
Call this function to report that the path changed. More... | |
Static Public Member Functions | |
static std::string | fileName (const std::string &path, bool cutExtension=false) |
Returns the file name of the given file. More... | |
static std::string | extension (const std::string &path) |
Returns the extension of the given file. More... | |
static std::string | pathWithoutExtension (const std::string &fullPath) |
Returns a copy of the given path without the extension/suffix. More... | |
static std::string | containingDirectory (const std::string &path) |
Returns the path of the directory containing the given file. More... | |
Protected Member Functions | |
virtual void | invalidated () |
This function is called when the BasicFileInfo gets invalidated. More... | |
The BasicFileInfo class provides basic file information such as file name, extension, directory and size for a specified file.
Definition at line 13 of file basicfileinfo.h.
Media::BasicFileInfo::BasicFileInfo | ( | const std::string & | path = std::string() | ) |
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.
|
delete |
|
virtual |
Destroys the BasicFileInfo.
A possibly opened std::fstream will be closed.
Definition at line 36 of file basicfileinfo.cpp.
void Media::BasicFileInfo::close | ( | ) |
A possibly opened std::fstream will be closed.
All flags of the stream will be cleared.
Definition at line 71 of file basicfileinfo.cpp.
|
static |
Returns the path of the directory containing the given file.
Definition at line 179 of file basicfileinfo.cpp.
string Media::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 206 of file basicfileinfo.cpp.
|
static |
Returns the extension of the given file.
path | Specifies the path of the file. |
Definition at line 141 of file basicfileinfo.cpp.
string Media::BasicFileInfo::extension | ( | ) | const |
Returns the extension of the current file.
Definition at line 154 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 cutted. |
Definition at line 108 of file basicfileinfo.cpp.
string Media::BasicFileInfo::fileName | ( | bool | cutExtension = false | ) | const |
Returns the file name of the current file.
cutExtension | Indicates whether the extension should be cutted. |
Definition at line 131 of file basicfileinfo.cpp.
void Media::BasicFileInfo::invalidate | ( | ) |
Invalidates the file info manually.
Definition at line 82 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 Media::MediaFileInfo.
Definition at line 218 of file basicfileinfo.cpp.
|
inline |
Indicates whether a std::fstream is open for the current file.
Definition at line 64 of file basicfileinfo.h.
|
inline |
Indicates whether the last open()/reopen() call was read-only.
Definition at line 72 of file basicfileinfo.h.
void Media::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 46 of file basicfileinfo.cpp.
|
delete |
|
inline |
Returns the path of the current file.
Definition at line 98 of file basicfileinfo.h.
|
static |
Returns a copy of the given path without the extension/suffix.
Definition at line 162 of file basicfileinfo.cpp.
string Media::BasicFileInfo::pathWithoutExtension | ( | ) | const |
Returns the path of the current file without the extension/suffix.
Definition at line 171 of file basicfileinfo.cpp.
void Media::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 59 of file basicfileinfo.cpp.
|
inline |
Call this function to report that the path changed.
Definition at line 128 of file basicfileinfo.h.
|
inline |
Call this function to report that the size changed.
Definition at line 119 of file basicfileinfo.h.
void Media::BasicFileInfo::setPath | ( | const 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 94 of file basicfileinfo.cpp.
|
inline |
Returns size of the current file in bytes.
Definition at line 110 of file basicfileinfo.h.
|
inline |
Returns the std::fstream for the current instance.
Definition at line 80 of file basicfileinfo.h.
|
inline |
Returns the std::fstream for the current instance.
Definition at line 88 of file basicfileinfo.h.