1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the network module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
31
#ifndef QT_NO_NETWORKPROTOCOL
57
QDateTime lastModified;
69
\class QUrlInfo qurlinfo.h
70
\brief The QUrlInfo class stores information about URLs.
75
The information about a URL that can be retrieved includes name(),
76
permissions(), owner(), group(), size(), lastModified(),
77
lastRead(), isDir(), isFile(), isSymLink(), isWritable(),
78
isReadable() and isExecutable().
80
You can create your own QUrlInfo objects passing in all the
81
relevant information in the constructor, and you can modify a
82
QUrlInfo; for each getter mentioned above there is an equivalent
83
setter. Note that setting values does not affect the underlying
84
resource that the QUrlInfo provides information about; for example
85
if you call setWritable(true) on a read-only resource the only
86
thing changed is the QUrlInfo object, not the resource.
92
\enum QUrlInfo::PermissionSpec
94
This enum is used by the permissions() function to report the
95
permissions of a file.
97
\value ReadOwner The file is readable by the owner of the file.
98
\value WriteOwner The file is writable by the owner of the file.
99
\value ExeOwner The file is executable by the owner of the file.
100
\value ReadGroup The file is readable by the group.
101
\value WriteGroup The file is writable by the group.
102
\value ExeGroup The file is executable by the group.
103
\value ReadOther The file is readable by anyone.
104
\value WriteOther The file is writable by anyone.
105
\value ExeOther The file is executable by anyone.
109
Constructs an invalid QUrlInfo object with default values.
120
Copy constructor, copies \a ui to this URL info object.
123
QUrlInfo::QUrlInfo(const QUrlInfo &ui)
126
d = new QUrlInfoPrivate;
134
Constructs a QUrlInfo object by specifying all the URL's
137
The information that is passed is the \a name, file \a
138
permissions, \a owner and \a group and the file's \a size. Also
139
passed is the \a lastModified date/time and the \a lastRead
140
date/time. Flags are also passed, specifically, \a isDir, \a
141
isFile, \a isSymLink, \a isWritable, \a isReadable and \a
145
QUrlInfo::QUrlInfo(const QString &name, int permissions, const QString &owner,
146
const QString &group, qint64 size, const QDateTime &lastModified,
147
const QDateTime &lastRead, bool isDir, bool isFile, bool isSymLink,
148
bool isWritable, bool isReadable, bool isExecutable)
150
d = new QUrlInfoPrivate;
152
d->permissions = permissions;
156
d->lastModified = lastModified;
157
d->lastRead = lastRead;
160
d->isSymLink = isSymLink;
161
d->isWritable = isWritable;
162
d->isReadable = isReadable;
163
d->isExecutable = isExecutable;
168
Constructs a QUrlInfo object by specifying all the URL's
171
The information that is passed is the \a url, file \a
172
permissions, \a owner and \a group and the file's \a size. Also
173
passed is the \a lastModified date/time and the \a lastRead
174
date/time. Flags are also passed, specifically, \a isDir, \a
175
isFile, \a isSymLink, \a isWritable, \a isReadable and \a
179
QUrlInfo::QUrlInfo(const QUrl &url, int permissions, const QString &owner,
180
const QString &group, qint64 size, const QDateTime &lastModified,
181
const QDateTime &lastRead, bool isDir, bool isFile, bool isSymLink,
182
bool isWritable, bool isReadable, bool isExecutable)
184
d = new QUrlInfoPrivate;
185
d->name = QFileInfo(url.path()).fileName();
186
d->permissions = permissions;
190
d->lastModified = lastModified;
191
d->lastRead = lastRead;
194
d->isSymLink = isSymLink;
195
d->isWritable = isWritable;
196
d->isReadable = isReadable;
197
d->isExecutable = isExecutable;
202
Sets the name of the URL to \a name. The name is the full text,
203
for example, "http://doc.trolltech.com/qurlinfo.html".
205
If you call this function for an invalid URL info, this function
206
turns it into a valid one.
211
void QUrlInfo::setName(const QString &name)
214
d = new QUrlInfoPrivate;
220
If \a b is true then the URL is set to be a directory; if \a b is
221
false then the URL is set not to be a directory (which normally
222
means it is a file). (Note that a URL can refer to both a file and
223
a directory even though most file systems do not support this.)
225
If you call this function for an invalid URL info, this function
226
turns it into a valid one.
231
void QUrlInfo::setDir(bool b)
234
d = new QUrlInfoPrivate;
240
If \a b is true then the URL is set to be a file; if \b is false
241
then the URL is set not to be a file (which normally means it is a
242
directory). (Note that a URL can refer to both a file and a
243
directory even though most file systems do not support this.)
245
If you call this function for an invalid URL info, this function
246
turns it into a valid one.
251
void QUrlInfo::setFile(bool b)
254
d = new QUrlInfoPrivate;
260
Specifies that the URL refers to a symbolic link if \a b is true
261
and that it does not if \a b is false.
263
If you call this function for an invalid URL info, this function
264
turns it into a valid one.
269
void QUrlInfo::setSymLink(bool b)
272
d = new QUrlInfoPrivate;
278
Specifies that the URL is writable if \a b is true and not
279
writable if \a b is false.
281
If you call this function for an invalid URL info, this function
282
turns it into a valid one.
287
void QUrlInfo::setWritable(bool b)
290
d = new QUrlInfoPrivate;
296
Specifies that the URL is readable if \a b is true and not
297
readable if \a b is false.
299
If you call this function for an invalid URL info, this function
300
turns it into a valid one.
305
void QUrlInfo::setReadable(bool b)
308
d = new QUrlInfoPrivate;
313
Specifies that the owner of the URL is called \a s.
315
If you call this function for an invalid URL info, this function
316
turns it into a valid one.
321
void QUrlInfo::setOwner(const QString &s)
324
d = new QUrlInfoPrivate;
329
Specifies that the owning group of the URL is called \a s.
331
If you call this function for an invalid URL info, this function
332
turns it into a valid one.
337
void QUrlInfo::setGroup(const QString &s)
340
d = new QUrlInfoPrivate;
345
Specifies the \a size of the URL.
347
If you call this function for an invalid URL info, this function
348
turns it into a valid one.
353
void QUrlInfo::setSize(qint64 size)
356
d = new QUrlInfoPrivate;
361
Specifies that the URL has access permisions, \a p.
363
If you call this function for an invalid URL info, this function
364
turns it into a valid one.
369
void QUrlInfo::setPermissions(int p)
372
d = new QUrlInfoPrivate;
377
Specifies that the object the URL refers to was last modified at
380
If you call this function for an invalid URL info, this function
381
turns it into a valid one.
386
void QUrlInfo::setLastModified(const QDateTime &dt)
389
d = new QUrlInfoPrivate;
390
d->lastModified = dt;
394
Destroys the URL info object.
397
QUrlInfo::~QUrlInfo()
403
Assigns the values of \a ui to this QUrlInfo object.
406
QUrlInfo &QUrlInfo::operator=(const QUrlInfo &ui)
410
d= new QUrlInfoPrivate;
420
Returns the file name of the URL.
425
QString QUrlInfo::name() const
433
Returns the permissions of the URL. You can use the \c PermissionSpec flags
434
to test for certain permissions.
439
int QUrlInfo::permissions() const
443
return d->permissions;
447
Returns the owner of the URL.
452
QString QUrlInfo::owner() const
460
Returns the group of the URL.
465
QString QUrlInfo::group() const
473
Returns the size of the URL.
478
qint64 QUrlInfo::size() const
486
Returns the last modification date of the URL.
491
QDateTime QUrlInfo::lastModified() const
495
return d->lastModified;
499
Returns the date when the URL was last read.
504
QDateTime QUrlInfo::lastRead() const
512
Returns true if the URL is a directory; otherwise returns false.
517
bool QUrlInfo::isDir() const
525
Returns true if the URL is a file; otherwise returns false.
530
bool QUrlInfo::isFile() const
538
Returns true if the URL is a symbolic link; otherwise returns false.
543
bool QUrlInfo::isSymLink() const
551
Returns true if the URL is writable; otherwise returns false.
556
bool QUrlInfo::isWritable() const
560
return d->isWritable;
564
Returns true if the URL is readable; otherwise returns false.
569
bool QUrlInfo::isReadable() const
573
return d->isReadable;
577
Returns true if the URL is executable; otherwise returns false.
582
bool QUrlInfo::isExecutable() const
586
return d->isExecutable;
590
Returns true if \a i1 is greater than \a i2; otherwise returns
591
false. The objects are compared by the value, which is specified
592
by \a sortBy. This must be one of QDir::Name, QDir::Time or
596
bool QUrlInfo::greaterThan(const QUrlInfo &i1, const QUrlInfo &i2,
601
return i1.name() > i2.name();
603
return i1.lastModified() > i2.lastModified();
605
return i1.size() > i2.size();
612
Returns true if \a i1 is less than \a i2; otherwise returns false.
613
The objects are compared by the value, which is specified by \a
614
sortBy. This must be one of QDir::Name, QDir::Time or QDir::Size.
617
bool QUrlInfo::lessThan(const QUrlInfo &i1, const QUrlInfo &i2,
620
return !greaterThan(i1, i2, sortBy);
624
Returns true if \a i1 equals to \a i2; otherwise returns false.
625
The objects are compared by the value, which is specified by \a
626
sortBy. This must be one of QDir::Name, QDir::Time or QDir::Size.
629
bool QUrlInfo::equal(const QUrlInfo &i1, const QUrlInfo &i2,
634
return i1.name() == i2.name();
636
return i1.lastModified() == i2.lastModified();
638
return i1.size() == i2.size();
645
Compares this QUrlInfo with \a i and returns true if they are
646
equal; otherwise returns false.
649
bool QUrlInfo::operator==(const QUrlInfo &i) const
656
return (d->name == i.d->name &&
657
d->permissions == i.d->permissions &&
658
d->owner == i.d->owner &&
659
d->group == i.d->group &&
660
d->size == i.d->size &&
661
d->lastModified == i.d->lastModified &&
662
d->lastRead == i.d->lastRead &&
663
d->isDir == i.d->isDir &&
664
d->isFile == i.d->isFile &&
665
d->isSymLink == i.d->isSymLink &&
666
d->isWritable == i.d->isWritable &&
667
d->isReadable == i.d->isReadable &&
668
d->isExecutable == i.d->isExecutable);
672
Returns true if the URL info is valid; otherwise returns false.
673
Valid means that the QUrlInfo contains real information.
675
You should always check if the URL info is valid before relying on
678
bool QUrlInfo::isValid() const
683
#endif // QT_NO_NETWORKPROTOCOL