refactor
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
#ifndef FILEMANAGER_H
|
||||
#define FILEMANAGER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QStandardPaths>
|
||||
#include <QCoreApplication>
|
||||
|
||||
class FileManager
|
||||
{
|
||||
public:
|
||||
// Типы файлов/папок
|
||||
enum FileType {
|
||||
Sounds,
|
||||
Images,
|
||||
Styles,
|
||||
Voices,
|
||||
Fonts,
|
||||
Temp,
|
||||
Backups,
|
||||
Exports,
|
||||
Logs,
|
||||
Cache,
|
||||
WebServerImages,
|
||||
WebServerSounds,
|
||||
Icons,
|
||||
SystemStyles
|
||||
};
|
||||
|
||||
// Режим копирования
|
||||
enum CopyMode {
|
||||
CopyIfNotExists, // Копировать только если не существует
|
||||
CopyAlways, // Всегда копировать (перезаписывать)
|
||||
CopyWithNewName // Копировать с новым именем (если существует)
|
||||
};
|
||||
|
||||
static FileManager& instance();
|
||||
|
||||
// Основные пути
|
||||
QString systemPath() const;
|
||||
QString userDataPath() const;
|
||||
|
||||
// Получение путей
|
||||
QString getPath(FileType type, const QString& subPath = "") const;
|
||||
QString getFullPath(FileType type, const QString& fileName) const;
|
||||
|
||||
// Копирование файлов
|
||||
bool copyToUserData(const QString& sourceFile, FileType type,
|
||||
CopyMode mode = CopyIfNotExists,
|
||||
QString* newFileName = nullptr);
|
||||
|
||||
// Проверка существования
|
||||
bool existsInUserData(FileType type, const QString& fileName) const;
|
||||
|
||||
// Инициализация структуры папок
|
||||
void initializeFolderStructure();
|
||||
|
||||
// Получение относительного пути для веб-сервера
|
||||
QString getWebPath(FileType type, const QString& fileName) const;
|
||||
|
||||
// Копирование файлов из системных в пользовательские (при первом запуске)
|
||||
void copyDefaultFiles();
|
||||
|
||||
private:
|
||||
FileManager();
|
||||
~FileManager() = default;
|
||||
FileManager(const FileManager&) = delete;
|
||||
FileManager& operator=(const FileManager&) = delete;
|
||||
|
||||
QString m_systemPath;
|
||||
QString m_userDataPath;
|
||||
};
|
||||
|
||||
#endif // FILEMANAGER_H
|
||||
Reference in New Issue
Block a user