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


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

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


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

示例1: listFolder


//.........这里部分代码省略.........
                                {
                                    destinationSuffixPath=otherRenamingRule;
                                    destinationSuffixPath.replace(QStringLiteral("%name%"),destination.baseName());
                                    destinationSuffixPath.replace(QStringLiteral("%number%"),QString::number(num));
                                }
                            }
                            destinationInfo.setFile(destinationInfo.absolutePath()+text_slash+destinationSuffixPath);
                            num++;
                        }
                        while(destinationInfo.exists());
                    }
                    else
                    {
                        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"use new name: "+newName);
                        destinationSuffixPath = newName;
                    }
                    if(destination.completeSuffix().isEmpty())
                        destination.setFile(destination.absolutePath()+text_slash+destinationSuffixPath);
                    else
                        destination.setFile(destination.absolutePath()+text_slash+destinationSuffixPath+QStringLiteral(".")+destination.completeSuffix());
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination after rename: "+destination.absoluteFilePath());
                break;
                default:
                    return;
                break;
            }
        }
    }
    //do source check
    //check of source is readable
    do
    {
        fileErrorAction=FileError_NotSet;
        if(!source.isReadable() || !source.isExecutable() || !source.exists() || !source.isDir())
        {
            if(!source.isDir())
                emit errorOnFolder(source,tr("This is not a folder"));
            else if(!source.exists())
                emit errorOnFolder(source,tr("The folder does exists"));
            else
                emit errorOnFolder(source,tr("The folder is not readable"));
            waitOneAction.acquire();
            ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"actionNum: "+QString::number(fileErrorAction));
        }
    } while(fileErrorAction==FileError_Retry);
    do
    {
        QDir tempDir(source.absoluteFilePath());
        fileErrorAction=FileError_NotSet;
        if(!tempDir.isReadable() || !tempDir.exists())
        {
            emit errorOnFolder(source,tr("Problem with name encoding"));
            waitOneAction.acquire();
            ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"actionNum: "+QString::number(fileErrorAction));
        }
    } while(fileErrorAction==FileError_Retry);
    if(stopIt)
        return;
    /// \todo check here if the folder is not readable or not exists
    QFileInfoList entryList;
    if(copyListOrder)
        entryList=QDir(source.absoluteFilePath()).entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden|QDir::System,QDir::DirsFirst|QDir::Name|QDir::IgnoreCase);//possible wait time here
    else
        entryList=QDir(source.absoluteFilePath()).entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden|QDir::System);//possible wait time here
    if(stopIt)
        return;
开发者ID:amitamitamitamit,项目名称:Ultracopier,代码行数:67,代码来源:ScanFileOrFolder.cpp

示例2: HandleImport

void IconView::HandleImport(void)
{
    QFileInfo path;
    QDir importdir;

#if 0
    DialogBox *importDlg = new DialogBox(GetMythMainWindow(),
                                         tr("Import pictures?"));

    importDlg->AddButton(tr("No"));
    importDlg->AddButton(tr("Yes"));
    DialogCode code = importDlg->exec();
    importDlg->deleteLater();
    if (kDialogCodeButton1 != code)
        return;
#endif

    // Makes import directory samba/windows friendly (no colon)
    QString idirname = m_currDir + "/" +
        MythDate::current().toString("yyyy-MM-dd_hh-mm-ss");

    importdir.mkdir(idirname);
    importdir.setPath(idirname);

    for (QStringList::const_iterator it = m_paths.begin();
         it != m_paths.end(); ++it)
    {
        path.setFile(*it);
        if (path.isDir() && path.isReadable())
        {
            ImportFromDir(*it, importdir.absolutePath());
        }
#if 0
        else if (path.isFile() && path.isExecutable())
        {
            // TODO this should not be enabled by default!!!
            QString cmd = *it + " " + importdir.absolutePath();
            LOG(VB_GENERAL, LOG_INFO, LOC + QString("Executing %1").arg(cmd));
            myth_system(cmd);
        }
#endif
        else
        {
            LOG(VB_GENERAL, LOG_ERR, LOC +
                QString("Could not read or execute %1").arg(*it));
        }
    }

    importdir.refresh();
    if (importdir.count() == 0)
    {
#if 0
        DialogBox *nopicsDlg = new DialogBox(GetMythMainWindow(),
                                             tr("Nothing found to import"));

        nopicsDlg->AddButton(tr("OK"));
        nopicsDlg->exec();
        nopicsDlg->deleteLater();
#endif

        return;
    }

    LoadDirectory(m_currDir);
}
开发者ID:iainlane,项目名称:mythtv,代码行数:65,代码来源:iconview.cpp

