File indexing completed on 2025-01-05 04:26:48

0001 /*
0002  * Replacement fot QT Bindings that were removed from QT5
0003  * Copyright (C) 2020  Pedro de Carvalho Gomes <pedrogomes81@gmail.com>
0004  *
0005  * This program is free software: you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation, either version 3 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #ifndef COREFILE_H
0020 #define COREFILE_H
0021 
0022 #include "QtBinding.h"
0023 #include "CoreIODevice.h"
0024 #include <QFile>
0025 
0026 namespace QtBindings
0027 {
0028     namespace Core
0029     {
0030         class File : public QFile, public QtBindings::Base<File>
0031         {
0032         Q_OBJECT
0033         public:
0034             Q_INVOKABLE File();
0035             Q_INVOKABLE File(const File &file);
0036             Q_INVOKABLE File(const QString &name, QObject *parent);
0037             Q_INVOKABLE File(QObject *parent);
0038             Q_INVOKABLE File(const QString &name);
0039             Q_INVOKABLE virtual ~File();;
0040             Q_INVOKABLE static bool copy(const QString &fileName, const QString &newName);
0041             Q_INVOKABLE static QString decodeName(const char *localFileName);
0042             Q_INVOKABLE static QString decodeName(const QByteArray &localFileName);
0043             Q_INVOKABLE static QByteArray encodeName(const QString &fileName);
0044             Q_INVOKABLE static bool exists(const QString &fileName);
0045             Q_INVOKABLE static bool link(const QString &fileName, const QString &linkName);
0046             Q_INVOKABLE static QFileDevice::Permissions permissions(const QString &fileName);
0047             Q_INVOKABLE static bool remove(const QString &fileName);
0048             Q_INVOKABLE static bool rename(const QString &oldName, const QString &newName);
0049             Q_INVOKABLE static bool resize(const QString &fileName, qint64 sz);
0050             Q_INVOKABLE static bool setPermissions(const QString &fileName, QFileDevice::Permissions permissions);
0051             Q_INVOKABLE static QString symLinkTarget(const QString &fileName);
0052             File &operator=(const File &other);
0053             // Supress warnings about overloading virtual QFile::open
0054             using QFile::open;
0055         public slots:
0056             Q_INVOKABLE virtual void close() override;
0057             Q_INVOKABLE bool copy(const QString &newName);
0058             Q_INVOKABLE bool exists() const;
0059             Q_INVOKABLE virtual QString fileName() const override;
0060             Q_INVOKABLE bool link(const QString &linkName);
0061             //Q_INVOKABLE bool open(FILE *fh, QIODevice::OpenMode mode, QFileDevice::FileHandleFlags handleFlags = DontCloseHandle);
0062             //Q_INVOKABLE bool open(int fd, QIODevice::OpenMode mode, QFileDevice::FileHandleFlags handleFlags = DontCloseHandle);
0063             //Q_INVOKABLE virtual bool open(QIODevice::OpenMode mode) override;
0064             Q_INVOKABLE virtual bool open(QtBindings::Core::IODevice::OpenModeFlag mode);
0065             Q_INVOKABLE virtual QFileDevice::Permissions permissions() const override;
0066             Q_INVOKABLE bool remove();
0067             Q_INVOKABLE bool rename(const QString &newName);
0068             Q_INVOKABLE virtual bool resize(qint64 sz) override;
0069             Q_INVOKABLE void setFileName(const QString &name);
0070             Q_INVOKABLE virtual bool setPermissions(QFileDevice::Permissions permissions) override;
0071             Q_INVOKABLE virtual qint64 size() const override;
0072             Q_INVOKABLE QString symLinkTarget() const;
0073         };
0074     }
0075 }
0076 Q_DECLARE_METATYPE(QtBindings::Core::File)
0077 #endif //COREFILE_H