CQtDeployer/Deploy/filemanager.h

98 lines
3.3 KiB
C
Raw Normal View History

2019-09-23 16:46:57 +03:00
//#
2019-12-08 13:57:20 +03:00
//# Copyright (C) 2018-2020 QuasarApp.
2019-09-23 16:46:57 +03:00
//# Distributed under the lgplv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
2019-09-03 18:15:05 +03:00
#ifndef COPYPASTEMANAGER_H
#define COPYPASTEMANAGER_H
#include <QFileInfo>
2019-09-03 19:36:06 +03:00
#include <QSet>
2019-09-03 18:15:05 +03:00
#include <QStringList>
#include <deploy_global.h>
2019-09-04 12:01:33 +03:00
class DEPLOYSHARED_EXPORT FileManager
2019-09-03 18:15:05 +03:00
{
private:
bool fileActionPrivate(const QString &file, const QString &target,
QStringList *mask, bool isMove, bool targetIsFile);
2019-09-03 18:15:05 +03:00
2019-09-03 19:36:06 +03:00
QSet<QString> _deployedFiles;
2019-09-03 18:15:05 +03:00
2020-07-04 23:08:41 +03:00
/**
* @brief changeDistanation - this function create new distanation path.
* (merge base path and pathFrom with depth)
* @param absalutePath
* @param basePath
* @param depch
* @return the new path
*/
QString changeDistanation(const QString &absalutePath, QString basePath, int depch);
2019-09-03 18:15:05 +03:00
public:
2019-09-04 12:01:33 +03:00
FileManager();
2020-12-03 20:00:14 +03:00
bool initDir(const QString &path);
2019-09-03 18:15:05 +03:00
bool copyFile(const QString &file, const QString &target,
QStringList *mask = nullptr, bool targetIsFile = false);
2019-09-03 18:15:05 +03:00
/**
* @brief copyFiles - copy files (source) to (to)
* @param source - copy source files
* @param to - distanation folder
* @param saveStructSize - size of name of source file to save after copy. example:
* copy /Foo/A.txt /Bar/ (size 0) - result file copyed to /Bar/A.txt
* copy /Foo/A.txt /Bar/ (size 1) - to /Bar/Foo/A.txt
* @param filter - list of forbiden names for ignore files
* @param listOfCopiedItems - list of copyed files
* @param mask - mask of copyed files
* @return true if files copyed
*/
bool copyFiles(const QStringList &source, const QString &to, int saveStructSize = 0,
const QStringList &filter = QStringList(),
QStringList *listOfCopiedItems = nullptr,
QStringList *mask = nullptr);
2019-09-03 18:15:05 +03:00
bool removeFile(const QString &file);
bool removeFile(const QFileInfo &file);
/**
* @brief smartCopyFile
* @param file
* @param target
* @param mask
* @param ifFileTarget
2019-09-03 18:15:05 +03:00
* @return if file in target dir try move file else copy
*/
2019-09-25 12:32:05 +03:00
bool smartCopyFile(const QString &file, const QString &target,
QStringList *mask = nullptr, bool ifFileTarget = false);
2019-09-03 18:15:05 +03:00
bool moveFile(const QString &file, const QString &target,
QStringList *mask = nullptr, bool targetIsFile = false);
2019-09-03 18:15:05 +03:00
bool copyFolder(const QString &from, const QString &to,
const QStringList &filter = QStringList(),
QStringList *listOfCopiedItems = nullptr,
2020-08-15 19:29:17 +03:00
QStringList *mask = nullptr, bool force = false);
2019-09-03 18:15:05 +03:00
2020-08-15 14:38:03 +03:00
bool moveFolder(const QString &from, const QString &to, const QString &ignore = "");
2020-01-15 18:31:09 +03:00
2019-09-04 12:01:33 +03:00
void clear(const QString& targetDir, bool force);
2019-09-03 18:15:05 +03:00
2019-09-03 19:36:06 +03:00
QStringList getDeployedFilesStringList() const;
2019-09-04 12:01:33 +03:00
QSet<QString> getDeployedFiles() const;
2019-09-03 19:36:06 +03:00
bool strip(const QString &dir) const;
bool addToDeployed(const QString& path);
2020-04-25 16:59:20 +03:00
void removeFromDeployed(const QString& path);
2019-09-03 19:36:06 +03:00
2019-09-04 12:01:33 +03:00
void saveDeploymendFiles(const QString &targetDir);
void loadDeployemendFiles(const QString &targetDir);
2019-09-03 18:15:05 +03:00
};
#endif // COPYPASTEMANAGER_H