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


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

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


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

示例1: Move

/**
 * @brief RealPass::Move move a file (or folder)
 * @param src source file or folder
 * @param dest destination file or folder
 * @param force overwrite
 */
void RealPass::Move(const QString src, const QString dest, const bool force) {
  QFileInfo srcFileInfo = QFileInfo(src);
  QFileInfo destFileInfo = QFileInfo(dest);

  // force mode?
  // pass uses always the force mode, when call from eg. QT. so we have to check
  // if this are to files
  // and the user didnt want to move force
  if (!force && srcFileInfo.isFile() && destFileInfo.isFile()) {
    return;
  }

  QString passSrc = QDir(QtPassSettings::getPassStore())
                        .relativeFilePath(QDir(src).absolutePath());
  QString passDest = QDir(QtPassSettings::getPassStore())
                         .relativeFilePath(QDir(dest).absolutePath());

  // remove the .gpg because pass will not work
  if (srcFileInfo.isFile() && srcFileInfo.suffix() == "gpg") {
    passSrc.replace(QRegExp("\\.gpg$"), "");
  }
  if (destFileInfo.isFile() && destFileInfo.suffix() == "gpg") {
    passDest.replace(QRegExp("\\.gpg$"), "");
  }

  QStringList args;
  args << "mv";
  if (force) {
    args << "-f";
  }
  args << passSrc;
  args << passDest;
  executePass(PASS_MOVE, args);
}
开发者ID:IJHack,项目名称:qtpass,代码行数:40,代码来源:realpass.cpp

示例2: compare_files

//*******************************************************************
// compare_files                                             PRIVATE
//*******************************************************************
void QBtWorkspace::compare_files()
{
    QBtView* const v1 = left_panel_ ->current_view();
    QBtView* const v2 = right_panel_->current_view();
    if( !v1 || !v2 ) return;

    SelectionsSet d1 = SelectionsSet();
    SelectionsSet d2 = SelectionsSet();
    get_selections( v1, d1 );
    get_selections( v2, d2 );
    if( d1.size() != 1 ) return;
    if( d2.size() != 1 ) return;

    const QFileInfo f1( *d1.begin() );
    const QFileInfo f2( *d2.begin() );

    if( f1.isFile() && f2.isFile() ) {
        const QString fpath1 = f1.absoluteFilePath();
        const QString fpath2 = f2.absoluteFilePath();

        QBtCompareFileDialog dialog( this, fpath1, fpath2 );
        if( QDialog::Accepted == dialog.exec() ) {
            diff( fpath1, fpath2 );
        }
    }
    else {
        QMessageBox::information( this, tr( CompareFiles ), tr( NoFiles ) );
    }
}
开发者ID:sclown,项目名称:bsc,代码行数:32,代码来源:QBtWorkspace.cpp

示例3: initializePage

			void ThirdStep::initializePage ()
			{
				TotalSize_ = 0;
				QString path = field ("RootPath").toString ();

				QFileInfo pathInfo (path);
				if (pathInfo.isDir ())
				{
					QDirIterator it (path,
							QDirIterator::Subdirectories);
					while (it.hasNext ())
					{
						it.next ();
						QFileInfo info = it.fileInfo ();
						if (info.isFile () && info.isReadable ())
							TotalSize_ += info.size ();
					}
				}
				else if (pathInfo.isFile () &&
						pathInfo.isReadable ())
					TotalSize_ += pathInfo.size ();

				quint64 max = std::log (static_cast<long double> (TotalSize_ / 102400)) * 80;

				quint32 pieceSize = 32 * 1024;
				int shouldIndex = 0;
				for (; TotalSize_ / pieceSize >= max; pieceSize *= 2, ++shouldIndex) ;

				if (shouldIndex > PieceSize_->count () - 1)
					shouldIndex = PieceSize_->count () - 1;

				PieceSize_->setCurrentIndex (shouldIndex);

				on_PieceSize__currentIndexChanged ();
			}
开发者ID:Akon32,项目名称:leechcraft,代码行数:35,代码来源:thirdstep.cpp

示例4: fixQmlFrame

// Try to resolve files of a QML stack (resource files).
void StackFrame::fixQmlFrame(const DebuggerStartParameters &sp)
{
    if (language != QmlLanguage)
        return;
    QFileInfo aFi(file);
    if (aFi.isAbsolute()) {
        usable = aFi.isFile();
        return;
    }
    if (!file.startsWith(QLatin1String("qrc:/")))
        return;
    const QString relativeFile = file.right(file.size() - 5);
    if (!sp.projectSourceDirectory.isEmpty()) {
        const QFileInfo pFi(sp.projectSourceDirectory + QLatin1Char('/') + relativeFile);
        if (pFi.isFile()) {
            file = pFi.absoluteFilePath();
            usable = true;
            return;
        }
        const QFileInfo cFi(QDir::currentPath() + QLatin1Char('/') + relativeFile);
        if (cFi.isFile()) {
            file = cFi.absoluteFilePath();
            usable = true;
            return;
        }
    }
}
开发者ID:AltarBeastiful,项目名称:qt-creator,代码行数:28,代码来源:stackframe.cpp

