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


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

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


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

示例3:

DocumentWatcher::Details::Details(const QFileInfo& info) :
	path(info.canonicalFilePath()),
	modified(info.lastModified()),
	permissions(info.permissions()),
	ignored(false)
{
}
开发者ID:FractalBobz,项目名称:focuswriter,代码行数:7,代码来源:document_watcher.cpp

示例4: if

static inline std::string permissions(const QFileInfo &fi)
{
    std::string result = permissions(fi.permissions());
    if (fi.isSymLink())
        result[0] = 'l';
    else if (fi.isDir())
        result[0] = 'd';
    return result;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:9,代码来源:main.cpp

示例5: name

MyDirEntry::MyDirEntry(const QFileInfo& info) : 
  name(info.fileName()),
  owner(info.owner()), 
  group(info.group()), 
  lastModified(info.lastModified()),
  permissions(info.permissions()),
  lastModifiedBy(hostName),
  parent(0)
{};
开发者ID:porphyr,项目名称:SyncBox,代码行数:9,代码来源:mydirentry.cpp

示例6: initFromFile

void CentralDirFileHeader::initFromFile( const QFileInfo& file )
{
    LocalFileHeader::initFromFile( file );

    setPermissions( file.permissions(), file.isDir() );

    // Windows Only: Add the files attributes to externalAttr (e.g. archive, readonly, system etc.)
    quint32 attr = getFileAttributes( file.filePath() );

    if ( attr & 0x20 )  // Archive
        externalFileAttr |= 0x20;
    if ( attr & 0x10 )  // Folder
        externalFileAttr |= 0x10;
    if ( attr & 0x08 )  // System
        externalFileAttr |= 0x08;
    if ( attr & 0x02 )  // Hidden
        externalFileAttr |= 0x02;
    if ( attr & 0x01 )  // ReadOnly
        externalFileAttr |= 0x01;
}
开发者ID:abelayer,项目名称:AbZip,代码行数:20,代码来源:CentralDirFileHeader.cpp

示例7: confirmExecutableOpen

void Widget::confirmExecutableOpen(const QFileInfo file)
{
    static const QStringList dangerousExtensions = { "app", "bat", "com", "cpl", "dmg", "exe", "hta", "jar", "js", "jse", "lnk", "msc", "msh", "msh1", "msh1xml", "msh2", "msh2xml", "mshxml", "msi", "msp", "pif", "ps1", "ps1xml", "ps2", "ps2xml", "psc1", "psc2", "py", "reg", "scf", "sh", "src", "vb", "vbe", "vbs", "ws", "wsc", "wsf", "wsh" };

    if (dangerousExtensions.contains(file.suffix()))
    {
        if (!GUI::askQuestion(tr("Executable file", "popup title"), tr("You have asked qTox to open an executable file. Executable files can potentially damage your computer. Are you sure want to open this file?", "popup text"), false, true))
        {
            return;
        }
        
        // The user wants to run this file, so make it executable and run it
        QFile(file.filePath()).setPermissions(file.permissions() | QFile::ExeOwner | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther);
        QProcess::startDetached(file.filePath());
    }
    else
    {
        QDesktopServices::openUrl(QUrl::fromLocalFile(file.filePath()));
    }
}
开发者ID:AWeinb,项目名称:qTox,代码行数:20,代码来源:widget.cpp

示例8: slotSelectionChanged

void FileInfoWidget::slotSelectionChanged(const QItemSelection&, const QItemSelection&)
{
    Page* pPage = dynamic_cast<Page*>(parent());
    if (pPage)
    {
        QFileSystemModel* pModel = dynamic_cast<QFileSystemModel*>(pPage->mpFileList->model());
        if (pModel)
        {
            QFileInfo info = pModel->fileInfo(pPage->mpFileList->currentIndex());
            if (info.isFile() && qPrintable(info.absoluteFilePath()))
            {
                QPixmap pixmap(info.absoluteFilePath());
                double dScale = pixmap.width() > pixmap.height() ? (double)imageSize.width() / pixmap.width() : (double)imageSize.height() / pixmap.height();
                dScale *= 0.9;
                mpImage->setPixmap(pixmap.scaled(pixmap.width() * dScale, pixmap.height() * dScale));
            }
            else mpImage->setPixmap(transparentImage);

            mpAbsolutePath->setText(QString("File Path: %1").arg(info.absoluteFilePath()));
            mpPermissions->setText(QString("Permissions: %1").arg(info.permissions(), 0, 16));
            mpSize->setText(QString("Size: %1").arg(info.size()));
        }
    }
}
开发者ID:lwch,项目名称:QLanguage,代码行数:24,代码来源:FileInfoWidget.cpp

示例9: equals

bool MyDirEntry::equals(const QFileInfo& info) const{
  return (  isDir() == info.isDir()
    && owner == info.owner()
    && lastModified == info.lastModified()
    && permissions == info.permissions());
}
开发者ID:porphyr,项目名称:SyncBox,代码行数:6,代码来源:mydirentry.cpp


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