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);
28 bool isReadOnly()
const;
31 CppUtilities::NativeFileStream &stream();
32 const CppUtilities::NativeFileStream &stream()
const;
35 const std::string &path()
const;
36 void setPath(std::string_view path);
37 void setPath(std::string &&path);
38 static std::string fileName(std::string_view path,
bool cutExtension =
false);
39 std::string fileName(
bool cutExtension =
false)
const;
40 static std::string extension(std::string_view path);
41 std::string extension()
const;
42 static std::string pathWithoutExtension(std::string_view fullPath);
43 std::string pathWithoutExtension()
const;
44 static std::string containingDirectory(std::string_view path);
45 std::string containingDirectory()
const;
46 static std::string_view pathForOpen(std::string_view url);
49 std::uint64_t size()
const;
50 void reportSizeChanged(std::uint64_t newSize);
51 void reportPathChanged(std::string_view newPath);
52 void reportPathChanged(std::string &&newPath);
55 virtual void invalidated();
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();
The BasicFileInfo class provides basic file information such as file name, extension,...
void reportPathChanged(std::string_view newPath)
Call this function to report that the path changed.
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.
std::uint64_t size() const
Returns size of the current file in bytes.
CppUtilities::NativeFileStream & stream()
Returns the std::fstream for the current instance.
BasicFileInfo(const BasicFileInfo &)=delete
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.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Contains all classes and functions of the TagInfo library.