示例5: checkBinary

// Locate a binary in a directory, applying all kinds of
// extensions the operating system supports.
static QString checkBinary(const QDir &dir, const QString &binary)
{
    // naive UNIX approach
    const QFileInfo info(dir.filePath(binary));

    if (info.isFile() && info.isExecutable()) {
        return info.absoluteFilePath();
    }

    // Does the OS have some weird extension concept or does the
    // binary have a 3 letter extension?
    if (pathOS == OS_Unix) {
        return QString();
    }
    const int dotIndex = binary.lastIndexOf(QLatin1Char('.'));
    if (dotIndex != -1 && dotIndex == binary.size() - 4) {
        return QString();
    }

    switch (pathOS) {
    case OS_Unix:
        break;
    case OS_Windows:
    {
        static const char *windowsExtensions[] = { ".cmd", ".bat", ".exe", ".com" };
        // Check the Windows extensions using the order
        const int windowsExtensionCount = sizeof(windowsExtensions) / sizeof(const char *);
        for (int e = 0; e < windowsExtensionCount; e++) {
            const QFileInfo windowsBinary(dir.filePath(binary + QLatin1String(windowsExtensions[e])));
            if (windowsBinary.isFile() && windowsBinary.isExecutable()) {
                return windowsBinary.absoluteFilePath();
            }
        }
    }
    break;
    case OS_Mac:
    {
        // Check for Mac app folders
        const QFileInfo appFolder(dir.filePath(binary + QLatin1String(".app")));
        if (appFolder.isDir()) {
            QString macBinaryPath = appFolder.absoluteFilePath();
            macBinaryPath += QLatin1String("/Contents/MacOS/");
            macBinaryPath += binary;
            const QFileInfo macBinary(macBinaryPath);
            if (macBinary.isFile() && macBinary.isExecutable()) {
                return macBinary.absoluteFilePath();
            }
        }
    }
    break;
    }
    return QString();
}
开发者ID:nongxiaoming,项目名称:QGroundStation,代码行数:55,代码来源:synchronousprocess.cpp

示例6: RenameFile

/** \fn     Content::RenameFile(const QString &sStorageGroup,
 *                              const QString &sFileName,
 *                              const QString &sNewFile)
 *  \brief  Renames the file to the new name.
 *  \param  sStorageGroup The storage group name where the image is located
 *  \param  sFileName The filename including the path that shall be renamed
 *  \param  sNewName  The new name of the file (only the name, no path)
 *  \return bool True if renaming was successful, otherwise false
 */
bool Content::RenameFile( const QString &sStorageGroup,
                          const QString &sFileName,
                          const QString &sNewName)
{
    QFileInfo fi = QFileInfo();
    fi = GetFile(sStorageGroup, sFileName);

    // Check if the file exists and is writable.
    // Only then we can actually delete it.
    if (!fi.isFile() && !QFile::exists(fi.absoluteFilePath()))
    {
        LOG(VB_GENERAL, LOG_ERR, "RenameFile - File does not exist.");
        return false;
    }

    // Check if the new filename has no path stuff specified
    if (sNewName.contains("/") || sNewName.contains("\\"))
    {
        LOG(VB_GENERAL, LOG_ERR, "RenameFile - New file must not contain a path.");
        return false;
    }
    
    // The newly renamed file must be in the same path as the original one.
    // So we need to check if a file of the new name exists and would be 
    // overwritten by the new filename. To to this get the path from the 
    // original file and append the new file name, Then check 
    // if it exists in the given storage group
    
    // Get the everthing until the last directory separator
    QString path = sFileName.left(sFileName.lastIndexOf("/"));
    // Append the new file name to the path
    QString newFileName = path.append("/").append(sNewName);
    
    QFileInfo nfi = QFileInfo();
    nfi = GetFile(sStorageGroup, newFileName);
    
    // Check if the target file is already present.
    // If is there then abort, overwriting is not supported
    if (nfi.isFile() || QFile::exists(nfi.absoluteFilePath()))
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("RenameFile - New file %1 would overwrite "
                    "existing one, not renaming.").arg(sFileName));
        return false;
    }

    // All checks have been passed, rename the file
    QFile file; 
    file.setFileName(fi.fileName());
    QDir::setCurrent(fi.absolutePath());
    return file.rename(sNewName);
}
开发者ID:doglover129,项目名称:mythtv,代码行数:61,代码来源:content.cpp

