2020-10-13 16:43:18 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QtCore/QDateTime>
|
|
|
|
|
2022-02-26 16:08:44 +00:00
|
|
|
class QFileInfo;
|
|
|
|
|
2020-10-13 16:43:18 +00:00
|
|
|
namespace Platform {
|
|
|
|
class FileBookmark;
|
|
|
|
} // namespace Platform
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
class ReadAccessEnabler {
|
|
|
|
public:
|
|
|
|
ReadAccessEnabler(const Platform::FileBookmark *bookmark);
|
|
|
|
ReadAccessEnabler(
|
|
|
|
const std::shared_ptr<Platform::FileBookmark> &bookmark);
|
|
|
|
bool failed() const {
|
|
|
|
return _failed;
|
|
|
|
}
|
|
|
|
~ReadAccessEnabler();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const Platform::FileBookmark *_bookmark = nullptr;
|
|
|
|
bool _failed;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class FileLocation {
|
|
|
|
public:
|
|
|
|
FileLocation() = default;
|
|
|
|
explicit FileLocation(const QString &name);
|
2022-02-26 16:08:44 +00:00
|
|
|
explicit FileLocation(const QFileInfo &info);
|
2020-10-13 16:43:18 +00:00
|
|
|
|
|
|
|
static FileLocation InMediaCacheLocation();
|
|
|
|
|
|
|
|
[[nodiscard]] bool check() const;
|
|
|
|
[[nodiscard]] const QString &name() const;
|
|
|
|
void setBookmark(const QByteArray &bookmark);
|
|
|
|
QByteArray bookmark() const;
|
|
|
|
[[nodiscard]] bool isEmpty() const {
|
|
|
|
return name().isEmpty();
|
|
|
|
}
|
|
|
|
[[nodiscard]] bool inMediaCache() const;
|
|
|
|
|
|
|
|
bool accessEnable() const;
|
|
|
|
void accessDisable() const;
|
|
|
|
|
|
|
|
QString fname;
|
|
|
|
QDateTime modified;
|
2022-05-12 08:04:36 +00:00
|
|
|
qint64 size = 0;
|
2020-10-13 16:43:18 +00:00
|
|
|
|
|
|
|
private:
|
2022-02-26 16:08:44 +00:00
|
|
|
void resolveFromInfo(const QFileInfo &info);
|
|
|
|
|
2020-10-13 16:43:18 +00:00
|
|
|
std::shared_ptr<Platform::FileBookmark> _bookmark;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
inline bool operator==(const FileLocation &a, const FileLocation &b) {
|
|
|
|
return (a.name() == b.name())
|
|
|
|
&& (a.modified == b.modified)
|
|
|
|
&& (a.size == b.size);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator!=(const FileLocation &a, const FileLocation &b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Core
|