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