示例7: addFilesToArchive

void addFilesToArchive(const QDir &dir, const QFileInfo &info, QStringList &files)
{
	qDebug() << info.absoluteFilePath() << info.isDir() << info.isFile();
	if(info.isFile())
		files << dir.relativeFilePath(info.absoluteFilePath());
	else if(info.isDir())
	{
		qDebug() << info.absoluteFilePath() << QDir(info.absoluteFilePath()).entryList(QDir::AllEntries | QDir::NoDotAndDotDot);
		QFileInfoList file_infos = QDir(info.absoluteFilePath()).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
		foreach(const QFileInfo &file_info, file_infos)
		{
			addFilesToArchive(dir, file_info, files);
		}
开发者ID:CyberSys,项目名称:qutim,代码行数:13,代码来源:configpackagepage.cpp

示例8: load

bool QTranslator::load(const QString & filename, const QString & directory,
                       const QString & search_delimiters,
                       const QString & suffix)
{
    Q_D(QTranslator);
    d->clear();

    QString fname = filename;
    QString prefix;
    if (QFileInfo(filename).isRelative()) {
        prefix = directory;
        if (prefix.length() && !prefix.endsWith(QLatin1Char('/')))
            prefix += QLatin1Char('/');
    }


    QString realname;
    QString delims;
    delims = search_delimiters.isNull() ? QString::fromLatin1("_.") : search_delimiters;

    for (;;) {
        QFileInfo fi;


        realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix);
        fi.setFile(realname);
        if (fi.isReadable() && fi.isFile())
            break;

        realname = prefix + fname;
        fi.setFile(realname);
        if (fi.isReadable() && fi.isFile())
            break;

        int rightmost = 0;
        for (int i = 0; i < (int)delims.length(); i++) {
            int k = fname.lastIndexOf(delims[i]);
            if (k > rightmost)
                rightmost = k;
        }

        // no truncations? fail
        if (rightmost == 0)
            return false;

        fname.truncate(rightmost);
    }

    // realname is now the fully qualified name of a readable file.
    return d->do_load(realname);
}
开发者ID:fluxer,项目名称:katie,代码行数:51,代码来源:qtranslator.cpp

示例9: parseCmdLine

/**
 * Parses the command line, after it was stripped of its KDE options.
 * The command line may contain one of the following options:
 * 1. A project file (named cscope.proj)
 * 2. A Cscope cross-reference database
 * 3. A list of source files
 * @param	pArgs	Command line arguments
 */
void KScope::parseCmdLine(KCmdLineArgs* pArgs)
{
	QString sArg;
	QFileInfo fi;
	int i;

	// Loop over all arguments
	for (i = 0; i < pArgs->count(); i++) {
		// Verify the argument is a file or directory name
		sArg = pArgs->arg(i);
		fi.setFile(sArg);
		if (!fi.exists())
			continue;
			
		// Handle the current argument
		if (fi.isFile()) {
			if (fi.fileName() == "cscope.proj") {
				// Open a project file
				openProject(fi.dirPath(true));
				return;
			} else if (openCscopeOut(sArg)) {
				// Opened the file as a cross-reference database
				return;
			} else {
				// Assume this is a source file
				slotShowEditor(sArg, 0);
			}
		} else if (fi.isDir()) {
			// Treat the given path as a project directory
			openProject(fi.absFilePath());
			return;
		}
	}
}
开发者ID:VicHao,项目名称:kkscope,代码行数:42,代码来源:kscope.cpp

示例10: dropEvent

void MainWindow::dropEvent(QDropEvent *event)
{
   QList<QUrl> urlList;
   QString fName;
   QFileInfo info;
   QStringList dtaFiles;
   QString sessionFile = "";

   // Dateinamen extrahieren
   if( event->mimeData()->hasUrls())
   {
      urlList = event->mimeData()->urls();
      for( int i=0; i<urlList.size(); i++)
      {
         fName = urlList.at(i).toLocalFile(); // convert first QUrl to local path
         info.setFile(fName); // information about file
         if(info.isFile())
         {
            if( fName.endsWith(".dta",Qt::CaseInsensitive))
               dtaFiles << fName;
         }
      }

      // DTA-Dateien laden
      if(!dtaFiles.isEmpty()) readDataFiles(dtaFiles, true);
   }

   if( (sessionFile!="") && (!dtaFiles.isEmpty()))
      event->acceptProposedAction();
}
开发者ID:tinkostuff,项目名称:opendta-code,代码行数:30,代码来源:mainwindow.cpp

示例11: activatedFolderView

void FileBrowser::activatedFolderView(const QModelIndex &index)
{
    QFileInfo info = m_folderView->fileInfo(index);
    if (info.isFile()) {
        m_liteApp->fileManager()->openEditor(info.filePath());
    }
}
开发者ID:arnold8,项目名称:liteide,代码行数:7,代码来源:filebrowser.cpp

示例12: showBrowse

/// Display a file dialog.  If `directory` is an invalid file or directory the browser will start at the current
/// working directory.
/// \param const QString& title title of the window
/// \param const QString& directory directory to start the file browser at
/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QString& directory, const QString& nameFilter,
                                                  QFileDialog::AcceptMode acceptMode) {
    // On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
    // filename if the directory is valid.
    QString path = "";
    QFileInfo fileInfo = QFileInfo(directory);
    qDebug() << "File: " << directory << fileInfo.isFile();
    if (fileInfo.isDir()) {
        fileInfo.setFile(directory, "__HIFI_INVALID_FILE__");
        path = fileInfo.filePath();
    }
    
    QFileDialog fileDialog(Application::getInstance()->getWindow(), title, path, nameFilter);
    fileDialog.setAcceptMode(acceptMode);
    qDebug() << "Opening!";
    QUrl fileUrl(directory);
    if (acceptMode == QFileDialog::AcceptSave) {
        fileDialog.setFileMode(QFileDialog::Directory);
        fileDialog.selectFile(fileUrl.fileName());
    }
    if (fileDialog.exec()) {
        return QScriptValue(fileDialog.selectedFiles().first());
    }
    return QScriptValue::NullValue;
}
开发者ID:noirsoft,项目名称:hifi,代码行数:31,代码来源:WindowScriptingInterface.cpp

