20#ifndef LIBREPCB_CORE_FILEPATH_H
21#define LIBREPCB_CORE_FILEPATH_H
26#include "../qtcompat.h"
157 explicit
FilePath(const QString& filepath) noexcept;
179 bool setPath(const QString& filepath) noexcept;
217 bool isRoot() const noexcept;
233 QString
toStr() const noexcept;
293 QUrl
toQUrl() const noexcept {
return QUrl::fromLocalFile(
toStr()); }
373 const QString& relative) noexcept;
427 CleanFileNameOptions options) noexcept;
443 bool operator==(const
FilePath& rhs) const noexcept;
452 bool operator!=(const
FilePath& rhs) const noexcept;
465 bool operator<(const
FilePath& rhs) const noexcept;
489QDataStream& operator<<(QDataStream& stream, const
FilePath& filepath);
490QDebug& operator<<(QDebug& stream, const
FilePath& filepath);
493 return qHash(key.toStr(), seed);
503Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::FilePath::CleanFileNameOptions)
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
QString getBasename() const noexcept
Get the basename of the file or directory.
Definition: filepath.cpp:135
bool isValid() const noexcept
Check whether this object contains a valid filepath or not.
Definition: filepath.h:188
QString getCompleteSuffix() const noexcept
Get the complete suffix of the file or directory.
Definition: filepath.cpp:156
CleanFileNameOption
Definition: filepath.h:131
@ KeepSpaces
Definition: filepath.h:133
@ ToLowerCase
Definition: filepath.h:137
@ Default
Definition: filepath.h:140
@ ToUpperCase
Definition: filepath.h:138
@ KeepCase
Definition: filepath.h:136
@ ReplaceSpaces
Definition: filepath.h:134
FilePath getPathTo(const QString &filename) const noexcept
Get the filepath to a file or directory which is relative to this filepath.
Definition: filepath.cpp:176
QString getFilename() const noexcept
Get the whole filename (without the path) of the file or directory.
Definition: filepath.cpp:163
bool isRoot() const noexcept
Check if the specified filepath is the root directory.
Definition: filepath.cpp:90
QString toStr() const noexcept
Get the absolute and well-formatted filepath as a QString.
Definition: filepath.cpp:102
bool setPath(const QString &filepath) noexcept
Set a new filepath.
Definition: filepath.cpp:60
static QString cleanFileName(const QString &userInput, CleanFileNameOptions options) noexcept
Clean a given string so that it becomes a valid filename.
Definition: filepath.cpp:239
static FilePath getApplicationTempPath() noexcept
Get the path to the temporary application directory (e.g. "/tmp/librepcb")
Definition: filepath.cpp:226
bool isLocatedInDir(const FilePath &dir) const noexcept
Check if the filepath is located inside another directory.
Definition: filepath.cpp:96
QUrl toQUrl() const noexcept
Create and return a QUrl object with this filepath.
Definition: filepath.h:293
static FilePath getRandomTempPath() noexcept
Get a random temporary directory path (e.g. "/tmp/librepcb/42")
Definition: filepath.cpp:230
QString toRelative(const FilePath &base) const noexcept
Convert an absolute filepath to a relative filepath (relative to another filepath)
Definition: filepath.cpp:124
bool mIsValid
Definition: filepath.h:483
FilePath getParentDir() const noexcept
Get the filepath of the parent directory of the file or directory.
Definition: filepath.cpp:170
static QString makeWellFormatted(const QString &filepath) noexcept
Make a filepath well-formatted (except making it absolute!)
Definition: filepath.cpp:258
FilePath() noexcept
The default constructor (this will create an invalid object!)
Definition: filepath.cpp:41
bool isEmptyDir() const noexcept
Check if the specified filepath is an existing, empty directory.
Definition: filepath.cpp:82
FilePath toUnique() const noexcept
Get a unique version of the filepath (resolve symbolic links if possible)
Definition: filepath.cpp:114
static FilePath getTempPath() noexcept
Get the path to the temporary directory (e.g. "/tmp" on Unix/Linux)
Definition: filepath.cpp:217
QFileInfo mFileInfo
the absolute and well-formatted filepath in a QFileInfo
Definition: filepath.h:485
QString getSuffix() const noexcept
Get the suffix of the file or directory.
Definition: filepath.cpp:149
QString getCompleteBasename() const noexcept
Get the complete basename of the file or directory.
Definition: filepath.cpp:142
static FilePath fromRelative(const FilePath &base, const QString &relative) noexcept
Build an absolute and well-formatted filepath from a relative filepath.
Definition: filepath.cpp:210
bool isExistingDir() const noexcept
Check if the specified filepath is an existing directory.
Definition: filepath.cpp:76
QString toNative() const noexcept
Get the absolute filepath with native directory separators.
Definition: filepath.cpp:108
QString toRelativeNative(const FilePath &base) const noexcept
Same as toRelative(), but with native directory separators.
Definition: filepath.cpp:131
bool isExistingFile() const noexcept
Check if the specified filepath is an existing file.
Definition: filepath.cpp:70
Qt compatibility helper class.
Definition: qtcompat.h:43
Definition: occmodel.cpp:77
QtCompat::Hash qHash(const AttributeKey &key, QtCompat::Hash seed=0) noexcept
Definition: attributekey.h:119