示例3: set_defaults


//.........这里部分代码省略.........


      misc->abe_share->key = 0;
      misc->abe_share->modcode = 0;
      misc->displayed_area.min_y = -91.0;

      misc->qsettings_org = pfmEdit3D::tr ("navo.navy.mil");
      misc->qsettings_app = pfmEdit3D::tr ("pfmEdit3D");

      misc->add_feature_index = -1;
      misc->nearest_feature_point = -1;

      misc->bfd_open = NVFalse;

      misc->undo = NULL;
      misc->undo_count = 0;
      misc->time_attr = -1;
      misc->datum_attr = -1;
      misc->ellipsoid_attr = -1;
      misc->process_id = getpid ();


      //  This is a special case for an option.  We don't want to reset the undo levels if we called for a restore of defaults from the prefs dialog.

      options->undo_levels = 100;


#ifdef NVWIN3X

      misc->help_browser = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";

      QFileInfo br (misc->help_browser);

      if (!br.exists () || !br.isExecutable ()) misc->help_browser = "C:\\Program Files\\Internet Explorer\\iexplore.exe";

#else

      misc->help_browser = "firefox";

#endif
    }


  /*

    Ancillary program command line substitutions:


    [MOSAIC_FILE] - associated mosaic file name
    [TARGET_FILE] - associated feature (target) file name
    [PFM_FILE] - PFM list or handle file name
    [BIN_FILE] - PFM bin directory name
    [INDEX_FILE] - PFM index directory name
    [INPUT_FILE] - input data file associated with the current point
    [SHARED_MEMORY_ID] - ABE shared memory ID (some programs like chartsPic require this)
    [LINE] - line name associated with the current point
    [Z_VALUE] - Z value of the current point
    [X_VALUE] - X value (usually longitude) associated with the current point
    [Y_VALUE] - Y value (usually latitude) associated with the current point
    [MIN_Y] - minimum Y value in the currently displayed area
    [MIN_X] - minimum X value in the currently displayed area
    [MAX_Y] - maximum Y value in the currently displayed area
    [MAX_X] - maximum X value in the currently displayed area
    [FILE_NUMBER] - PFM input file number associated with the current point
    [LINE_NUMBER] - PFM input line number associated with the current point
    [VALIDITY] - PFM validity word for the current point
开发者ID:dmagiccys,项目名称:pfmabe,代码行数:67,代码来源:set_defaults.cpp

示例4: matchesFilters

bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInfo &fi) const
{
    Q_ASSERT(!fileName.isEmpty());

    // filter . and ..?
    const int fileNameSize = fileName.size();
    const bool dotOrDotDot = fileName[0] == QLatin1Char('.')
                             && ((fileNameSize == 1)
                                 ||(fileNameSize == 2 && fileName[1] == QLatin1Char('.')));
    if ((filters & QDir::NoDot) && dotOrDotDot && fileNameSize == 1)
        return false;
    if ((filters & QDir::NoDotDot) && dotOrDotDot && fileNameSize == 2)
        return false;
    if ((filters & QDir::NoDotAndDotDot) && dotOrDotDot) // ### Qt5 remove (NoDotAndDotDot == NoDot|NoDotDot)
        return false;

    // name filter
#ifndef QT_NO_REGEXP
    // Pass all entries through name filters, except dirs if the AllDirs
    if (!nameFilters.isEmpty() && !((filters & QDir::AllDirs) && fi.isDir())) {
        bool matched = false;
        for (QVector<QRegExp>::const_iterator iter = nameRegExps.constBegin(),
                                              end = nameRegExps.constEnd();
                iter != end; ++iter) {

            if (iter->exactMatch(fileName)) {
                matched = true;
                break;
            }
        }
        if (!matched)
            return false;
    }
#endif
    // skip symlinks
    const bool skipSymlinks = (filters & QDir::NoSymLinks);
    const bool includeSystem = (filters & QDir::System);
    if(skipSymlinks && fi.isSymLink()) {
        // The only reason to save this file is if it is a broken link and we are requesting system files.
        if(!includeSystem || fi.exists())
            return false;
    }

    // filter hidden
    const bool includeHidden = (filters & QDir::Hidden);
    if (!includeHidden && !dotOrDotDot && fi.isHidden())
        return false;

    // filter system files
    if (!includeSystem && (!(fi.isFile() || fi.isDir() || fi.isSymLink())
                    || (!fi.exists() && fi.isSymLink())))
        return false;

    // skip directories
    const bool skipDirs = !(filters & (QDir::Dirs | QDir::AllDirs));
    if (skipDirs && fi.isDir())
        return false;

    // skip files
    const bool skipFiles    = !(filters & QDir::Files);
    if (skipFiles && fi.isFile())
        // Basically we need a reason not to exclude this file otherwise we just eliminate it.
        return false;

    // filter permissions
    const bool filterPermissions = ((filters & QDir::PermissionMask)
                                    && (filters & QDir::PermissionMask) != QDir::PermissionMask);
    const bool doWritable = !filterPermissions || (filters & QDir::Writable);
    const bool doExecutable = !filterPermissions || (filters & QDir::Executable);
    const bool doReadable = !filterPermissions || (filters & QDir::Readable);
    if (filterPermissions
        && ((doReadable && !fi.isReadable())
            || (doWritable && !fi.isWritable())
            || (doExecutable && !fi.isExecutable()))) {
        return false;
    }

    return true;
}
开发者ID:Afreeca,项目名称:qt,代码行数:79,代码来源:qdiriterator.cpp

示例5: start

void DataInput::start()
{
    QNetworkRequest nr;
    QString url;
    //qDebug() << "DataInput:start:"<<type<<":"<<input->arg1();

    if( type == "ifttt" ) {
        // url = "http://api.thingm.com/blink1/eventsall/" + iftttKey;
        url = "http://feed.thingm.com/blink1/eventsall/" + iftttKey;
        //url = "http://localhost:3232/blink1/eventsall/" + iftttKey;
        nr.setUrl(QUrl(url));
        reply = networkManager->get(nr);
        connect(reply, SIGNAL(finished()), this, SLOT(onFinished()));
        connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError()));
    }
    else if( type == "url" ) { 
        url = input->arg1();
        //qDebug() << "datainput:start url: "<<url; 
        if(!url.startsWith("http://") && !url.startsWith("https://"))
            url="http://"+url;
        QUrl correctUrl(url);
        if(correctUrl.isValid()) {
            nr.setUrl(QUrl(url));
            reply = networkManager->get(nr);
            connect(reply, SIGNAL(finished()), this, SLOT(onFinished()));
            connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError()));
        }
        else {
            input->setArg2("Bad URL");
            input->setDate(-1);  // FIXME: don't like -1 here
            emit toDelete(this);
        }
    }
    else if( type == "file" ) { 
        QFileInfo fileInfo;
        fileInfo.setFile(input->arg1());
        if( !fileInfo.exists() ) {
            qDebug() << "datainput:start: no file";
            input->setArg2("Not Found");
            input->setDate(-1);
        }
        else { 
            int lastModTime = fileInfo.lastModified().toTime_t(); // why was cast to uint?
            if( lastModTime > input->date()) {
                qDebug() << "datainput:start: file newer";
                QFile f(input->arg1());
                if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
                    input->setArg2("Couldn't Open");
                    input->setDate(-1);  // FIXME: why -1? what does it mean?
                    emit toDelete(this);
                    return;
                }
                input->setDate( lastModTime); //fileInfo.lastModified().toTime_t());
                QString txt = "";
                QTextStream in(&f);
                txt.append(in.readAll());

                bool good = parsePatternOrColor( txt, type, lastModTime );
                if( !good ) { 
                    input->setArg2("Bad Parse");
                }
            } // last modified
            else { 
                //input->setArg2("Old File");  // FIXME: should do something to indicate older file
                //input->setDate(-1);
            }
        }
        emit toDelete(this);
    }
    else if( type == "script" ) { 
        //QString path = QStandardPaths::locate(QStandardPaths::DocumentsLocation, input->arg1());
        QFileInfo fileInfo;
        fileInfo.setFile( input->arg1() );
        if( !fileInfo.exists() ) {
            input->setArg2("Not Found");
            input->setDate(-1);
            emit toDelete(this);
        } 
        else if( !fileInfo.isExecutable() ) { 
            input->setArg2("Not Executable");
            input->setDate(-1);
            emit toDelete(this);
        }
        else { 
            // FIXME: should check new value compare to lastVal
            // (and FIXME: need to refactor to properly use lastVal for all monitor types)
            //if(fileInfo.lastModified().toTime_t() != (uint)input->date()){
            // no, don't do lastModTime check on exec file, jeez
            input->setDate(fileInfo.lastModified().toTime_t());
            process = new QProcess;
            connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(onProcessOutput()));
            connect(process, SIGNAL(readyReadStandardError()), this, SLOT(onError()));
            connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onError()));
            connect(process, SIGNAL(finished(int)), this, SLOT(onProcessFinished()));
            // start process running
            process->start( fileInfo.canonicalFilePath() );
        }
    }
开发者ID:dunk8888,项目名称:blink1,代码行数:98,代码来源:datainput.cpp

示例6: HandleImport

void IconView::HandleImport(void)
{
    QFileInfo path;
    QDir importdir;

    // Makes import directory samba/windows friendly (no colon)
    QString idirname = m_currDir + "/" +
        MythDate::current().toString("yyyy-MM-dd_hh-mm-ss");

    importdir.mkdir(idirname);
    importdir.setPath(idirname);

    for (QStringList::const_iterator it = m_paths.begin();
         it != m_paths.end(); ++it)
    {
        path.setFile(*it);
        if (path.isDir() && path.isReadable())
        {
            ImportFromDir(*it, importdir.absolutePath());
        }
        else if (path.isFile() && path.isExecutable())
        {
            if (m_allowImportScripts)
            {
                QString cmd = *it + " " + importdir.absolutePath();

                MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
                MythUIBusyDialog *busy =
                        new MythUIBusyDialog(tr("Importing images from camera. Please wait..."),
                                                popupStack,
                                                "importbusydialog");

                if (busy->Create())
                {
                    popupStack->AddScreen(busy, false);
                }
                else
                {
                    delete busy;
                    busy = NULL;
                }

                ImportThread *import = new ImportThread(cmd);
                import->start();

                while (!import->isFinished())
                {
                    usleep(500);
                    qApp->processEvents();
                }

                delete import;

                if (busy)
                    busy->Close();
            }
            else
            {
                ShowOkPopup(tr("Found an import script (%1) but running them has been disabled in the settings!")
                               .arg(*it));
                importdir.rmdir(importdir.absolutePath());
                return;
            }
        }
        else
        {
            LOG(VB_GENERAL, LOG_ERR, LOC +
                QString("Could not read or execute %1").arg(*it));

            ShowOkPopup(tr("Could not read or execute %1").arg(*it));
        }
    }

    importdir.setFilter(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot);
    importdir.refresh();
    if (importdir.count() == 0)
    {
        ShowOkPopup(tr("Nothing found to import"));
        importdir.rmdir(importdir.absolutePath());
        return;
    }
    else
        ShowOkPopup(tr("Found %1 images").arg(importdir.count()));

    LoadDirectory(m_currDir);
}
开发者ID:mhyon,项目名称:mythtv,代码行数:86,代码来源:iconview.cpp

示例7: getMacIcon

QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const
{
    QIcon retIcon;
    QString fileExtension = fi.suffix().toUpper();
    fileExtension.prepend(QLatin1String("."));

    const QString keyBase = QLatin1String("qt_") + fileExtension;

    QPixmap pixmap;
    if (fi.isFile() && !fi.isExecutable() && !fi.isSymLink()) {
        QPixmapCache::find(keyBase + QLatin1String("16"), pixmap);
    }

    if (!pixmap.isNull()) {
        retIcon.addPixmap(pixmap);
        if (QPixmapCache::find(keyBase + QLatin1String("32"), pixmap)) {
            retIcon.addPixmap(pixmap);
            if (QPixmapCache::find(keyBase + QLatin1String("64"), pixmap)) {
                retIcon.addPixmap(pixmap);
                if (QPixmapCache::find(keyBase + QLatin1String("128"), pixmap)) {
                    retIcon.addPixmap(pixmap);
                    return retIcon;
                }
            }
        }
    }


    FSRef macRef;
    OSStatus status = FSPathMakeRef(reinterpret_cast<const UInt8*>(fi.canonicalFilePath().toUtf8().constData()),
                                    &macRef, 0);
    if (status != noErr)
        return retIcon;
    FSCatalogInfo info;
    HFSUniStr255 macName;
    status = FSGetCatalogInfo(&macRef, kIconServicesCatalogInfoMask, &info, &macName, 0, 0);
    if (status != noErr)
        return retIcon;
    IconRef iconRef;
    SInt16 iconLabel;
    status = GetIconRefFromFileInfo(&macRef, macName.length, macName.unicode,
                                    kIconServicesCatalogInfoMask, &info, kIconServicesNormalUsageFlag,
                                    &iconRef, &iconLabel);
    if (status != noErr)
        return retIcon;
    qt_mac_constructQIconFromIconRef(iconRef, 0, &retIcon);
    ReleaseIconRef(iconRef);

    if (fi.isFile() && !fi.isExecutable() && !fi.isSymLink()) {
        pixmap = retIcon.pixmap(16);
        QPixmapCache::insert(keyBase + QLatin1String("16"), pixmap);
        pixmap = retIcon.pixmap(32);
        QPixmapCache::insert(keyBase + QLatin1String("32"), pixmap);
        pixmap = retIcon.pixmap(64);
        QPixmapCache::insert(keyBase + QLatin1String("64"), pixmap);
        pixmap = retIcon.pixmap(128);
        QPixmapCache::insert(keyBase + QLatin1String("128"), pixmap);
    }

    return retIcon;
}
开发者ID:diversys,项目名称:qt4,代码行数:61,代码来源:qfileiconprovider.cpp

示例8: fileInfoString

/*!
    returns a string containing the general information about the file \c name
    and some content specific information
    (number of columns and lines for ASCII, color-depth for images etc.).
 */
