Add static methods to get the data paths in a library

This commit is contained in:
Luis Ángel San Martín 2025-03-27 20:19:08 +01:00
parent af1af3976d
commit c148a96d7f
2 changed files with 20 additions and 1 deletions

View File

@ -228,7 +228,7 @@ QString YACReaderLibrary::getPath() const
QString YACReaderLibrary::getDBPath() const QString YACReaderLibrary::getDBPath() const
{ {
return path + "/.yacreaderlibrary"; return YACReaderLibrary::libraryDataPath(path);
} }
int YACReaderLibrary::getLegacyId() const int YACReaderLibrary::getLegacyId() const
@ -251,6 +251,21 @@ bool YACReaderLibrary::operator!=(const YACReaderLibrary &other) const
return !(*this == other); return !(*this == other);
} }
QString YACReaderLibrary::libraryDataPath(const QString &libraryPath)
{
return QDir(libraryPath).filePath(".yacreaderlibrary");
}
QString YACReaderLibrary::libraryDatabasePath(const QString &libraryPath)
{
return QDir(YACReaderLibrary::libraryDataPath(libraryPath)).filePath("library.ydb");
}
QString YACReaderLibrary::libraryCoversFolderPath(const QString &libraryPath)
{
return QDir(YACReaderLibrary::libraryDataPath(libraryPath)).filePath("covers");
}
QDataStream &operator<<(QDataStream &out, const YACReaderLibrary &library) QDataStream &operator<<(QDataStream &out, const YACReaderLibrary &library)
{ {
out << library.name << library.path << library.legacyId << library.id; out << library.name << library.path << library.legacyId << library.id;

View File

@ -55,6 +55,10 @@ public:
friend QDataStream &operator>>(QDataStream &in, YACReaderLibrary &library); friend QDataStream &operator>>(QDataStream &in, YACReaderLibrary &library);
operator QString() const { return QString("%1 [%2, %3, %4]").arg(name, QString::number(legacyId), id.toString(QUuid::WithoutBraces), path); } operator QString() const { return QString("%1 [%2, %3, %4]").arg(name, QString::number(legacyId), id.toString(QUuid::WithoutBraces), path); }
static QString libraryDataPath(const QString &libraryPath); // libraryPath + /.yacreaderlibrary
static QString libraryDatabasePath(const QString &libraryPath); // libraryPath + /.yacreaderlibrary/library.ydb
static QString libraryCoversFolderPath(const QString &libraryPath); // libraryPath + /.yacreaderlibrary/covers
private: private:
QString name; QString name;
QString path; QString path;