| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/kernel/qurlinfo.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
| 9 | ** Commercial License Usage | - | ||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
| 16 | ** | - | ||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
| 24 | ** | - | ||||||
| 25 | ** GNU General Public License Usage | - | ||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
| 35 | ** | - | ||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||
| 37 | ** | - | ||||||
| 38 | ****************************************************************************/ | - | ||||||
| 39 | - | |||||||
| 40 | #include "qurlinfo_p.h" | - | ||||||
| 41 | - | |||||||
| 42 | #ifndef QT_NO_FTP | - | ||||||
| 43 | - | |||||||
| 44 | #include "qurl.h" | - | ||||||
| 45 | #include "qdir.h" | - | ||||||
| 46 | #include <limits.h> | - | ||||||
| 47 | - | |||||||
| 48 | QT_BEGIN_NAMESPACE | - | ||||||
| 49 | - | |||||||
| 50 | class QUrlInfoPrivate | - | ||||||
| 51 | { | - | ||||||
| 52 | public: | - | ||||||
| 53 | QUrlInfoPrivate() : | - | ||||||
| 54 | permissions(0), | - | ||||||
| 55 | size(0), | - | ||||||
| 56 | isDir(false), | - | ||||||
| 57 | isFile(true), | - | ||||||
| 58 | isSymLink(false), | - | ||||||
| 59 | isWritable(true), | - | ||||||
| 60 | isReadable(true), | - | ||||||
| 61 | isExecutable(false) | - | ||||||
| 62 | {} executed 730 times by 1 test: end of blockExecuted by:
| 730 | ||||||
| 63 | - | |||||||
| 64 | QString name; | - | ||||||
| 65 | int permissions; | - | ||||||
| 66 | QString owner; | - | ||||||
| 67 | QString group; | - | ||||||
| 68 | qint64 size; | - | ||||||
| 69 | - | |||||||
| 70 | QDateTime lastModified; | - | ||||||
| 71 | QDateTime lastRead; | - | ||||||
| 72 | bool isDir; | - | ||||||
| 73 | bool isFile; | - | ||||||
| 74 | bool isSymLink; | - | ||||||
| 75 | bool isWritable; | - | ||||||
| 76 | bool isReadable; | - | ||||||
| 77 | bool isExecutable; | - | ||||||
| 78 | }; | - | ||||||
| 79 | - | |||||||
| 80 | - | |||||||
| 81 | /*! | - | ||||||
| 82 | \class QUrlInfo | - | ||||||
| 83 | \brief The QUrlInfo class stores information about URLs. | - | ||||||
| 84 | - | |||||||
| 85 | \internal | - | ||||||
| 86 | \ingroup io | - | ||||||
| 87 | \ingroup network | - | ||||||
| 88 | \inmodule QtNetwork | - | ||||||
| 89 | - | |||||||
| 90 | The information about a URL that can be retrieved includes name(), | - | ||||||
| 91 | permissions(), owner(), group(), size(), lastModified(), | - | ||||||
| 92 | lastRead(), isDir(), isFile(), isSymLink(), isWritable(), | - | ||||||
| 93 | isReadable() and isExecutable(). | - | ||||||
| 94 | - | |||||||
| 95 | You can create your own QUrlInfo objects passing in all the | - | ||||||
| 96 | relevant information in the constructor, and you can modify a | - | ||||||
| 97 | QUrlInfo; for each getter mentioned above there is an equivalent | - | ||||||
| 98 | setter. Note that setting values does not affect the underlying | - | ||||||
| 99 | resource that the QUrlInfo provides information about; for example | - | ||||||
| 100 | if you call setWritable(true) on a read-only resource the only | - | ||||||
| 101 | thing changed is the QUrlInfo object, not the resource. | - | ||||||
| 102 | - | |||||||
| 103 | \sa QUrl, {FTP Example} | - | ||||||
| 104 | */ | - | ||||||
| 105 | - | |||||||
| 106 | /*! | - | ||||||
| 107 | \enum QUrlInfo::PermissionSpec | - | ||||||
| 108 | - | |||||||
| 109 | This enum is used by the permissions() function to report the | - | ||||||
| 110 | permissions of a file. | - | ||||||
| 111 | - | |||||||
| 112 | \value ReadOwner The file is readable by the owner of the file. | - | ||||||
| 113 | \value WriteOwner The file is writable by the owner of the file. | - | ||||||
| 114 | \value ExeOwner The file is executable by the owner of the file. | - | ||||||
| 115 | \value ReadGroup The file is readable by the group. | - | ||||||
| 116 | \value WriteGroup The file is writable by the group. | - | ||||||
| 117 | \value ExeGroup The file is executable by the group. | - | ||||||
| 118 | \value ReadOther The file is readable by anyone. | - | ||||||
| 119 | \value WriteOther The file is writable by anyone. | - | ||||||
| 120 | \value ExeOther The file is executable by anyone. | - | ||||||
| 121 | */ | - | ||||||
| 122 | - | |||||||
| 123 | /*! | - | ||||||
| 124 | Constructs an invalid QUrlInfo object with default values. | - | ||||||
| 125 | - | |||||||
| 126 | \sa isValid() | - | ||||||
| 127 | */ | - | ||||||
| 128 | - | |||||||
| 129 | QUrlInfo::QUrlInfo() | - | ||||||
| 130 | { | - | ||||||
| 131 | d = 0; | - | ||||||
| 132 | } executed 374 times by 1 test: end of blockExecuted by:
| 374 | ||||||
| 133 | - | |||||||
| 134 | /*! | - | ||||||
| 135 | Copy constructor, copies \a ui to this URL info object. | - | ||||||
| 136 | */ | - | ||||||
| 137 | - | |||||||
| 138 | QUrlInfo::QUrlInfo(const QUrlInfo &ui) | - | ||||||
| 139 | { | - | ||||||
| 140 | if (ui.d) {
| 0-358 | ||||||
| 141 | d = new QUrlInfoPrivate; | - | ||||||
| 142 | *d = *ui.d; | - | ||||||
| 143 | } else { executed 358 times by 1 test: end of blockExecuted by:
| 358 | ||||||
| 144 | d = 0; | - | ||||||
| 145 | } never executed: end of block | 0 | ||||||
| 146 | } | - | ||||||
| 147 | - | |||||||
| 148 | /*! | - | ||||||
| 149 | Constructs a QUrlInfo object by specifying all the URL's | - | ||||||
| 150 | information. | - | ||||||
| 151 | - | |||||||
| 152 | The information that is passed is the \a name, file \a | - | ||||||
| 153 | permissions, \a owner and \a group and the file's \a size. Also | - | ||||||
| 154 | passed is the \a lastModified date/time and the \a lastRead | - | ||||||
| 155 | date/time. Flags are also passed, specifically, \a isDir, \a | - | ||||||
| 156 | isFile, \a isSymLink, \a isWritable, \a isReadable and \a | - | ||||||
| 157 | isExecutable. | - | ||||||
| 158 | */ | - | ||||||
| 159 | - | |||||||
| 160 | QUrlInfo::QUrlInfo(const QString &name, int permissions, const QString &owner, | - | ||||||
| 161 | const QString &group, qint64 size, const QDateTime &lastModified, | - | ||||||
| 162 | const QDateTime &lastRead, bool isDir, bool isFile, bool isSymLink, | - | ||||||
| 163 | bool isWritable, bool isReadable, bool isExecutable) | - | ||||||
| 164 | { | - | ||||||
| 165 | d = new QUrlInfoPrivate; | - | ||||||
| 166 | d->name = name; | - | ||||||
| 167 | d->permissions = permissions; | - | ||||||
| 168 | d->owner = owner; | - | ||||||
| 169 | d->group = group; | - | ||||||
| 170 | d->size = size; | - | ||||||
| 171 | d->lastModified = lastModified; | - | ||||||
| 172 | d->lastRead = lastRead; | - | ||||||
| 173 | d->isDir = isDir; | - | ||||||
| 174 | d->isFile = isFile; | - | ||||||
| 175 | d->isSymLink = isSymLink; | - | ||||||
| 176 | d->isWritable = isWritable; | - | ||||||
| 177 | d->isReadable = isReadable; | - | ||||||
| 178 | d->isExecutable = isExecutable; | - | ||||||
| 179 | } never executed: end of block | 0 | ||||||
| 180 | - | |||||||
| 181 | - | |||||||
| 182 | /*! | - | ||||||
| 183 | Constructs a QUrlInfo object by specifying all the URL's | - | ||||||
| 184 | information. | - | ||||||
| 185 | - | |||||||
| 186 | The information that is passed is the \a url, file \a | - | ||||||
| 187 | permissions, \a owner and \a group and the file's \a size. Also | - | ||||||
| 188 | passed is the \a lastModified date/time and the \a lastRead | - | ||||||
| 189 | date/time. Flags are also passed, specifically, \a isDir, \a | - | ||||||
| 190 | isFile, \a isSymLink, \a isWritable, \a isReadable and \a | - | ||||||
| 191 | isExecutable. | - | ||||||
| 192 | */ | - | ||||||
| 193 | - | |||||||
| 194 | QUrlInfo::QUrlInfo(const QUrl &url, int permissions, const QString &owner, | - | ||||||
| 195 | const QString &group, qint64 size, const QDateTime &lastModified, | - | ||||||
| 196 | const QDateTime &lastRead, bool isDir, bool isFile, bool isSymLink, | - | ||||||
| 197 | bool isWritable, bool isReadable, bool isExecutable) | - | ||||||
| 198 | { | - | ||||||
| 199 | d = new QUrlInfoPrivate; | - | ||||||
| 200 | d->name = QFileInfo(url.path()).fileName(); | - | ||||||
| 201 | d->permissions = permissions; | - | ||||||
| 202 | d->owner = owner; | - | ||||||
| 203 | d->group = group; | - | ||||||
| 204 | d->size = size; | - | ||||||
| 205 | d->lastModified = lastModified; | - | ||||||
| 206 | d->lastRead = lastRead; | - | ||||||
| 207 | d->isDir = isDir; | - | ||||||
| 208 | d->isFile = isFile; | - | ||||||
| 209 | d->isSymLink = isSymLink; | - | ||||||
| 210 | d->isWritable = isWritable; | - | ||||||
| 211 | d->isReadable = isReadable; | - | ||||||
| 212 | d->isExecutable = isExecutable; | - | ||||||
| 213 | } never executed: end of block | 0 | ||||||
| 214 | - | |||||||
| 215 | - | |||||||
| 216 | /*! | - | ||||||
| 217 | Sets the name of the URL to \a name. The name is the full text, | - | ||||||
| 218 | for example, "http://qt-project.org/doc/qt-5.0/qtcore/qurl.html". | - | ||||||
| 219 | - | |||||||
| 220 | If you call this function for an invalid URL info, this function | - | ||||||
| 221 | turns it into a valid one. | - | ||||||
| 222 | - | |||||||
| 223 | \sa isValid() | - | ||||||
| 224 | */ | - | ||||||
| 225 | - | |||||||
| 226 | void QUrlInfo::setName(const QString &name) | - | ||||||
| 227 | { | - | ||||||
| 228 | if (!d)
| 0-372 | ||||||
| 229 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 230 | d->name = name; | - | ||||||
| 231 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 232 | - | |||||||
| 233 | - | |||||||
| 234 | /*! | - | ||||||
| 235 | If \a b is true then the URL is set to be a directory; if \a b is | - | ||||||
| 236 | false then the URL is set not to be a directory (which normally | - | ||||||
| 237 | means it is a file). (Note that a URL can refer to both a file and | - | ||||||
| 238 | a directory even though most file systems do not support this.) | - | ||||||
| 239 | - | |||||||
| 240 | If you call this function for an invalid URL info, this function | - | ||||||
| 241 | turns it into a valid one. | - | ||||||
| 242 | - | |||||||
| 243 | \sa isValid() | - | ||||||
| 244 | */ | - | ||||||
| 245 | - | |||||||
| 246 | void QUrlInfo::setDir(bool b) | - | ||||||
| 247 | { | - | ||||||
| 248 | if (!d)
| 0-372 | ||||||
| 249 | d = new QUrlInfoPrivate; executed 372 times by 1 test: d = new QUrlInfoPrivate;Executed by:
| 372 | ||||||
| 250 | d->isDir = b; | - | ||||||
| 251 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 252 | - | |||||||
| 253 | - | |||||||
| 254 | /*! | - | ||||||
| 255 | If \a b is true then the URL is set to be a file; if \b is false | - | ||||||
| 256 | then the URL is set not to be a file (which normally means it is a | - | ||||||
| 257 | directory). (Note that a URL can refer to both a file and a | - | ||||||
| 258 | directory even though most file systems do not support this.) | - | ||||||
| 259 | - | |||||||
| 260 | If you call this function for an invalid URL info, this function | - | ||||||
| 261 | turns it into a valid one. | - | ||||||
| 262 | - | |||||||
| 263 | \sa isValid() | - | ||||||
| 264 | */ | - | ||||||
| 265 | - | |||||||
| 266 | void QUrlInfo::setFile(bool b) | - | ||||||
| 267 | { | - | ||||||
| 268 | if (!d)
| 0-372 | ||||||
| 269 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 270 | d->isFile = b; | - | ||||||
| 271 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 272 | - | |||||||
| 273 | - | |||||||
| 274 | /*! | - | ||||||
| 275 | Specifies that the URL refers to a symbolic link if \a b is true | - | ||||||
| 276 | and that it does not if \a b is false. | - | ||||||
| 277 | - | |||||||
| 278 | If you call this function for an invalid URL info, this function | - | ||||||
| 279 | turns it into a valid one. | - | ||||||
| 280 | - | |||||||
| 281 | \sa isValid() | - | ||||||
| 282 | */ | - | ||||||
| 283 | - | |||||||
| 284 | void QUrlInfo::setSymLink(bool b) | - | ||||||
| 285 | { | - | ||||||
| 286 | if (!d)
| 0-372 | ||||||
| 287 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 288 | d->isSymLink = b; | - | ||||||
| 289 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 290 | - | |||||||
| 291 | - | |||||||
| 292 | /*! | - | ||||||
| 293 | Specifies that the URL is writable if \a b is true and not | - | ||||||
| 294 | writable if \a b is false. | - | ||||||
| 295 | - | |||||||
| 296 | If you call this function for an invalid URL info, this function | - | ||||||
| 297 | turns it into a valid one. | - | ||||||
| 298 | - | |||||||
| 299 | \sa isValid() | - | ||||||
| 300 | */ | - | ||||||
| 301 | - | |||||||
| 302 | void QUrlInfo::setWritable(bool b) | - | ||||||
| 303 | { | - | ||||||
| 304 | if (!d)
| 0-372 | ||||||
| 305 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 306 | d->isWritable = b; | - | ||||||
| 307 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 308 | - | |||||||
| 309 | - | |||||||
| 310 | /*! | - | ||||||
| 311 | Specifies that the URL is readable if \a b is true and not | - | ||||||
| 312 | readable if \a b is false. | - | ||||||
| 313 | - | |||||||
| 314 | If you call this function for an invalid URL info, this function | - | ||||||
| 315 | turns it into a valid one. | - | ||||||
| 316 | - | |||||||
| 317 | \sa isValid() | - | ||||||
| 318 | */ | - | ||||||
| 319 | - | |||||||
| 320 | void QUrlInfo::setReadable(bool b) | - | ||||||
| 321 | { | - | ||||||
| 322 | if (!d)
| 0-372 | ||||||
| 323 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 324 | d->isReadable = b; | - | ||||||
| 325 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 326 | - | |||||||
| 327 | /*! | - | ||||||
| 328 | Specifies that the owner of the URL is called \a s. | - | ||||||
| 329 | - | |||||||
| 330 | If you call this function for an invalid URL info, this function | - | ||||||
| 331 | turns it into a valid one. | - | ||||||
| 332 | - | |||||||
| 333 | \sa isValid() | - | ||||||
| 334 | */ | - | ||||||
| 335 | - | |||||||
| 336 | void QUrlInfo::setOwner(const QString &s) | - | ||||||
| 337 | { | - | ||||||
| 338 | if (!d)
| 0-372 | ||||||
| 339 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 340 | d->owner = s; | - | ||||||
| 341 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 342 | - | |||||||
| 343 | /*! | - | ||||||
| 344 | Specifies that the owning group of the URL is called \a s. | - | ||||||
| 345 | - | |||||||
| 346 | If you call this function for an invalid URL info, this function | - | ||||||
| 347 | turns it into a valid one. | - | ||||||
| 348 | - | |||||||
| 349 | \sa isValid() | - | ||||||
| 350 | */ | - | ||||||
| 351 | - | |||||||
| 352 | void QUrlInfo::setGroup(const QString &s) | - | ||||||
| 353 | { | - | ||||||
| 354 | if (!d)
| 0-372 | ||||||
| 355 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 356 | d->group = s; | - | ||||||
| 357 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 358 | - | |||||||
| 359 | /*! | - | ||||||
| 360 | Specifies the \a size of the URL. | - | ||||||
| 361 | - | |||||||
| 362 | If you call this function for an invalid URL info, this function | - | ||||||
| 363 | turns it into a valid one. | - | ||||||
| 364 | - | |||||||
| 365 | \sa isValid() | - | ||||||
| 366 | */ | - | ||||||
| 367 | - | |||||||
| 368 | void QUrlInfo::setSize(qint64 size) | - | ||||||
| 369 | { | - | ||||||
| 370 | if (!d)
| 0-372 | ||||||
| 371 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 372 | d->size = size; | - | ||||||
| 373 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 374 | - | |||||||
| 375 | /*! | - | ||||||
| 376 | Specifies that the URL has access permissions \a p. | - | ||||||
| 377 | - | |||||||
| 378 | If you call this function for an invalid URL info, this function | - | ||||||
| 379 | turns it into a valid one. | - | ||||||
| 380 | - | |||||||
| 381 | \sa isValid() | - | ||||||
| 382 | */ | - | ||||||
| 383 | - | |||||||
| 384 | void QUrlInfo::setPermissions(int p) | - | ||||||
| 385 | { | - | ||||||
| 386 | if (!d)
| 0-372 | ||||||
| 387 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 388 | d->permissions = p; | - | ||||||
| 389 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 390 | - | |||||||
| 391 | /*! | - | ||||||
| 392 | Specifies that the object the URL refers to was last modified at | - | ||||||
| 393 | \a dt. | - | ||||||
| 394 | - | |||||||
| 395 | If you call this function for an invalid URL info, this function | - | ||||||
| 396 | turns it into a valid one. | - | ||||||
| 397 | - | |||||||
| 398 | \sa isValid() | - | ||||||
| 399 | */ | - | ||||||
| 400 | - | |||||||
| 401 | void QUrlInfo::setLastModified(const QDateTime &dt) | - | ||||||
| 402 | { | - | ||||||
| 403 | if (!d)
| 0-372 | ||||||
| 404 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 405 | d->lastModified = dt; | - | ||||||
| 406 | } executed 372 times by 1 test: end of blockExecuted by:
| 372 | ||||||
| 407 | - | |||||||
| 408 | /*! | - | ||||||
| 409 | \since 4.4 | - | ||||||
| 410 | - | |||||||
| 411 | Specifies that the object the URL refers to was last read at | - | ||||||
| 412 | \a dt. | - | ||||||
| 413 | - | |||||||
| 414 | If you call this function for an invalid URL info, this function | - | ||||||
| 415 | turns it into a valid one. | - | ||||||
| 416 | - | |||||||
| 417 | \sa isValid() | - | ||||||
| 418 | */ | - | ||||||
| 419 | - | |||||||
| 420 | void QUrlInfo::setLastRead(const QDateTime &dt) | - | ||||||
| 421 | { | - | ||||||
| 422 | if (!d)
| 0 | ||||||
| 423 | d = new QUrlInfoPrivate; never executed: d = new QUrlInfoPrivate; | 0 | ||||||
| 424 | d->lastRead = dt; | - | ||||||
| 425 | } never executed: end of block | 0 | ||||||
| 426 | - | |||||||
| 427 | /*! | - | ||||||
| 428 | Destroys the URL info object. | - | ||||||
| 429 | */ | - | ||||||
| 430 | - | |||||||
| 431 | QUrlInfo::~QUrlInfo() | - | ||||||
| 432 | { | - | ||||||
| 433 | delete d; | - | ||||||
| 434 | } executed 732 times by 1 test: end of blockExecuted by:
| 732 | ||||||
| 435 | - | |||||||
| 436 | /*! | - | ||||||
| 437 | Assigns the values of \a ui to this QUrlInfo object. | - | ||||||
| 438 | */ | - | ||||||
| 439 | - | |||||||
| 440 | QUrlInfo &QUrlInfo::operator=(const QUrlInfo &ui) | - | ||||||
| 441 | { | - | ||||||
| 442 | if (ui.d) {
| 0 | ||||||
| 443 | if (!d)
| 0 | ||||||
| 444 | d= new QUrlInfoPrivate; never executed: d= new QUrlInfoPrivate; | 0 | ||||||
| 445 | *d = *ui.d; | - | ||||||
| 446 | } else { never executed: end of block | 0 | ||||||
| 447 | delete d; | - | ||||||
| 448 | d = 0; | - | ||||||
| 449 | } never executed: end of block | 0 | ||||||
| 450 | return *this; never executed: return *this; | 0 | ||||||
| 451 | } | - | ||||||
| 452 | - | |||||||
| 453 | /*! | - | ||||||
| 454 | Returns the file name of the URL. | - | ||||||
| 455 | - | |||||||
| 456 | \sa isValid() | - | ||||||
| 457 | */ | - | ||||||
| 458 | - | |||||||
| 459 | QString QUrlInfo::name() const | - | ||||||
| 460 | { | - | ||||||
| 461 | if (!d)
| 0-340 | ||||||
| 462 | return QString(); never executed: return QString(); | 0 | ||||||
| 463 | return d->name; executed 340 times by 1 test: return d->name;Executed by:
| 340 | ||||||
| 464 | } | - | ||||||
| 465 | - | |||||||
| 466 | /*! | - | ||||||
| 467 | Returns the permissions of the URL. You can use the \c PermissionSpec flags | - | ||||||
| 468 | to test for certain permissions. | - | ||||||
| 469 | - | |||||||
| 470 | \sa isValid() | - | ||||||
| 471 | */ | - | ||||||
| 472 | - | |||||||
| 473 | int QUrlInfo::permissions() const | - | ||||||
| 474 | { | - | ||||||
| 475 | if (!d)
| 0 | ||||||
| 476 | return 0; never executed: return 0; | 0 | ||||||
| 477 | return d->permissions; never executed: return d->permissions; | 0 | ||||||
| 478 | } | - | ||||||
| 479 | - | |||||||
| 480 | /*! | - | ||||||
| 481 | Returns the owner of the URL. | - | ||||||
| 482 | - | |||||||
| 483 | \sa isValid() | - | ||||||
| 484 | */ | - | ||||||
| 485 | - | |||||||
| 486 | QString QUrlInfo::owner() const | - | ||||||
| 487 | { | - | ||||||
| 488 | if (!d)
| 0-372 | ||||||
| 489 | return QString(); never executed: return QString(); | 0 | ||||||
| 490 | return d->owner; executed 372 times by 1 test: return d->owner;Executed by:
| 372 | ||||||
| 491 | } | - | ||||||
| 492 | - | |||||||
| 493 | /*! | - | ||||||
| 494 | Returns the group of the URL. | - | ||||||
| 495 | - | |||||||
| 496 | \sa isValid() | - | ||||||
| 497 | */ | - | ||||||
| 498 | - | |||||||
| 499 | QString QUrlInfo::group() const | - | ||||||
| 500 | { | - | ||||||
| 501 | if (!d)
| 0 | ||||||
| 502 | return QString(); never executed: return QString(); | 0 | ||||||
| 503 | return d->group; never executed: return d->group; | 0 | ||||||
| 504 | } | - | ||||||
| 505 | - | |||||||
| 506 | /*! | - | ||||||
| 507 | Returns the size of the URL. | - | ||||||
| 508 | - | |||||||
| 509 | \sa isValid() | - | ||||||
| 510 | */ | - | ||||||
| 511 | - | |||||||
| 512 | qint64 QUrlInfo::size() const | - | ||||||
| 513 | { | - | ||||||
| 514 | if (!d)
| 0 | ||||||
| 515 | return 0; never executed: return 0; | 0 | ||||||
| 516 | return d->size; never executed: return d->size; | 0 | ||||||
| 517 | } | - | ||||||
| 518 | - | |||||||
| 519 | /*! | - | ||||||
| 520 | Returns the last modification date of the URL. | - | ||||||
| 521 | - | |||||||
| 522 | \sa isValid() | - | ||||||
| 523 | */ | - | ||||||
| 524 | - | |||||||
| 525 | QDateTime QUrlInfo::lastModified() const | - | ||||||
| 526 | { | - | ||||||
| 527 | if (!d)
| 0 | ||||||
| 528 | return QDateTime(); never executed: return QDateTime(); | 0 | ||||||
| 529 | return d->lastModified; never executed: return d->lastModified; | 0 | ||||||
| 530 | } | - | ||||||
| 531 | - | |||||||
| 532 | /*! | - | ||||||
| 533 | Returns the date when the URL was last read. | - | ||||||
| 534 | - | |||||||
| 535 | \sa isValid() | - | ||||||
| 536 | */ | - | ||||||
| 537 | - | |||||||
| 538 | QDateTime QUrlInfo::lastRead() const | - | ||||||
| 539 | { | - | ||||||
| 540 | if (!d)
| 0 | ||||||
| 541 | return QDateTime(); never executed: return QDateTime(); | 0 | ||||||
| 542 | return d->lastRead; never executed: return d->lastRead; | 0 | ||||||
| 543 | } | - | ||||||
| 544 | - | |||||||
| 545 | /*! | - | ||||||
| 546 | Returns \c true if the URL is a directory; otherwise returns \c false. | - | ||||||
| 547 | - | |||||||
| 548 | \sa isValid() | - | ||||||
| 549 | */ | - | ||||||
| 550 | - | |||||||
| 551 | bool QUrlInfo::isDir() const | - | ||||||
| 552 | { | - | ||||||
| 553 | if (!d)
| 0 | ||||||
| 554 | return false; never executed: return false; | 0 | ||||||
| 555 | return d->isDir; never executed: return d->isDir; | 0 | ||||||
| 556 | } | - | ||||||
| 557 | - | |||||||
| 558 | /*! | - | ||||||
| 559 | Returns \c true if the URL is a file; otherwise returns \c false. | - | ||||||
| 560 | - | |||||||
| 561 | \sa isValid() | - | ||||||
| 562 | */ | - | ||||||
| 563 | - | |||||||
| 564 | bool QUrlInfo::isFile() const | - | ||||||
| 565 | { | - | ||||||
| 566 | if (!d)
| 0 | ||||||
| 567 | return false; never executed: return false; | 0 | ||||||
| 568 | return d->isFile; never executed: return d->isFile; | 0 | ||||||
| 569 | } | - | ||||||
| 570 | - | |||||||
| 571 | /*! | - | ||||||
| 572 | Returns \c true if the URL is a symbolic link; otherwise returns \c false. | - | ||||||
| 573 | - | |||||||
| 574 | \sa isValid() | - | ||||||
| 575 | */ | - | ||||||
| 576 | - | |||||||
| 577 | bool QUrlInfo::isSymLink() const | - | ||||||
| 578 | { | - | ||||||
| 579 | if (!d)
| 0-372 | ||||||
| 580 | return false; never executed: return false; | 0 | ||||||
| 581 | return d->isSymLink; executed 372 times by 1 test: return d->isSymLink;Executed by:
| 372 | ||||||
| 582 | } | - | ||||||
| 583 | - | |||||||
| 584 | /*! | - | ||||||
| 585 | Returns \c true if the URL is writable; otherwise returns \c false. | - | ||||||
| 586 | - | |||||||
| 587 | \sa isValid() | - | ||||||
| 588 | */ | - | ||||||
| 589 | - | |||||||
| 590 | bool QUrlInfo::isWritable() const | - | ||||||
| 591 | { | - | ||||||
| 592 | if (!d)
| 0 | ||||||
| 593 | return false; never executed: return false; | 0 | ||||||
| 594 | return d->isWritable; never executed: return d->isWritable; | 0 | ||||||
| 595 | } | - | ||||||
| 596 | - | |||||||
| 597 | /*! | - | ||||||
| 598 | Returns \c true if the URL is readable; otherwise returns \c false. | - | ||||||
| 599 | - | |||||||
| 600 | \sa isValid() | - | ||||||
| 601 | */ | - | ||||||
| 602 | - | |||||||
| 603 | bool QUrlInfo::isReadable() const | - | ||||||
| 604 | { | - | ||||||
| 605 | if (!d)
| 0 | ||||||
| 606 | return false; never executed: return false; | 0 | ||||||
| 607 | return d->isReadable; never executed: return d->isReadable; | 0 | ||||||
| 608 | } | - | ||||||
| 609 | - | |||||||
| 610 | /*! | - | ||||||
| 611 | Returns \c true if the URL is executable; otherwise returns \c false. | - | ||||||
| 612 | - | |||||||
| 613 | \sa isValid() | - | ||||||
| 614 | */ | - | ||||||
| 615 | - | |||||||
| 616 | bool QUrlInfo::isExecutable() const | - | ||||||
| 617 | { | - | ||||||
| 618 | if (!d)
| 0 | ||||||
| 619 | return false; never executed: return false; | 0 | ||||||
| 620 | return d->isExecutable; never executed: return d->isExecutable; | 0 | ||||||
| 621 | } | - | ||||||
| 622 | - | |||||||
| 623 | /*! | - | ||||||
| 624 | Returns \c true if \a i1 is greater than \a i2; otherwise returns | - | ||||||
| 625 | false. The objects are compared by the value, which is specified | - | ||||||
| 626 | by \a sortBy. This must be one of QDir::Name, QDir::Time or | - | ||||||
| 627 | QDir::Size. | - | ||||||
| 628 | */ | - | ||||||
| 629 | - | |||||||
| 630 | bool QUrlInfo::greaterThan(const QUrlInfo &i1, const QUrlInfo &i2, | - | ||||||
| 631 | int sortBy) | - | ||||||
| 632 | { | - | ||||||
| 633 | switch (sortBy) { | - | ||||||
| 634 | case QDir::Name: never executed: case QDir::Name: | 0 | ||||||
| 635 | return i1.name() > i2.name(); never executed: return i1.name() > i2.name(); | 0 | ||||||
| 636 | case QDir::Time: never executed: case QDir::Time: | 0 | ||||||
| 637 | return i1.lastModified() > i2.lastModified(); never executed: return i1.lastModified() > i2.lastModified(); | 0 | ||||||
| 638 | case QDir::Size: never executed: case QDir::Size: | 0 | ||||||
| 639 | return i1.size() > i2.size(); never executed: return i1.size() > i2.size(); | 0 | ||||||
| 640 | default: never executed: default: | 0 | ||||||
| 641 | return false; never executed: return false; | 0 | ||||||
| 642 | } | - | ||||||
| 643 | } | - | ||||||
| 644 | - | |||||||
| 645 | /*! | - | ||||||
| 646 | Returns \c true if \a i1 is less than \a i2; otherwise returns \c false. | - | ||||||
| 647 | The objects are compared by the value, which is specified by \a | - | ||||||
| 648 | sortBy. This must be one of QDir::Name, QDir::Time or QDir::Size. | - | ||||||
| 649 | */ | - | ||||||
| 650 | - | |||||||
| 651 | bool QUrlInfo::lessThan(const QUrlInfo &i1, const QUrlInfo &i2, | - | ||||||
| 652 | int sortBy) | - | ||||||
| 653 | { | - | ||||||
| 654 | return !greaterThan(i1, i2, sortBy); never executed: return !greaterThan(i1, i2, sortBy); | 0 | ||||||
| 655 | } | - | ||||||
| 656 | - | |||||||
| 657 | /*! | - | ||||||
| 658 | Returns \c true if \a i1 equals to \a i2; otherwise returns \c false. | - | ||||||
| 659 | The objects are compared by the value, which is specified by \a | - | ||||||
| 660 | sortBy. This must be one of QDir::Name, QDir::Time or QDir::Size. | - | ||||||
| 661 | */ | - | ||||||
| 662 | - | |||||||
| 663 | bool QUrlInfo::equal(const QUrlInfo &i1, const QUrlInfo &i2, | - | ||||||
| 664 | int sortBy) | - | ||||||
| 665 | { | - | ||||||
| 666 | switch (sortBy) { | - | ||||||
| 667 | case QDir::Name: never executed: case QDir::Name: | 0 | ||||||
| 668 | return i1.name() == i2.name(); never executed: return i1.name() == i2.name(); | 0 | ||||||
| 669 | case QDir::Time: never executed: case QDir::Time: | 0 | ||||||
| 670 | return i1.lastModified() == i2.lastModified(); never executed: return i1.lastModified() == i2.lastModified(); | 0 | ||||||
| 671 | case QDir::Size: never executed: case QDir::Size: | 0 | ||||||
| 672 | return i1.size() == i2.size(); never executed: return i1.size() == i2.size(); | 0 | ||||||
| 673 | default: never executed: default: | 0 | ||||||
| 674 | return false; never executed: return false; | 0 | ||||||
| 675 | } | - | ||||||
| 676 | } | - | ||||||
| 677 | - | |||||||
| 678 | /*! | - | ||||||
| 679 | Returns \c true if this QUrlInfo is equal to \a other; otherwise | - | ||||||
| 680 | returns \c false. | - | ||||||
| 681 | - | |||||||
| 682 | \sa lessThan(), equal() | - | ||||||
| 683 | */ | - | ||||||
| 684 | - | |||||||
| 685 | bool QUrlInfo::operator==(const QUrlInfo &other) const | - | ||||||
| 686 | { | - | ||||||
| 687 | if (!d)
| 0 | ||||||
| 688 | return other.d == 0; never executed: return other.d == 0; | 0 | ||||||
| 689 | if (!other.d)
| 0 | ||||||
| 690 | return false; never executed: return false; | 0 | ||||||
| 691 | - | |||||||
| 692 | return (d->name == other.d->name && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 693 | d->permissions == other.d->permissions && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 694 | d->owner == other.d->owner && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 695 | d->group == other.d->group && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 696 | d->size == other.d->size && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 697 | d->lastModified == other.d->lastModified && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 698 | d->lastRead == other.d->lastRead && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 699 | d->isDir == other.d->isDir && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 700 | d->isFile == other.d->isFile && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 701 | d->isSymLink == other.d->isSymLink && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 702 | d->isWritable == other.d->isWritable && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 703 | d->isReadable == other.d->isReadable && never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 704 | d->isExecutable == other.d->isExecutable); never executed: return (d->name == other.d->name && d->permissions == other.d->permissions && d->owner == other.d->owner && d->group == other.d->group && d->size == other.d->size && d->lastModified == other.d->lastModified && d->lastRead == other.d->lastRead && d->isDir == other.d->isDir && d->isFile == other.d->isFile && d->isSymLink == other.d->isSymLink && d->isWritable == other.d->isWritable && d->isReadable == other.d->isReadable && d->isExecutable == other.d->isExecutable); | 0 | ||||||
| 705 | } | - | ||||||
| 706 | - | |||||||
| 707 | /*! | - | ||||||
| 708 | \fn bool QUrlInfo::operator!=(const QUrlInfo &other) const | - | ||||||
| 709 | \since 4.2 | - | ||||||
| 710 | - | |||||||
| 711 | Returns \c true if this QUrlInfo is not equal to \a other; otherwise | - | ||||||
| 712 | returns \c false. | - | ||||||
| 713 | - | |||||||
| 714 | \sa lessThan(), equal() | - | ||||||
| 715 | */ | - | ||||||
| 716 | - | |||||||
| 717 | /*! | - | ||||||
| 718 | Returns \c true if the URL info is valid; otherwise returns \c false. | - | ||||||
| 719 | Valid means that the QUrlInfo contains real information. | - | ||||||
| 720 | - | |||||||
| 721 | You should always check if the URL info is valid before relying on | - | ||||||
| 722 | the values. | - | ||||||
| 723 | */ | - | ||||||
| 724 | bool QUrlInfo::isValid() const | - | ||||||
| 725 | { | - | ||||||
| 726 | return d != 0; never executed: return d != 0; | 0 | ||||||
| 727 | } | - | ||||||
| 728 | - | |||||||
| 729 | QT_END_NAMESPACE | - | ||||||
| 730 | - | |||||||
| 731 | #endif // QT_NO_FTP | - | ||||||
| Source code | Switch to Preprocessed file |