QString FileDataSource::fileInfoString(const QString &name){
	QString infoString;
	QFileInfo fileInfo;
	QString fileTypeString;
	QIODevice *file = new QFile(name);

	QString fileName;
    if (name.at(0) != QDir::separator()) {
        fileName = QDir::homePath() + QDir::separator() + name;
    } else {
        fileName = name;
	}

	if(file==0)
		file = new QFile(fileName);

	if (file->open(QIODevice::ReadOnly)){
		QStringList infoStrings;

		//general information about the file
		infoStrings << "<u><b>" + fileName + "</b></u><br>";
		fileInfo.setFile(fileName);

		infoStrings << i18n("Readable: %1", fileInfo.isReadable() ? i18n("yes") : i18n("no"));

		infoStrings << i18n("Writable: %1", fileInfo.isWritable() ? i18n("yes") : i18n("no"));

		infoStrings << i18n("Executable: %1", fileInfo.isExecutable() ? i18n("yes") : i18n("no"));

		infoStrings << i18n("Created: %1", fileInfo.created().toString());
		infoStrings << i18n("Last modified: %1", fileInfo.lastModified().toString());
		infoStrings << i18n("Last read: %1", fileInfo.lastRead().toString());
		infoStrings << i18n("Owner: %1", fileInfo.owner());
		infoStrings << i18n("Group: %1", fileInfo.group());
		infoStrings << i18n("Size: %1", i18np("%1 cByte", "%1 cBytes", fileInfo.size()));

#ifdef HAVE_FITS
        if (fileName.endsWith(QLatin1String(".fits"))) {
            FITSFilter* fitsFilter = new FITSFilter;

            infoStrings << i18n("Images: %1", QString::number(fitsFilter->imagesCount(fileName) ));
            infoStrings << i18n("Tables: %1", QString::number(fitsFilter->tablesCount(fileName) ));

            delete fitsFilter;
        }
#endif

		// file type and type specific information about the file
#ifdef Q_OS_LINUX
		QProcess *proc = new QProcess();
		QStringList args;
		args<<"-b"<<fileName;
		proc->start( "file", args);

		if(proc->waitForReadyRead(1000) == false){
			infoStrings << i18n("Could not open file %1 for reading.", fileName);
		}else{
			fileTypeString = proc->readLine();
			if( fileTypeString.contains(i18n("cannot open")) )
				fileTypeString="";
			else {
				fileTypeString.remove(fileTypeString.length()-1,1);	// remove '\n'
			}
		}
		infoStrings << i18n("File type: %1", fileTypeString);
#endif

		//TODO depending on the file type, generate additional information about the file:
		//Number of lines for ASCII, color-depth for images etc. Use the specific filters here.
		// port the old labplot1.6 code.
		if( fileTypeString.contains("ASCII")){
			infoStrings << "<br/>";
			infoStrings << i18n("Number of columns: %1", AsciiFilter::columnNumber(fileName));

			infoStrings << i18n("Number of lines: %1", AsciiFilter::lineNumber(fileName));
		}
		infoString += infoStrings.join("<br/>");
	} else{
		infoString += i18n("Could not open file %1 for reading.", fileName);
	}

	return infoString;
}
开发者ID:gerlachs,项目名称:labplot,代码行数:88,代码来源:FileDataSource.cpp

