Skip to content
Snippets Groups Projects
file.h 985 B
Newer Older
akiraohgaki's avatar
akiraohgaki committed
/**
 * A library for Qt app
 *
 * LICENSE: The GNU Lesser General Public License, version 3.0
 *
 * @author      Akira Ohgaki <akiraohgaki@gmail.com>
 * @copyright   Akira Ohgaki
 * @license     https://opensource.org/licenses/LGPL-3.0  The GNU Lesser General Public License, version 3.0
 * @link        https://github.com/akiraohgaki/qtlibs
 */

#pragma once

#include <QObject>

namespace qtlibs {

class File : public QObject
{
    Q_OBJECT

public:
akiraohgaki's avatar
akiraohgaki committed
    explicit File(const QString &path = "", QObject *parent = 0);
akiraohgaki's avatar
akiraohgaki committed

akiraohgaki's avatar
akiraohgaki committed
    File(const File &other, QObject *parent = 0);
akiraohgaki's avatar
akiraohgaki committed
    File &operator =(const File &other);
akiraohgaki's avatar
akiraohgaki committed

    QString path() const;
    void setPath(const QString &path);

    bool exists();
    QByteArray readData();
    bool writeData(const QByteArray &data);
    QString readText();
    bool writeText(const QString &data);
    bool copy(const QString &newPath);
    bool move(const QString &newPath);
    bool remove();

private:
    QString path_;
};

} // namespace qtlibs