当前位置: 首页>>代码示例>>C++>>正文


C++ QFileInfo::isSymLink方法代码示例

本文整理汇总了C++中QFileInfo::isSymLink方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfo::isSymLink方法的具体用法?C++ QFileInfo::isSymLink怎么用?C++ QFileInfo::isSymLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QFileInfo的用法示例。


在下文中一共展示了QFileInfo::isSymLink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: toFileInfo

FileInfo toFileInfo(const QFileInfo &info)
{
    FileInfo fi;

    fi.m_valid = true;
    fi.m_exists = info.exists();
    fi.m_permissions = info.permissions();
    fi.m_isSymlink = info.isSymLink();
    fi.m_type = FileInfo::System;
    fi.m_hidden = info.isHidden();
    fi.m_size = -1;
    fi.m_lastModified = info.lastModified();

    if (info.isDir())
        fi.m_type = FileInfo::Dir;
    else if (info.isFile())
        fi.m_type = FileInfo::File;
    else if (!info.exists() && info.isSymLink())
        fi.m_type = FileInfo::System;

    if (fi.type() == FileInfo::Dir)
        fi.m_size = 0;
    else if (fi.type() == FileInfo::File)
        fi.m_size = info.size();
    if (!info.exists() && !info.isSymLink())
        fi.m_size = -1;

    return fi;
}
开发者ID:vistle,项目名称:vistle,代码行数:29,代码来源:remotefileinfogatherer.cpp

示例2: advance

/*!
    \internal
*/
void QDirIteratorPrivate::advance()
{
    // Store the current entry
    if (!fileEngineIterators.isEmpty())
        currentFilePath = fileEngineIterators.top()->currentFilePath();

    // Advance to the next entry
    if (followNextDir) {
        // Start by navigating into the current directory.
        followNextDir = false;

        QAbstractFileEngineIterator *it = fileEngineIterators.top();

        QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
        if (currentFileInfo.isSymLink())
            subDir = currentFileInfo.canonicalFilePath();
#endif
        pushSubDirectory(subDir, it->nameFilters(), it->filters());
    }

    while (!fileEngineIterators.isEmpty()) {
        QAbstractFileEngineIterator *it = fileEngineIterators.top();

        // Find the next valid iterator that matches the filters.
        bool foundDirectory = false;
        while (it->hasNext()) {
            it->next();
            if (matchesFilters(it)) {
                currentFileInfo = nextFileInfo;
                nextFileInfo = it->currentFileInfo();
                // Signal that we want to follow this entry.
                followNextDir = shouldFollowDirectory(nextFileInfo);
                //We found a matching entry.
                return;

            } else if (iteratorFlags & QDirIterator::Subdirectories) {
                QFileInfo fileInfo = it->currentFileInfo();

                if (!shouldFollowDirectory(fileInfo))
                    continue;
                QString subDir = it->currentFilePath();
#ifdef Q_OS_WIN
                if (fileInfo.isSymLink())
                    subDir = fileInfo.canonicalFilePath();
#endif
                pushSubDirectory(subDir, it->nameFilters(), it->filters());
                
                foundDirectory = true;
                break;
            }
        }
        if (!foundDirectory)
            delete fileEngineIterators.pop();
    }
    currentFileInfo = nextFileInfo;
    done = true;
}
开发者ID:Fale,项目名称:qtmoko,代码行数:61,代码来源:qdiriterator.cpp

示例3: type

QString QFileIconProvider::type(const QFileInfo &info) const
{
    if (info.isRoot())
        return QApplication::translate("QFileDialog", "Drive");
    if (info.isFile()) {
        if (!info.suffix().isEmpty())
            return info.suffix() + QLatin1Char(' ') + QApplication::translate("QFileDialog", "File");
        return QApplication::translate("QFileDialog", "File");
    }

    if (info.isDir())
#ifdef Q_WS_WIN
        return QApplication::translate("QFileDialog", "File Folder", "Match Windows Explorer");
#else
        return QApplication::translate("QFileDialog", "Folder", "All other platforms");
#endif
    // Windows   - "File Folder"
    // OS X      - "Folder"
    // Konqueror - "Folder"
    // Nautilus  - "folder"

    if (info.isSymLink())
#ifdef Q_OS_MAC
        return QApplication::translate("QFileDialog", "Alias", "Mac OS X Finder");
#else
        return QApplication::translate("QFileDialog", "Shortcut", "All other platforms");
#endif
    // OS X      - "Alias"
    // Windows   - "Shortcut"
    // Konqueror - "Folder" or "TXT File" i.e. what it is pointing to
    // Nautilus  - "link to folder" or "link to object file", same as Konqueror

    return QApplication::translate("QFileDialog", "Unknown");
}
开发者ID:diversys,项目名称:qt4,代码行数:34,代码来源:qfileiconprovider.cpp