示例9: readDirEntries

bool QDir::readDirEntries( const QString &nameFilter,
                           int filterSpec, int sortSpec )
{
    int i;
    if ( !fList ) {
        fList  = new QStringList;
        CHECK_PTR( fList );
        fiList = new QFileInfoList;
        CHECK_PTR( fiList );
        fiList->setAutoDelete( TRUE );
    } else {
        fList->clear();
        fiList->clear();
    }

    QStringList filters = qt_makeFilterList( nameFilter );

    bool doDirs	    = (filterSpec & Dirs)	!= 0;
    bool doFiles    = (filterSpec & Files)	!= 0;
    bool noSymLinks = (filterSpec & NoSymLinks) != 0;
    bool doReadable = (filterSpec & Readable)	!= 0;
    bool doWritable = (filterSpec & Writable)	!= 0;
    bool doExecable = (filterSpec & Executable) != 0;
    bool doHidden   = (filterSpec & Hidden)	!= 0;

#if defined(_OS_OS2EMX_)
    //QRegExp   wc( nameFilter, FALSE, TRUE );	// wild card, case insensitive
#else
    //QRegExp   wc( nameFilter, TRUE, TRUE );	// wild card, case sensitive
#endif
    QFileInfo fi;
    DIR	     *dir;
    dirent   *file;

    dir = opendir( QFile::encodeName(dPath) );
    if ( !dir ) {
#if defined(CHECK_NULL)
        qWarning( "QDir::readDirEntries: Cannot read the directory: %s",
                  QFile::encodeName(dPath).data() );
#endif
        return FALSE;
    }

    while ( (file = readdir(dir)) ) {
        QString fn = QFile::decodeName(file->d_name);
        fi.setFile( *this, fn );
        if ( !match( filters, fn ) && !(allDirs && fi.isDir()) )
            continue;
        if  ( (doDirs && fi.isDir()) || (doFiles && fi.isFile()) ) {
            if ( noSymLinks && fi.isSymLink() )
                continue;
            if ( (filterSpec & RWEMask) != 0 )
                if ( (doReadable && !fi.isReadable()) ||
                        (doWritable && !fi.isWritable()) ||
                        (doExecable && !fi.isExecutable()) )
                    continue;
            if ( !doHidden && fn[0] == '.' &&
                    fn != QString::fromLatin1(".")
                    && fn != QString::fromLatin1("..") )
                continue;
            fiList->append( new QFileInfo( fi ) );
        }
    }
    if ( closedir(dir) != 0 ) {
#if defined(CHECK_NULL)
        qWarning( "QDir::readDirEntries: Cannot close the directory: %s",
                  dPath.local8Bit().data() );
#endif
    }

    // Sort...
    if(fiList->count()) {
        QDirSortItem* si= new QDirSortItem[fiList->count()];
        QFileInfo* itm;
        i=0;
        for (itm = fiList->first(); itm; itm = fiList->next())
            si[i++].item = itm;
        qt_cmp_si_sortSpec = sortSpec;
        qsort( si, i, sizeof(si[0]), qt_cmp_si );
        // put them back in the list
        fiList->setAutoDelete( FALSE );
        fiList->clear();
        int j;
        for ( j=0; j<i; j++ ) {
            fiList->append( si[j].item );
            fList->append( si[j].item->fileName() );
        }
        delete [] si;
        fiList->setAutoDelete( TRUE );
    }

    if ( filterSpec == (FilterSpec)filtS && sortSpec == (SortSpec)sortS &&
            nameFilter == nameFilt )
        dirty = FALSE;
    else
        dirty = TRUE;
    return TRUE;
}
开发者ID:kthxbyte,项目名称:QT2-Linaro,代码行数:98,代码来源:qdir_unix.cpp

