⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qurlinfo.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the QtNetwork module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qurlinfo.h"#ifndef QT_NO_URLINFO#include "qurl.h"#include "qdir.h"#include <limits.h>class QUrlInfoPrivate{public:    QUrlInfoPrivate() :        permissions(0),        size(0),        isDir(false),        isFile(true),        isSymLink(false),        isWritable(true),        isReadable(true),        isExecutable(false)    {}    QString name;    int permissions;    QString owner;    QString group;    qint64 size;    QDateTime lastModified;    QDateTime lastRead;    bool isDir;    bool isFile;    bool isSymLink;    bool isWritable;    bool isReadable;    bool isExecutable;};/*!    \class QUrlInfo    \brief The QUrlInfo class stores information about URLs.    \ingroup io    \ingroup misc    The information about a URL that can be retrieved includes name(),    permissions(), owner(), group(), size(), lastModified(),    lastRead(), isDir(), isFile(), isSymLink(), isWritable(),    isReadable() and isExecutable().    You can create your own QUrlInfo objects passing in all the    relevant information in the constructor, and you can modify a    QUrlInfo; for each getter mentioned above there is an equivalent    setter. Note that setting values does not affect the underlying    resource that the QUrlInfo provides information about; for example    if you call setWritable(true) on a read-only resource the only    thing changed is the QUrlInfo object, not the resource.    \sa QUrl, {FTP Example}*//*!    \enum QUrlInfo::PermissionSpec    This enum is used by the permissions() function to report the    permissions of a file.    \value ReadOwner The file is readable by the owner of the file.    \value WriteOwner The file is writable by the owner of the file.    \value ExeOwner The file is executable by the owner of the file.    \value ReadGroup The file is readable by the group.    \value WriteGroup The file is writable by the group.    \value ExeGroup The file is executable by the group.    \value ReadOther The file is readable by anyone.    \value WriteOther The file is writable by anyone.    \value ExeOther The file is executable by anyone.*//*!    Constructs an invalid QUrlInfo object with default values.    \sa isValid()*/QUrlInfo::QUrlInfo(){    d = 0;}/*!    Copy constructor, copies \a ui to this URL info object.*/QUrlInfo::QUrlInfo(const QUrlInfo &ui){    if (ui.d) {        d = new QUrlInfoPrivate;        *d = *ui.d;    } else {        d = 0;    }}/*!    Constructs a QUrlInfo object by specifying all the URL's    information.    The information that is passed is the \a name, file \a    permissions, \a owner and \a group and the file's \a size. Also    passed is the \a lastModified date/time and the \a lastRead    date/time. Flags are also passed, specifically, \a isDir, \a    isFile, \a isSymLink, \a isWritable, \a isReadable and \a    isExecutable.*/QUrlInfo::QUrlInfo(const QString &name, int permissions, const QString &owner,                    const QString &group, qint64 size, const QDateTime &lastModified,                    const QDateTime &lastRead, bool isDir, bool isFile, bool isSymLink,                    bool isWritable, bool isReadable, bool isExecutable){    d = new QUrlInfoPrivate;    d->name = name;    d->permissions = permissions;    d->owner = owner;    d->group = group;    d->size = size;    d->lastModified = lastModified;    d->lastRead = lastRead;    d->isDir = isDir;    d->isFile = isFile;    d->isSymLink = isSymLink;    d->isWritable = isWritable;    d->isReadable = isReadable;    d->isExecutable = isExecutable;}/*!    Constructs a QUrlInfo object by specifying all the URL's    information.    The information that is passed is the \a url, file \a    permissions, \a owner and \a group and the file's \a size. Also    passed is the \a lastModified date/time and the \a lastRead    date/time. Flags are also passed, specifically, \a isDir, \a    isFile, \a isSymLink, \a isWritable, \a isReadable and \a    isExecutable.*/QUrlInfo::QUrlInfo(const QUrl &url, int permissions, const QString &owner,                    const QString &group, qint64 size, const QDateTime &lastModified,                    const QDateTime &lastRead, bool isDir, bool isFile, bool isSymLink,                    bool isWritable, bool isReadable, bool isExecutable){    d = new QUrlInfoPrivate;    d->name = QFileInfo(url.path()).fileName();    d->permissions = permissions;    d->owner = owner;    d->group = group;    d->size = size;    d->lastModified = lastModified;    d->lastRead = lastRead;    d->isDir = isDir;    d->isFile = isFile;    d->isSymLink = isSymLink;    d->isWritable = isWritable;    d->isReadable = isReadable;    d->isExecutable = isExecutable;}/*!    Sets the name of the URL to \a name. The name is the full text,    for example, "http://doc.trolltech.com/qurlinfo.html".    If you call this function for an invalid URL info, this function    turns it into a valid one.    \sa isValid()*/void QUrlInfo::setName(const QString &name){    if (!d)        d = new QUrlInfoPrivate;    d->name = name;}/*!    If \a b is true then the URL is set to be a directory; if \a b is    false then the URL is set not to be a directory (which normally    means it is a file). (Note that a URL can refer to both a file and    a directory even though most file systems do not support this.)    If you call this function for an invalid URL info, this function    turns it into a valid one.    \sa isValid()*/void QUrlInfo::setDir(bool b){    if (!d)        d = new QUrlInfoPrivate;    d->isDir = b;}/*!    If \a b is true then the URL is set to be a file; if \b is false    then the URL is set not to be a file (which normally means it is a    directory). (Note that a URL can refer to both a file and a    directory even though most file systems do not support this.)    If you call this function for an invalid URL info, this function    turns it into a valid one.    \sa isValid()*/void QUrlInfo::setFile(bool b){    if (!d)        d = new QUrlInfoPrivate;    d->isFile = b;}/*!    Specifies that the URL refers to a symbolic link if \a b is true    and that it does not if \a b is false.    If you call this function for an invalid URL info, this function    turns it into a valid one.    \sa isValid()*/void QUrlInfo::setSymLink(bool b){    if (!d)        d = new QUrlInfoPrivate;    d->isSymLink = b;}/*!    Specifies that the URL is writable if \a b is true and not    writable if \a b is false.    If you call this function for an invalid URL info, this function    turns it into a valid one.    \sa isValid()*/void QUrlInfo::setWritable(bool b){    if (!d)        d = new QUrlInfoPrivate;    d->isWritable = b;}/*!    Specifies that the URL is readable if \a b is true and not    readable if \a b is false.    If you call this function for an invalid URL info, this function    turns it into a valid one.    \sa isValid()*/void QUrlInfo::setReadable(bool b){    if (!d)        d = new QUrlInfoPrivate;    d->isReadable = b;}/*!    Specifies that the owner of the URL is called \a s.    If you call this function for an invalid URL info, this function    turns it into a valid one.    \sa isValid()*/void QUrlInfo::setOwner(const QString &s){    if (!d)        d = new QUrlInfoPrivate;    d->owner = s;}/*!    Specifies that the owning group of the URL is called \a s.    If you call this function for an invalid URL info, this function    turns it into a valid one.    \sa isValid()*/void QUrlInfo::setGroup(const QString &s){    if (!d)        d = new QUrlInfoPrivate;    d->group = s;}/*!

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -