1 /*
2  * Replacement fot QT Bindings that were removed from QT5
3  * Copyright (C) 2020  Pedro de Carvalho Gomes <pedrogomes81@gmail.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include "CoreFile.h"
20 
21 using namespace QtBindings::Core;
22 
File()23 File::File()
24 {
25 }
26 
File(const File & file)27 File::File(const File &file) : QFile()
28 {
29     *this = file;
30 }
31 
File(const QString & name,QObject * parent)32 File::File(const QString &name, QObject *parent) : QFile(name, parent)
33 {
34 }
35 
File(QObject * parent)36 File::File(QObject *parent) : QFile(parent)
37 {
38 }
39 
File(const QString & name)40 File::File(const QString &name) : QFile(name)
41 {
42 }
43 
~File()44 File::~File()
45 {
46 }
47 
close()48 void File::close()
49 {
50     QFile::close();
51 }
52 
copy(const QString & fileName,const QString & newName)53 bool File::copy(const QString &fileName, const QString &newName)
54 {
55     return QFile::copy(fileName,newName);
56 }
57 
decodeName(const char * localFileName)58 QString File::decodeName(const char *localFileName)
59 {
60     return QFile::decodeName(localFileName);
61 }
62 
decodeName(const QByteArray & localFileName)63 QString File::decodeName(const QByteArray &localFileName)
64 {
65     return QFile::decodeName(localFileName);
66 }
67 
encodeName(const QString & fileName)68 QByteArray File::encodeName(const QString &fileName)
69 {
70     return QFile::encodeName(fileName);
71 }
72 
exists(const QString & fileName)73 bool File::exists(const QString &fileName)
74 {
75     return QFile::exists(fileName);
76 }
77 
link(const QString & fileName,const QString & linkName)78 bool File::link(const QString &fileName, const QString &linkName)
79 {
80     return QFile::link(fileName,linkName);
81 }
82 
permissions(const QString & fileName)83 QFileDevice::Permissions File::permissions(const QString &fileName)
84 {
85     return QFile::permissions(fileName);
86 }
87 
remove(const QString & fileName)88 bool File::remove(const QString &fileName)
89 {
90     return QFile::remove(fileName);
91 }
92 
rename(const QString & oldName,const QString & newName)93 bool File::rename(const QString &oldName, const QString &newName)
94 {
95     return QFile::rename(oldName,newName);
96 }
97 
resize(const QString & fileName,qint64 sz)98 bool File::resize(const QString &fileName, qint64 sz)
99 {
100     return QFile::resize(fileName,sz);
101 }
102 
setPermissions(const QString & fileName,QFileDevice::Permissions permissions)103 bool File::setPermissions(const QString &fileName,
104                                             QFileDevice::Permissions permissions)
105 {
106     return QFile::setPermissions(fileName,permissions);
107 }
108 
symLinkTarget(const QString & fileName)109 QString File::symLinkTarget(const QString &fileName)
110 {
111     return QFile::symLinkTarget(fileName);
112 }
113 
copy(const QString & newName)114 bool File::copy(const QString &newName)
115 {
116     return QFile::copy(newName);
117 }
118 
exists() const119 bool File::exists() const
120 {
121     return QFile::exists();
122 }
123 
fileName() const124 QString File::fileName() const
125 {
126     return QFile::fileName();
127 }
128 
link(const QString & linkName)129 bool File::link(const QString &linkName)
130 {
131     return QFile::link(linkName);
132 }
133 /*
134 bool File::open(FILE *fh, QIODevice::OpenMode mode,
135                                   QFileDevice::FileHandleFlags handleFlags)
136 {
137     return QFile::open(fh, mode, handleFlags);
138 }
139 
140 bool File::open(int fd, QIODevice::OpenMode mode,
141                                   QFileDevice::FileHandleFlags handleFlags)
142 {
143     return QFile::open(fd, mode, handleFlags);
144 }
145 
146 bool File::open(QIODevice::OpenMode mode)
147 {
148     return QFile::open(mode);
149 }
150 */
151 
open(QtBindings::Core::IODevice::OpenModeFlag mode)152 bool File::open(QtBindings::Core::IODevice::OpenModeFlag mode)
153 {
154     return QFile::open( QIODevice::OpenMode(mode) );
155 }
156 
permissions() const157 QFileDevice::Permissions File::permissions() const
158 {
159     return QFile::permissions();
160 }
161 
remove()162 bool File::remove()
163 {
164     return QFile::remove();
165 }
166 
rename(const QString & newName)167 bool File::rename(const QString &newName)
168 {
169     return QFile::rename(newName);
170 }
171 
resize(qint64 sz)172 bool File::resize(qint64 sz)
173 {
174     return QFile::resize(sz);
175 }
176 
setFileName(const QString & name)177 void File::setFileName(const QString &name)
178 {
179     QFile::setFileName(name);
180 }
181 
setPermissions(QFileDevice::Permissions permissions)182 bool File::setPermissions(QFileDevice::Permissions permissions)
183 {
184     return QFile::setPermissions(permissions);
185 }
186 
size() const187 qint64 File::size() const
188 {
189     return QFile::size();
190 }
191 
symLinkTarget() const192 QString File::symLinkTarget() const
193 {
194     return QFile::symLinkTarget();
195 }
196 
operator =(const File & other)197 File &File::operator=(const File &other)
198 {
199     if (this != &other ) {
200         this->setFileName(other.fileName());
201         this->setPermissions(other.permissions());
202         this->setCurrentReadChannel(other.currentReadChannel());
203         this->setCurrentWriteChannel(other.currentWriteChannel());
204         this->setTextModeEnabled(other.isTextModeEnabled());
205         this->setErrorString(other.errorString());
206         this->setOpenMode(other.openMode());
207     }
208     return *this;
209 }
210