示例10: startMencoder

void SplitVideo::startMencoder()
{
    QTime t;

    int startTime = t.secsTo( ui->teFrom->time() );
    int endTime = t.secsTo( ui->teTo->time() );

    QFileInfo fi;

    QString inputFile = m_core->mdat.filename;
    QString outputFile;

    fi.setFile( m_core->mdat.filename );

    if ( m_core->mdat.type == TYPE_DVD || m_core->mdat.type == TYPE_VCD )
    {
        outputFile = QDesktopServices::storageLocation( QDesktopServices::MoviesLocation ) + tr( "/Movie_" ) +
                QString::number( startTime ) + "_" +
                QString::number( endTime ) + ".avi";
    }
    else
    {
        outputFile = fi.absolutePath() + "/" + fi.baseName() + "_" +
                QString::number( startTime ) + "_" +
                QString::number( endTime ) + "." + fi.suffix();
    }
    outputFile = getNewFileName( outputFile );

    if ( !canWriteTo( outputFile ) )
    {
        qDebug("SplitVideo::startMencoder():   cannot trim video ( maybe your disk is mounted read-only? )");
        outputFile = QDesktopServices::storageLocation( QDesktopServices::MoviesLocation ) + "/" +
                fi.baseName() + "_" +
                QString::number( startTime ) + "_" +
                QString::number( endTime ) + "." + fi.suffix();
        outputFile = getNewFileName( outputFile );
    }

    qDebug("SplitVideo::startMencoder():   outputFile is %s", outputFile.toLocal8Bit().data() );

    // we cannot splitting if time is not valid
    if ( !checkTime( startTime, endTime ) )
        return;

    if ( !checkDiskSpace( outputFile, endTime - startTime, m_core->mdat.duration ) )
    {
        ui->labelError->setText( tr( "Cannot trim video ( maybe you have no enough disk space? )" ) );
        return;
    }

    m_isStopMencoder = false;
    m_error = -1;
    m_startTime = startTime;
    m_endTime = endTime;
    m_inputFile = inputFile;
    m_outputFile = outputFile;

    // Use absolute path, otherwise after changing to the screenshot directory
    // the mencoder path might not be found if it's a relative path
    // (seems to be necessary only for linux)
    QString mencoder_bin = pref->mencoder_bin;
    fi.setFile( mencoder_bin );
    if ( fi.exists() && fi.isExecutable() && !fi.isDir() )
    {
        mencoder_bin = fi.absoluteFilePath();
    }

    m_proc->clearArguments();
    m_proc->addArgument( mencoder_bin );
    m_proc->addArgument( m_inputFile );
    m_proc->addArgument( "-oac" );
    if ( m_isCutError )
        m_proc->addArgument( "pcm" );
    else
        m_proc->addArgument( "copy" );
    m_proc->addArgument( "-ovc" );
    m_proc->addArgument( "copy" );
    m_proc->addArgument( "-ss" );
    m_proc->addArgument( QString::number( m_startTime ) );
    m_proc->addArgument( "-endpos" );
    m_proc->addArgument( QString::number( m_endTime - m_startTime ) );
    m_proc->addArgument( "-o" );
    m_proc->addArgument( m_outputFile );

    QString commandline = m_proc->arguments().join(" ");
    qDebug("SplitVideo::startMencoder: command: '%s'", commandline.toUtf8().data());

    if ( !m_proc->start() ) {
        // error handling
        qWarning("SplitVideo::startMencoder: mencoder process didn't start");
    }

    updateControls();
}
开发者ID:AlexRu,项目名称:rosa-media-player,代码行数:94,代码来源:splitvideo.cpp

