1#ifndef TAG_PARSER_BASICFILEINFO_H
2#define TAG_PARSER_BASICFILEINFO_H
6#include <c++utilities/conversion/stringconversion.h>
7#include <c++utilities/io/nativefilestream.h>
25 void open(
bool readOnly =
false);
26 void reopen(
bool readOnly =
false);
31 CppUtilities::NativeFileStream &
stream();
32 const CppUtilities::NativeFileStream &
stream()
const;
35 const std::string &
path()
const;
38 static std::string
fileName(std::string_view
path,
bool cutExtension =
false);
39 std::string
fileName(
bool cutExtension =
false)
const;
46 static std::string_view
pathForOpen(std::string_view url);
49 std::uint64_t
size()
const;
59 CppUtilities::NativeFileStream m_file;
71 return m_file.is_open();
144 m_path = std::move(newPath);
155 return CppUtilities::startsWith(url,
"file:/") ? url.data() + 6 : url.data();
BasicFileInfo()
Constructs a new BasicFileInfo for the specified file.
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.
void reportPathChanged(std::string_view newPath)
Call this function to report that the path changed.
void invalidate()
Invalidates the file info manually.
const std::string & path() const
Returns the path of the current file.
bool isReadOnly() const
Indicates whether the last open()/reopen() call was read-only.
static std::string containingDirectory(std::string_view path)
Returns the path of the directory containing the given file.
void reopen(bool readOnly=false)
Opens a std::fstream for the current file.
std::uint64_t size() const
Returns size of the current file in bytes.
virtual void invalidated()
This function is called when the BasicFileInfo gets invalidated.
CppUtilities::NativeFileStream & stream()
Returns the std::fstream for the current instance.
void open(bool readOnly=false)
Opens a std::fstream for the current file.
BasicFileInfo(const BasicFileInfo &)=delete
static std::string pathWithoutExtension(std::string_view fullPath)
Returns a copy of the given path without the extension/suffix.
void close()
A possibly opened std::fstream will be closed.
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(),...
void reportSizeChanged(std::uint64_t newSize)
Call this function to report that the size changed.
BasicFileInfo & operator=(const BasicFileInfo &)=delete
bool isOpen() const
Indicates whether a std::fstream is open for the current file.
void setPath(std::string_view path)
Sets the current file.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Contains all classes and functions of the TagInfo library.