示例13: dropEvent

void GLWidget::dropEvent(QDropEvent *event)
{
    const QMimeData *mimeData = event->mimeData();
    if (mimeData->hasUrls()) {
        QList<QUrl> urlList = mimeData->urls();
        QString filename;
        QFileInfo info;
        for (int i = 0; i < urlList.size(); ++i) {
            filename = urlList.at(i).toLocalFile();
            info.setFile(filename);
            if (info.isFile()) {
                QString ext = info.suffix();
                if (ext == "scn") {
                    QDir::setCurrent(info.absolutePath());
                    if (load_scene_file(filename.toLatin1().data()))
                        event->acceptProposedAction();
                    else
                        qDebug() << "No scene";
                    lastfile = filename.toLatin1().data();
                }
             } else
                 qDebug() << "Unable to load file";
             update();
          }
      }
}
开发者ID:cheque,项目名称:s3d,代码行数:26,代码来源:glwidget.cpp

示例14: ListFilesInDirectoryTest

QMultiMap<QString,FileAttributes> ListFilesInDirectoryTest(QDir dir, bool Hash)
{
    extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
    qt_ntfs_permission_lookup++; // turn checking on
    QMultiMap<QString, FileAttributes> fileAttHashTable; //making hash table to store file attributes
    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    dir.setSorting(QDir::Name);
    QFileInfoList list = dir.entryInfoList();
    for (int i = 0; i < list.size(); ++i)
    {
       QFileInfo fileInfo = list.at(i);
       if (fileInfo.isFile())
       {
           FileAttributes tempFileAttributes;
           QDateTime date = fileInfo.lastModified();
           QString lastModified = date.toString();

            tempFileAttributes.absoluteFilePath = fileInfo.absoluteFilePath();
            tempFileAttributes.fileName = fileInfo.fileName();
            tempFileAttributes.filePath= fileInfo.path();
            if (Hash) tempFileAttributes.md5Hash = GetFileMd5hash(fileInfo.absoluteFilePath());
            tempFileAttributes.lastModified  = fileInfo.lastModified();
            tempFileAttributes.lastRead = fileInfo.lastRead();
            tempFileAttributes.created = fileInfo.created();
            tempFileAttributes.isHidden =  fileInfo.isHidden();
            tempFileAttributes.size = fileInfo.size();
            tempFileAttributes.owner = fileInfo.owner();
            fileAttHashTable.insert(fileInfo.absoluteFilePath(),tempFileAttributes);
       }

    }
return fileAttHashTable;
}
开发者ID:szkrawcz,项目名称:aInf,代码行数:33,代码来源:dirgrinder.cpp

示例15: findPlugin

QString findPlugin(const QString& filename) {
    QFileInfo info;
    info.setFile(AppDir+"/../lib/"+filename);
    if(info.exists() && info.isFile())
        return AppDir+"/../lib/"+filename;
    return QString();
}
开发者ID:zarmin,项目名称:KeePassX_zmod,代码行数:7,代码来源:main.cpp


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