示例4: icon

QIcon TIconProvider::icon(const QFileInfo& fi) const {

    if (fi.isSymLink()) {
        if (fi.isDir() || extensions.isPlaylist(fi)) {
            return folderLinkIcon;
        }
        return fileLinkIcon;
    }

    if (fi.isDir() || extensions.isPlaylist(fi)) {
        return folderIcon;
    }

    if (fi.filePath().startsWith("dvd://")
        || fi.filePath().startsWith("dvdnav://")
        || fi.filePath().startsWith("br://")) {
        return driveDVDIcon;
    }

    if (fi.filePath().startsWith("vcd://")
        || fi.filePath().startsWith("cdda://")) {
        return driveCDIcon;
    }

    QIcon i = QFileIconProvider::icon(fi);
    if (i.isNull()) {
        return fileIcon;
    }

    return i;
}
开发者ID:wilbert2000,项目名称:wzplayer,代码行数:31,代码来源:iconprovider.cpp

示例5: listOpenedFd

void listOpenedFd()
{
    qDebug() << Q_FUNC_INFO;

    pid_t pid = getpid();
    qDebug() << Q_FUNC_INFO << pid;

    QString path("/proc/");
    path.append(QString::number(pid));
    path.append("/fd");

    QDir pidDir(path);

    qDebug() << Q_FUNC_INFO << path;

    QStringList list = pidDir.entryList();

    QStringList::const_iterator it = list.begin();
    QStringList::const_iterator itEnd = list.end();

    QFileInfo fi;
    for(; it != itEnd; ++it)
    {
        QString file_path = pidDir.filePath(*it);
        fi.setFile(file_path);

        qDebug() << Q_FUNC_INFO << fi.isSymLink() << fi.symLinkTarget();
    }
}
开发者ID:oskrs111,项目名称:3p.cervantes,代码行数:29,代码来源:StorageMx508.cpp

示例6: shouldFollowDirectory

/*!
    \internal
 */
bool QDirIteratorPrivate::shouldFollowDirectory(const QFileInfo &fileInfo)
{
    // If we're doing flat iteration, we're done.
    if (!(iteratorFlags & QDirIterator::Subdirectories))
        return false;
    
    // Never follow non-directory entries
    if (!fileInfo.isDir())
        return false;


    // Never follow . and ..
    if (fileInfo.fileName() == QLatin1String(".") || fileInfo.fileName() == QLatin1String(".."))
        return false;

      
    // Check symlinks
    if (fileInfo.isSymLink() && !(iteratorFlags & QDirIterator::FollowSymlinks)) {
        // Follow symlinks only if FollowSymlinks was passed
        return false;
    }

    // Stop link loops
    if (visitedLinks.contains(fileInfo.canonicalFilePath()))
        return false;
    
    return true;
}
开发者ID:Fale,项目名称:qtmoko,代码行数:31,代码来源:qdiriterator.cpp

示例7: checkAndPushDirectory

/*!
    \internal
 */
