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

📄 qdir.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    \a filters and \a sort arguments.    Returns an empty list if the directory is unreadable, does not    exist, or if nothing matches the specification.    \sa entryList(), setNameFilters(), setSorting(), setFilter(), isReadable(), exists()*/QFileInfoList QDir::entryInfoList(Filters filters, SortFlags sort) const{    Q_D(const QDir);    return entryInfoList(d->data->nameFilters, filters, sort);}/*!    Returns a list of the names of all the files and    directories in the directory, ordered according to the name    and attribute filters previously set with setNameFilters()    and setFilter(), and sorted according to the flags set with    setSorting().    The name filter, file attribute filter, and sorting specification    can be overridden using the \a nameFilters, \a filters, and \a sort    arguments.    Returns an empty list if the directory is unreadable, does not    exist, or if nothing matches the specification.    \sa entryInfoList(), setNameFilters(), setSorting(), setFilter()*/QStringList QDir::entryList(const QStringList &nameFilters, Filters filters,                            SortFlags sort) const{    Q_D(const QDir);    if (filters == NoFilter)        filters = d->data->filters;#ifdef QT3_SUPPORT    if (d->matchAllDirs)        filters |= AllDirs;#endif    if (sort == NoSort)        sort = d->data->sort;    if (filters == NoFilter && sort == NoSort && nameFilters == d->data->nameFilters) {        d->updateFileLists();        return d->data->files;    }    QStringList l = d->data->fileEngine->entryList(filters, nameFilters);    if ((sort & QDir::SortByMask) == QDir::Unsorted)        return l;    QStringList ret;    d->sortFileList(sort, l, &ret, 0);    return ret;}/*!    Returns a list of QFileInfo objects for all the files and    directories in the directory, ordered according to the name    and attribute filters previously set with setNameFilters()    and setFilter(), and sorted according to the flags set with    setSorting().    The name filter, file attribute filter, and sorting specification    can be overridden using the \a nameFilters, \a filters, and \a sort    arguments.    Returns an empty list if the directory is unreadable, does not    exist, or if nothing matches the specification.    \sa entryList(), setNameFilters(), setSorting(), setFilter(), isReadable(), exists()*/QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filters,                                  SortFlags sort) const{    Q_D(const QDir);    if (filters == NoFilter)        filters = d->data->filters;#ifdef QT3_SUPPORT    if (d->matchAllDirs)        filters |= AllDirs;#endif    if (sort == NoSort)        sort = d->data->sort;    if (filters == NoFilter && sort == NoSort && nameFilters == d->data->nameFilters) {        d->updateFileLists();        return d->data->fileInfos;    }    QFileInfoList ret;    QStringList l = d->data->fileEngine->entryList(filters, nameFilters);    d->sortFileList(sort, l, 0, &ret);    return ret;}/*!    Creates a sub-directory called \a dirName.    Returns true on success; otherwise returns false.    \sa rmdir()*/bool QDir::mkdir(const QString &dirName) const{    Q_D(const QDir);    if (dirName.isEmpty()) {        qWarning("QDir::mkdir: Empty or null file name(s)");        return false;    }    if(!d->data->fileEngine)        return false;    QString fn = filePath(dirName);    return d->data->fileEngine->mkdir(fn, false);}/*!    Removes the directory specified by \a dirName.    The directory must be empty for rmdir() to succeed.    Returns true if successful; otherwise returns false.    \sa mkdir()*/bool QDir::rmdir(const QString &dirName) const{    Q_D(const QDir);    if (dirName.isEmpty()) {        qWarning("QDir::rmdir: Empty or null file name(s)");        return false;    }    if(!d->data->fileEngine)        return false;    QString fn = filePath(dirName);    return d->data->fileEngine->rmdir(fn, false);}/*!    Creates the directory path \a dirPath.    The function will create all parent directories necessary to    create the directory.    Returns true if successful; otherwise returns false.    \sa rmpath()*/bool QDir::mkpath(const QString &dirPath) const{    Q_D(const QDir);    if (dirPath.isEmpty()) {        qWarning("QDir::mkpath: Empty or null file name(s)");        return false;    }    if(!d->data->fileEngine)        return false;    QString fn = filePath(dirPath);    return d->data->fileEngine->mkdir(fn, true);}/*!    Removes the directory path \a dirPath.    The function will remove all parent directories in \a dirPath,    provided that they are empty. This is the opposite of    mkpath(dirPath).    Returns true if successful; otherwise returns false.    \sa mkpath()*/bool QDir::rmpath(const QString &dirPath) const{    Q_D(const QDir);    if (dirPath.isEmpty()) {        qWarning("QDir::rmpath: Empty or null file name(s)");        return false;    }    if(!d->data->fileEngine)        return false;    QString fn = filePath(dirPath);    return d->data->fileEngine->rmdir(fn, true);}/*!    Returns true if the directory is readable \e and we can open files    by name; otherwise returns false.    \warning A false value from this function is not a guarantee that    files in the directory are not accessible.    \sa QFileInfo::isReadable()*/bool QDir::isReadable() const{    Q_D(const QDir);    if(!d->data->fileEngine)        return false;    const QAbstractFileEngine::FileFlags info = d->data->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType                                                                       |QAbstractFileEngine::PermsMask);    if(!(info & QAbstractFileEngine::DirectoryType))        return false;    return info & QAbstractFileEngine::ReadUserPerm;}/*!    \overload    Returns true if the \e directory exists; otherwise returns false.    (If a file with the same name is found this function will return    false).    \sa QFileInfo::exists(), QFile::exists()*/bool QDir::exists() const{    Q_D(const QDir);    if(!d->data->fileEngine)        return false;    const QAbstractFileEngine::FileFlags info =        d->data->fileEngine->fileFlags(            QAbstractFileEngine::DirectoryType            | QAbstractFileEngine::ExistsFlag            | QAbstractFileEngine::Refresh);    if(!(info & QAbstractFileEngine::DirectoryType))        return false;    return info & QAbstractFileEngine::ExistsFlag;}/*!    Returns true if the directory is the root directory; otherwise    returns false.    Note: If the directory is a symbolic link to the root directory    this function returns false. If you want to test for this use    canonicalPath(), e.g.    \code        QDir dir("/tmp/root_link");        dir = dir.canonicalPath();        if (dir.isRoot())            qWarning("It is a root link");    \endcode    \sa root(), rootPath()*/bool QDir::isRoot() const{    Q_D(const QDir);    if(!d->data->fileEngine)        return true;    return d->data->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag;}/*!    \fn bool QDir::isAbsolute() const    Returns true if the directory's path is absolute; otherwise    returns false. See isAbsolutePath().    \sa isRelative() makeAbsolute() cleanPath()*//*!   \fn bool QDir::isAbsolutePath(const QString &)    Returns true if \a path is absolute; returns false if it is    relative.    \sa isAbsolute() isRelativePath() makeAbsolute() cleanPath()*//*!    Returns true if the directory path is relative; otherwise returns    false. (Under Unix a path is relative if it does not start with a    "/").    \sa makeAbsolute() isAbsolute() isAbsolutePath() cleanPath()*/bool QDir::isRelative() const{    Q_D(const QDir);    if(!d->data->fileEngine)        return false;    return d->data->fileEngine->isRelativePath();}/*!    Converts the directory path to an absolute path. If it is already    absolute nothing happens. Returns true if the conversion    succeeded; otherwise returns false.    \sa isAbsolute() isAbsolutePath() isRelative() cleanPath()*/bool QDir::makeAbsolute() // ### What do the return values signify?{    Q_D(QDir);    if(!d->data->fileEngine)        return false;    QString absolutePath = d->data->fileEngine->fileName(QAbstractFileEngine::AbsoluteName);    if(QDir::isRelativePath(absolutePath))        return false;    d->detach();    d->data->path = absolutePath;    d->data->fileEngine->setFileName(absolutePath);    if(!(d->data->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType))        return false;    return true;}/*!    Returns true if directory \a dir and this directory have the same    path and their sort and filter settings are the same; otherwise    returns false.    Example:    \code        // The current directory is "/usr/local"        QDir d1("/usr/local/bin");        QDir d2("bin");        if (d1 == d2)            qDebug("They're the same");    \endcode*/bool QDir::operator==(const QDir &dir) const{    const QDirPrivate *d = d_func();    const QDirPrivate *other = dir.d_func();    if(d->data == other->data)        return true;    Q_ASSERT(d->data->fileEngine && other->data->fileEngine);    if(d->data->fileEngine->caseSensitive() != other->data->fileEngine->caseSensitive())        return false;    if(d->data->filters == other->data->filters       && d->data->sort == other->data->sort       && d->data->nameFilters == other->data->nameFilters) {        QString dir1 = absolutePath(), dir2 = dir.absolutePath();        if(!other->data->fileEngine->caseSensitive())            return (dir1.toLower() == dir2.toLower());        return (dir1 == dir2);    }    return false;}/*!    Makes a copy of the \a dir object and assigns it to this QDir    object.*/QDir &QDir::operator=(const QDir &dir){    if (this == &dir)        return *this;    Q_D(QDir);    qAtomicAssign(d->data, dir.d_func()->data);    return *this;}/*!    \overload    \obsolete    Sets the directory path to the given \a path.    Use setPath() instead.*/QDir &QDir::operator=(const QString &path){    Q_D(QDir);    d->setPath(path);    return *this;}/*!    \fn bool QDir::operator!=(const QDir &dir) const    Returns true if directory \a dir and this directory have different    paths or different sort or filter settings; otherwise returns    false.    Example:    \code        // The current directory is "/usr/local"        QDir d1("/usr/local/bin");        QDir d2("bin");        if (d1 != d2)            qDebug("They differ");    \endcode*//*!    Removes the file, \a fileName.    Returns true if the file is removed successfully; otherwise    returns false.*/bool QDir::remove(const QString &fileName){    if (fileName.isEmpty()) {        qWarning("QDir::remove: Empty or null file name");        return false;    }    QString p = filePath(fileName);    return QFile::remove(p);}/*!    Renames a file or directory from \a oldName to \a newName, and returns    true if successful; otherwise returns false.    On most file systems, rename() fails only if \a oldName does not

⌨️ 快捷键说明

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