/*! * * Copyright (c) 2020-2022 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file FileHandler.h * \author (last) Behrouz NematiPour * \date (last) 10-Aug-2021 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #pragma once // Qt #include #include #include #include #include class QDate; namespace Storage { /*! * \brief The FileHandler class * This class is suppose to be the static class * which contains methods to manipulate files and folders * Since it is static it does not have thread so needs to be used with care * and the classes which are using it need to take care of the threading. */ class FileHandler { static void errOut(const QString &vMessage); public: static bool write (const QString &vFileName, const QString &vContent, bool vAppend = true); static bool read (const QString &vFileName, QString &vContent); static bool read (const QString &vFileName, QJsonObject &vContent, QJsonParseError *error = nullptr); static int copyFolder (const QString &vSource , const QString &vDestination); static int moveFolder (const QString &vSource , const QString &vDestination); static int removeFolder(const QString &vFolder); static int removeFiles (const QStringList &vFolders, const QStringList &vNameFilter, const QDate &vDateOlderThan); static bool makeFolder (const QString &vFolder); static bool isMounted (const QString &vPath, bool *vIsReadOnly = nullptr); static QFileInfoList find(const QString &vPath, QStringList vNameFilters, quint8 vRetainPercent); static QFileInfoList find(const QString &vPath, QStringList vNameFilters); static quint64 totalSize(const QFileInfoList &vFileInfoList); static QStringList subFolders(const QString &vFolder); }; }