示例11: dir

/** Creates the \c ls command result 
  *
  * It creates it in the packetData string.
  *
  */
void RainbruRPG::Network::Ftp::FtpTransfer::lsResult(){
  LOGI("LIST command result :");
  packetData="";
  unsigned int childs=1;

  QDir dir(currentDirectory );
  dir.setFilter(QDir::Dirs| QDir::Files| QDir::NoSymLinks);
  dir.setSorting(QDir::Name);

  QFileInfoList list = dir.entryInfoList();

  LOGCATS("Sending ");
  LOGCATI(list.size());
  LOGCATS(" files.");
  LOGCAT();

  for (int i = 0; i < list.size(); ++i) {
    QFileInfo fileInfo = list.at(i);

    // ====== User permissions
    // Diretory ?
    if (fileInfo.isDir()){
      packetData+="d";

      QDir dir2(fileInfo.absoluteFilePath());
      childs=dir2.count();

    }
    else{
      packetData+="-";
      childs=1;
    }

    packetData+=filePermissions(fileInfo.isReadable(),fileInfo.isWritable(),
				fileInfo.isExecutable());

    packetData+=filePermissions(fileInfo.permission(QFile::ReadGroup),
				fileInfo.permission(QFile::WriteGroup),
				fileInfo.permission(QFile::ExeGroup));

    packetData+=filePermissions(fileInfo.permission(QFile::ReadOther),
				fileInfo.permission(QFile::WriteOther),
				fileInfo.permission(QFile::ExeOther));

    // Child number
    QString sChild;
    sChild.setNum(childs);
    sChild=sChild.rightJustified(5);
    packetData+=sChild;

    // Owner and group names
    packetData+=' ';
    QString sOwner=fileInfo.owner();
    sOwner=sOwner.leftJustified(9);
    packetData+=sOwner;
    QString sGroup=fileInfo.group();
    sGroup=sGroup.leftJustified(9);
    packetData+=sGroup;

    // File size
    qint64 size=fileInfo.size();

    QString sSize=fileSizeToString(size);
    sSize=sSize.rightJustified(8);
    packetData+=sSize;

    // Last modified time
    packetData+=" ";
    QDateTime dt=fileInfo.lastModified();
    packetData+=dt.toString("yyyy-MM-dd hh:mm");

    // File name and EOL
    packetData+=" ";
    packetData+=fileInfo.fileName();
    packetData+="\n";
  }
  LOGI("PacketData done. LIST result can be sent");
  int i=  packetData.size();
  LOGCATS("PacketData lenght :");
  LOGCATI(i);
  LOGCAT();
}
开发者ID:dreamsxin,项目名称:rainbrurpg,代码行数:87,代码来源:ftptransfer.cpp