void QDirIteratorPrivate::checkAndPushDirectory(const QFileInfo &fileInfo)
{
    // If we're doing flat iteration, we're done.
    if (!(iteratorFlags & QDirIterator::Subdirectories))
        return;

    // Never follow non-directory entries
    if (!fileInfo.isDir())
        return;

    // Follow symlinks only when asked
    if (!(iteratorFlags & QDirIterator::FollowSymlinks) && fileInfo.isSymLink())
        return;

    // Never follow . and ..
    QString fileName = fileInfo.fileName();
    if (QLatin1String(".") == fileName || QLatin1String("..") == fileName)
        return;

    // No hidden directories unless requested
    if (!(filters & QDir::AllDirs) && !(filters & QDir::Hidden) && fileInfo.isHidden())
        return;

    // Stop link loops
    if (!visitedLinks.isEmpty() &&
        visitedLinks.contains(fileInfo.canonicalFilePath()))
        return;

    pushDirectory(fileInfo);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:33,代码来源:qdiriterator.cpp

示例8: dirIterator

QSet<MacBinaryInfo> MacReplaceInstallNamesOperation::collectPatchableBinaries(const QString &searchDir)
{
    QSet<MacBinaryInfo> patchableBinaries;
    QDirIterator dirIterator(searchDir, QDirIterator::Subdirectories);
    while (dirIterator.hasNext()) {
        const QString fileName = dirIterator.next();
        const QFileInfo fileInfo = dirIterator.fileInfo();
        if (fileInfo.isDir() || fileInfo.isSymLink())
            continue;

        MacBinaryInfo binaryInfo;
        binaryInfo.fileName = fileName;

        // try to find libraries in frameworks
        if (fileName.contains(QLatin1String(".framework/")) && !fileName.contains(QLatin1String("/Headers/"))
            && updateExecutableInfo(&binaryInfo) == 0) {
                patchableBinaries.insert(binaryInfo);
        } else if (fileName.endsWith(QLatin1String(".dylib")) && updateExecutableInfo(&binaryInfo) == 0) {
            patchableBinaries.insert(binaryInfo);
        } // the endsWith checks are here because there might be wrongly committed files in the repositories
        else if (dirIterator.fileInfo().isExecutable() && !fileName.endsWith(QLatin1String(".h"))
            && !fileName.endsWith(QLatin1String(".cpp")) && !fileName.endsWith(QLatin1String(".pro"))
            && !fileName.endsWith(QLatin1String(".pri")) && updateExecutableInfo(&binaryInfo) == 0) {
                 patchableBinaries.insert(binaryInfo);
        }
    }
    return patchableBinaries;
}
开发者ID:olear,项目名称:qtifw,代码行数:28,代码来源:macreplaceinstallnamesoperation.cpp

示例9: forPermissions

    QString forPermissions(const QFileInfo &info)
    {
        mode_t p = 0;

        if (info.isDir())
            p |= S_IFDIR;
        if (info.isSymLink())
            p |= S_IFLNK;

        if (info.permission(QFile::ReadUser))
            p |= S_IRWXU & S_IRUSR;
        if (info.permission(QFile::WriteUser))
            p |= S_IRWXU & S_IWUSR;
        if (info.permission(QFile::ExeUser))
            p |= S_IRWXU & S_IXUSR;

        if (info.permission(QFile::ReadGroup))
            p |= S_IRWXG & S_IRGRP;
        if (info.permission(QFile::WriteGroup))
            p |= S_IRWXG & S_IWGRP;
        if (info.permission(QFile::ExeGroup))
            p |= S_IRWXG & S_IXGRP;

        if (info.permission(QFile::ReadOther))
            p |= S_IRWXO & S_IROTH;
        if (info.permission(QFile::WriteOther))
            p |= S_IRWXO & S_IWOTH;
        if (info.permission(QFile::ExeOther))
            p |= S_IRWXO & S_IXOTH;

        return forPermissions(p);
    }
开发者ID:curvedspace,项目名称:vibe,代码行数:32,代码来源:vfilestring.cpp

示例10: runningUnderDebugger

QT_BEGIN_NAMESPACE

// Find out if our parent process is gdb by looking at the 'exe' symlink under /proc,.
// or, for older Linuxes, read out 'cmdline'.
static bool runningUnderDebugger()
{
#if defined(QT_DEBUG) && defined(Q_OS_LINUX)
    const QString parentProc = QLatin1String("/proc/") + QString::number(getppid());
    const QFileInfo parentProcExe(parentProc + QLatin1String("/exe"));
    if (parentProcExe.isSymLink())
        return parentProcExe.symLinkTarget().endsWith(QLatin1String("/gdb"));
    QFile f(parentProc + QLatin1String("/cmdline"));
    if (!f.open(QIODevice::ReadOnly))
        return false;
    QByteArray s;
    char c;
    while (f.getChar(&c) && c) {
        if (c == '/')
            s.clear();
        else
            s += c;
    }
    return s == "gdb";
#else
    return false;
#endif
}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:27,代码来源:qxcbintegration.cpp

示例11: slotAddPathWithSubFolders

void QucsSettingsDialog::slotAddPathWithSubFolders()
{
    // open a file dialog to select the top level directory
    QFileDialog fileDialog( this, tr("Select a directory"), QucsSettings.QucsWorkDir.canonicalPath());
    fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
    fileDialog.setFileMode(QFileDialog::DirectoryOnly);

    QString path;
    QFileInfo pathfinfo;

    if (fileDialog.exec())
    {
        // Iterate through the directories
        QDirIterator pathIter(fileDialog.selectedFile(), QDirIterator::Subdirectories);
        while (pathIter.hasNext())
        {
            path = pathIter.next();
            pathfinfo = pathIter.fileInfo();

            if (pathfinfo.isDir() && !pathfinfo.isSymLink() && !path.endsWith("."))
            {
                QDir thispath(path);
                currentPaths.append(thispath.canonicalPath());
            }
        }
        makePathTable();
    }
    else
    {
        // user cancelled
    }


}
开发者ID:myutwo,项目名称:qucs,代码行数:34,代码来源:qucssettingsdialog.cpp

示例12: getDirSize

/* private slots */
qint64 ShredThread::getDirSize(QString &dir)
{
    uint _size = 0;
    QDir::Filters flags =
            QDir::AllEntries |
            QDir::NoDotAndDotDot |
            QDir::Hidden |
            QDir::System |
            QDir::AllDirs;
    QDir d;
    d.setPath(dir);
    QList<QFileInfo> entry = d.entryInfoList(flags);
    if ( !entry.isEmpty() ) {
        QList<QFileInfo>::const_iterator i;
        for ( i=entry.constBegin(); i<entry.constEnd(); i++ ) {
            QFileInfo item = *i;
            if ( !item.exists() ) continue;
            QString path = item.canonicalFilePath();
            if ( path==d.absoluteFilePath(dir)
                 || item.isSymLink() )
                continue;
            if ( item.isDir() ) {
                _size += getDirSize(path);
            } else {
                _size += item.size();
            };
        };
    };
    return _size;
}
开发者ID:F1ash,项目名称:se-sandbox-runner,代码行数:31,代码来源:shred_thread.cpp

示例13: deleteFileOrFolder

bool SyncAction::deleteFileOrFolder(SyncFile * sf, FolderActionGroup * fag)
{
    QFileInfo fi;
    for (int i = 0; i < fag->count(); ++i) {
        MTFile file(QDir(fag->at(i)).absoluteFilePath(sf->getName()));
        fi.setFile(file);

        if (fi.isDir() && !fi.isSymLink()) {
            if (removeFolder(fi)) {
                sf->setFileStatusInFolder(fag->idAt(i), SyncFile::Deleted);
                emit this->syncOutMessage(new SyncOutMessage(SyncOutMessage::FolderDeleted, new FolderActionGroup(fag->idAt(i), fi.absoluteFilePath())));
            } else
                emit this->syncOutMessage(new SyncOutMessage(SyncOutMessage::FolderDeleted, new FolderActionGroup(fag->idAt(i), fi.absoluteFilePath()), true));
        }
        else {
            if (!backup_action->backupFile(&file)) {
                continue;
            }

            if (file.remove()) {
                sf->setFileStatusInFolder(fag->idAt(i), SyncFile::Deleted);
                emit this->syncOutMessage(new SyncOutMessage(SyncOutMessage::FileDeleted, new FolderActionGroup(fag->idAt(i), fi.absoluteFilePath())));
            } else
                emit this->syncOutMessage(new SyncOutMessage(SyncOutMessage::FileDeleted, new FolderActionGroup(fag->idAt(i), fi.absoluteFilePath()), true, file.errorString()));
        }
    }
    sf->setModified(true);
    return true;
}
开发者ID:matus-tomlein,项目名称:synkron,代码行数:29,代码来源:syncaction.cpp

示例14: pushDirectory

/*!
    \internal
*/
void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo)
{
    QString path = fileInfo.filePath();

#ifdef Q_OS_WIN
    if (fileInfo.isSymLink())
        path = fileInfo.canonicalFilePath();
#endif

    if (iteratorFlags & QDirIterator::FollowSymlinks)
        visitedLinks << fileInfo.canonicalFilePath();

    if (engine) {
        engine->setFileName(path);
        QAbstractFileEngineIterator *it = engine->beginEntryList(filters, nameFilters);
        if (it) {
            it->setPath(path);
            fileEngineIterators << it;
        } else {
            // No iterator; no entry list.
        }
    } else {
#ifndef QT_NO_FILESYSTEMITERATOR
        QFileSystemIterator *it = new QFileSystemIterator(fileInfo.d_ptr->fileEntry,
            filters, nameFilters, iteratorFlags);
        nativeIterators << it;
#endif
    }
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:32,代码来源:qdiriterator.cpp

示例15: addFileNode

  tlp::node addFileNode(const QFileInfo &infos, tlp::Graph *g) {
    tlp::node n = g->addNode();
    _absolutePaths->setNodeValue(n,tlp::QStringToTlpString(infos.absoluteFilePath()));
    _baseNames->setNodeValue(n,tlp::QStringToTlpString(infos.baseName()));
    _createdDates->setNodeValue(n,tlp::QStringToTlpString(infos.created().toString()));
    _fileNames->setNodeValue(n,tlp::QStringToTlpString(infos.fileName()));
    _isDir->setNodeValue(n,infos.isDir());
    _isExecutable->setNodeValue(n,infos.isExecutable());
    _isReadable->setNodeValue(n,infos.isReadable());
    _isSymlink->setNodeValue(n,infos.isSymLink());
    _isWritable->setNodeValue(n,infos.isWritable());
    _lastModifiedDates->setNodeValue(n,tlp::QStringToTlpString(infos.lastModified().toString()));
    _lastReadDates->setNodeValue(n,tlp::QStringToTlpString(infos.lastRead().toString()));
    _owners->setNodeValue(n,tlp::QStringToTlpString(infos.owner()));
    _permissions->setNodeValue(n,(int)(infos.permissions()));
    _suffixes->setNodeValue(n,tlp::QStringToTlpString(infos.suffix()));
    _sizes->setNodeValue(n,infos.size());

    if (_useIcons) {
      std::string extension = infos.suffix().toStdString();

      if (infos.isDir()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FolderO);
        tlp::ColorProperty *viewColor = graph->getProperty<tlp::ColorProperty>("viewColor");
        viewColor->setNodeValue(n, dirColor);
      }
      else if (std::find(commonTextFilesExt.begin(), commonTextFilesExt.end(), extension) != commonTextFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileTextO);
      }
      else if (std::find(commonArchiveFilesExt.begin(), commonArchiveFilesExt.end(), extension) != commonArchiveFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileArchiveO);
      }
      else if (std::find(commonAudioFilesExt.begin(), commonAudioFilesExt.end(), extension) != commonAudioFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileAudioO);
      }
      else if (std::find(commonImageFilesExt.begin(), commonImageFilesExt.end(), extension) != commonImageFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileImageO);
      }
      else if (std::find(commonVideoFilesExt.begin(), commonVideoFilesExt.end(), extension) != commonVideoFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileVideoO);
      }
      else if (std::find(commonDevFilesExt.begin(), commonDevFilesExt.end(), extension) != commonDevFilesExt.end()) {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileCodeO);
      }
      else if (extension == "pdf") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FilePdfO);
      }
      else if (extension == "doc" || extension == "docx") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileWordO);
      }
      else if (extension == "xls" || extension == "xlsx") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileExcelO);
      }
      else if (extension == "ppt" || extension == "pptx") {
        _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FilePowerpointO);
      }
    }

    return n;
  }
开发者ID:mneumann,项目名称:tulip,代码行数:60,代码来源:FileSystem.cpp


注:本文中的QFileInfo::isSymLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。