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

📄 qdir.cpp

📁 QT 开发环境里面一个很重要的文件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    If the directory of the current user's profile does not exist or    cannot be retrieved, the following alternatives will be checked (in    the given order) until an existing and available path is found:    \list 1    \o The path specified by the \c USERPROFILE environment variable.    \o The path formed by concatenating the \c HOMEDRIVE and \c HOMEPATH    environment variables.    \o The path specified by the \c HOME environment variable.    \o The path returned by the rootPath() function (which uses the \c SystemDrive    environment variable)    \o  The \c{C:\} directory.    \endlist    Under non-Windows operating systems the \c HOME environment    variable is used if it exists, otherwise the path returned by the    rootPath() function is used.    \sa home(), currentPath(), rootPath(), tempPath()*/QString QDir::homePath(){    return QFSFileEngine::homePath();}/*!    \fn QDir QDir::temp()    Returns the system's temporary directory.    The directory is constructed using the absolute path of the temporary directory,    ensuring that its path() will be the same as its absolutePath().    See tempPath() for details.    \sa drives(), current(), home(), root()*//*!    Returns the absolute path of the system's temporary directory.    On Unix/Linux systems this is usually \c{/tmp}; on Windows this is    usually the path in the \c TEMP or \c TMP environment    variable. Whether a directory separator is added to the end or    not, depends on the operating system.    \sa temp(), currentPath(), homePath(), rootPath()*/QString QDir::tempPath(){    return QFSFileEngine::tempPath();}/*!    \fn QDir QDir::root()    Returns the root directory.    The directory is constructed using the absolute path of the root directory,    ensuring that its path() will be the same as its absolutePath().    See rootPath() for details.    \sa drives(), current(), home(), temp()*//*!    Returns the absolute path of the root directory.    For Unix operating systems this returns "/". For Windows file    systems this normally returns "c:/".    \sa root(), drives(), currentPath(), homePath(), tempPath()*/QString QDir::rootPath(){    return QFSFileEngine::rootPath();}#ifndef QT_NO_REGEXP/*!    \overload    Returns true if the \a fileName matches any of the wildcard (glob)    patterns in the list of \a filters; otherwise returns false. The    matching is case insensitive.    \sa {QRegExp wildcard matching}, QRegExp::exactMatch() entryList() entryInfoList()*/bool QDir::match(const QStringList &filters, const QString &fileName){    for(QStringList::ConstIterator sit = filters.begin(); sit != filters.end(); ++sit) {        QRegExp rx(*sit, Qt::CaseInsensitive, QRegExp::Wildcard);        if (rx.exactMatch(fileName))            return true;    }    return false;}/*!    Returns true if the \a fileName matches the wildcard (glob)    pattern \a filter; otherwise returns false. The \a filter may    contain multiple patterns separated by spaces or semicolons.    The matching is case insensitive.    \sa {QRegExp wildcard matching}, QRegExp::exactMatch() entryList() entryInfoList()*/bool QDir::match(const QString &filter, const QString &fileName){    return match(nameFiltersFromString(filter), fileName);}#endif/*!    Removes all multiple directory separators "/" and resolves any    "."s or ".."s found in the path, \a path.    Symbolic links are kept. This function does not return the    canonical path, but rather the simplest version of the input.    For example, "./local" becomes "local", "local/../bin" becomes    "bin" and "/local/usr/../bin" becomes "/local/bin".    \sa absolutePath() canonicalPath()*/QString QDir::cleanPath(const QString &path){    if (path.isEmpty())        return path;    QString name = path;    QChar dir_separator = separator();    if(dir_separator != QLatin1Char('/'))	name.replace(dir_separator, QLatin1Char('/'));    int used = 0, levels = 0;    const int len = name.length();    QVector<QChar> out(len);    const QChar *p = name.unicode();    for(int i = 0, last = -1, iwrite = 0; i < len; i++) {        if(p[i] == QLatin1Char('/')) {            while(i < len-1 && p[i+1] == QLatin1Char('/')) {#ifdef Q_OS_WIN //allow unc paths                if(!i)                    break;#endif                i++;            }            bool eaten = false;            if(i < len - 1 && p[i+1] == QLatin1Char('.')) {                int dotcount = 1;                if(i < len - 2 && p[i+2] == QLatin1Char('.'))                    dotcount++;                if(i == len - dotcount - 1) {                    if(dotcount == 1) {                        break;                    } else if(levels) {                        if(last == -1) {                            for(int i2 = iwrite-1; i2 >= 0; i2--) {                                if(out[i2] == QLatin1Char('/')) {                                    last = i2;                                    break;                                }                            }                        }                        used -= iwrite - last - 1;                        break;                    }                } else if(p[i+dotcount+1] == QLatin1Char('/')) {                    if(dotcount == 2 && levels) {                        if(last == -1 || iwrite - last == 1) {                            for(int i2 = (last == -1) ? (iwrite-1) : (last-1); i2 >= 0; i2--) {                                if(out[i2] == QLatin1Char('/')) {                                    eaten = true;                                    last = i2;                                    break;                                }                            }                        } else {                            eaten = true;                        }                        if(eaten) {                            levels--;                            used -= iwrite - last;                            iwrite = last;                            last = -1;                        }                    } else if(dotcount == 1) {                        eaten = true;                    }                    if(eaten)                        i += dotcount;                } else {                    levels++;                }            } else if(last != -1 && iwrite - last == 1) {#ifdef Q_OS_WIN                eaten = (iwrite > 2);#else                eaten = true;#endif                last = -1;            } else if(last != -1 && i == len-1) {                eaten = true;            } else {                levels++;            }            if(!eaten)                last = i - (i - iwrite);            else                continue;        } else if(!i && p[i] == QLatin1Char('.')) {            int dotcount = 1;            if(len >= 1 && p[1] == QLatin1Char('.'))                dotcount++;            if(len >= dotcount && p[dotcount] == QLatin1Char('/')) {                if(dotcount == 1) {                    i++;                    while(i+1 < len-1 && p[i+1] == QLatin1Char('/'))                        i++;                    continue;                }            }        }        out[iwrite++] = p[i];        used++;    }    QString ret;    if(used == len)        ret = name;    else	ret = QString(out.data(), used);    // Strip away last slash except for root directories    if (ret.endsWith(QLatin1Char('/'))        && !(ret.size() == 1 || (ret.size() == 3 && ret.at(1) == QLatin1Char(':'))))        ret = ret.left(ret.length() - 1);    return ret;}/*!    Returns true if \a path is relative; returns false if it is    absolute.    \sa isRelative() isAbsolutePath() makeAbsolute()*/bool QDir::isRelativePath(const QString &path){    return QFileInfo(path).isRelative();}/*!    Refreshes the directory information.*/void QDir::refresh() const{    Q_D(const QDir);    d->data->clear();}/*!    \internal    Returns a list of name filters from the given \a nameFilter. (If    there is more than one filter, each pair of filters is separated    by a space or by a semicolon.)*/QStringList QDir::nameFiltersFromString(const QString &nameFilter){    return QDirPrivate::splitFilters(nameFilter);}/*!    \macro void Q_INIT_RESOURCE(name)    \relates QDir    Initializes the resources specified by the \c .qrc file with the    specified base \a name. Normally, Qt resources are loaded    automatically at startup. The Q_INIT_RESOURCE() macro is    necessary on some platforms for resources stored in a static    library.    For example, if your application's resources are listed in a file    called \c myapp.qrc, you can ensure that the resources are    initialized at startup by adding this line to your \c main()    function:    \code        Q_INIT_RESOURCE(myapp);    \endcode    Note: This macro cannot be used in a namespace. It should be called from    main(). If that is not possible, the following workaround can be used    to init the resource \c myapp from the function \c{MyNamespace::myFunction}:    \code    inline void initMyResource() { Q_INIT_RESOURCE(myapp); }    namespace MyNamespace    {        ...        void myFunction()        {            initMyResource();        }    }    \endcode    \sa Q_CLEANUP_RESOURCE(), {The Qt Resource System}*//*!    \since 4.1    \macro void Q_CLEANUP_RESOURCE(name)    \relates QDir    Unloads the resources specified by the \c .qrc file with the base    name \a name.    Normally, Qt resources are unloaded automatically when the    application terminates, but if the resources are located in a    plugin that is being unloaded, call Q_CLEANUP_RESOURCE() to force    removal of your resources.    Note: This macro cannot be used in a namespace. Please see the    Q_INIT_RESOURCE documentation for a workaround.    Example:    \code        Q_CLEANUP_RESOURCE(myapp);    \endcode    \sa Q_INIT_RESOURCE(), {The Qt Resource System}*/#ifdef QT3_SUPPORT/*!    \fn bool QDir::matchAllDirs() const    Use filter() & AllDirs instead.*/bool QDir::matchAllDirs() const{    Q_D(const QDir);    return d->matchAllDirs;}/*!    \fn void QDir::setMatchAllDirs(bool on)    Use setFilter() instead.*/void QDir::setMatchAllDirs(bool on){    Q_D(QDir);    d->matchAllDirs = on;}/*!    Use nameFilters() instead.*/QString QDir::nameFilter() const{    Q_D(const QDir);    return nameFilters().join(QString(d->filterSepChar));}/*!    Use setNameFilters() instead.    The \a nameFilter is a wildcard (globbing) filter that understands    "*" and "?" wildcards. (See \l{QRegExp wildcard matching}.) You may    specify several filter entries, each separated by spaces or by    semicolons.    For example, if you want entryList() and entryInfoList() to list    all files ending with either ".cpp" or ".h", you would use either    dir.setNameFilters("*.cpp *.h") or dir.setNameFilters("*.cpp;*.h").    \oldcode        QString filter = "*.cpp *.cxx *.cc";        dir.setNameFilter(filter);    \newcode        QString filter = "*.cpp *.cxx *.cc";        dir.setNameFilters(filter.split(' '));    \endcode*/void QDir::setNameFilter(const QString &nameFilter){    Q_D(QDir);    d->filterSepChar = QDirPrivate::getFilterSepChar(nameFilter);    setNameFilters(QDirPrivate::splitFilters(nameFilter, d->filterSepChar));}/*!    \fn QString QDir::absPath() const    Use absolutePath() instead.*//*!    \fn QString QDir::absFilePath(const QString &fileName, bool acceptAbsPath) const    Use absoluteFilePath(\a fileName) instead.    The \a acceptAbsPath parameter is ignored.*//*!    \fn bool QDir::mkdir(const QString &dirName, bool acceptAbsPath) const    Use mkdir(\a dirName) instead.    The \a acceptAbsPath parameter is ignored.*//*!    \fn bool QDir::rmdir(const QString &dirName, bool acceptAbsPath) const    Use rmdir(\a dirName) instead.    The \a acceptAbsPath parameter is ignored.*//*!    \fn QStringList QDir::entryList(const QString &nameFilter, Filters filters,                                    SortFlags sort) const    \overload    Use the overload that takes a name filter string list as first    argument instead of a combination of attribute filter flags.*//*!    \fn QFileInfoList QDir::entryInfoList(const QString &nameFilter, Filters filters,                                          SortFlags sort) const    \overload    U

⌨️ 快捷键说明

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