示例12: enter

//*******************************************************************
// enter                                                PRIVATE slot
//*******************************************************************
void QBtView::enter( const QModelIndex& in_index )
{
   const QString fname = model_->file_full_name( in_index ); // tak ma byc ze wzgledu na ..
   const QFileInfo fi( model_->file_path( in_index ) );
   const QString fpath = fi.absoluteFilePath();
   const QString dir = fi.absolutePath();
   
   if( fi.isDir() ) {                                 // KATALOG
      if( fi.isExecutable() && fi.isReadable() ) {
         if( ".." == fname ) {
            one_level_up();
         }
         else {
            initial_file_stack_.push( fi.fileName() );
            requests_.push( GOTO_TOP );
            model_->update( fpath );
         }
      }
      return;
   }
   else {                                             // PLIK (NIE KATALOG)
      if( fi.isExecutable() ) {                       // wykonywalne
#if !_WIN32
         if( QBtShared::is_binary_file( fpath ) ) {   // program
            static const QString PRG = "%1 &";
            system( PRG.arg( fpath ).toLocal8Bit() );
         }
         else {                                       // skrypt
            static const QString GNOME = "gnome-terminal --working-directory=%1 --command=%2";
            static const QString KDE = "konsole --workdir %1 -e %2";
            const QString cmd = QBtShared::is_gnome() ? GNOME : KDE;
            system( cmd.arg( dir ).arg( fpath ).toLocal8Bit() );
         }
#else
          ShellExecuteA(NULL, "open", fpath.toLocal8Bit(), NULL, dir.toLocal8Bit(), SW_SHOWNORMAL);
#endif
      }
      else {                                          // ZWYKLY PLIK
         const QString ext = fi.suffix().toLower();
         QString prg = QString();
         QString par = QString();
         if( is_ext_declared( ext, prg, par  ) ) {
            par.replace( "$dir", fi.absolutePath() );
            par.replace( "$name", fi.fileName() );
            par.replace( "$path", fi.absoluteFilePath() );
            const QString cmd = "\"%1\" \"%2\" &";
            system( cmd.arg( prg ).arg( par ).toLocal8Bit() );
         }
         else {
#if !_WIN32
            static const QString GNOME = "gnome-open %1";
            static const QString KDE   = "kfmclient exec %1";
            const QString cmd = QBtShared::is_gnome() ? GNOME : KDE;
            system( cmd.arg( fpath ).toLocal8Bit() );
#else
             ShellExecuteA(NULL, "open", fpath.toLocal8Bit(), NULL, dir.toLocal8Bit(), SW_SHOWNORMAL);
#endif
         }
      }
   }
}
开发者ID:NasuTek,项目名称:NasuTek-Commander,代码行数:64,代码来源:QBtView.cpp


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