本文整理汇总了C++中QFileInfo::lastModified方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfo::lastModified方法的具体用法?C++ QFileInfo::lastModified怎么用?C++ QFileInfo::lastModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileInfo
的用法示例。
在下文中一共展示了QFileInfo::lastModified方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void ConfigureStep::run(QFutureInterface<bool>& interface)
{
BuildConfiguration *bc = buildConfiguration();
//Check whether we need to run configure
const QString projectDir(bc->target()->project()->projectDirectory().toString());
const QFileInfo configureInfo(projectDir + QLatin1String("/configure"));
const QFileInfo configStatusInfo(bc->buildDirectory().toString() + QLatin1String("/config.status"));
if (!configStatusInfo.exists()
|| configStatusInfo.lastModified() < configureInfo.lastModified()) {
m_runConfigure = true;
}
if (!m_runConfigure) {
emit addOutput(tr("Configuration unchanged, skipping configure step."), BuildStep::MessageOutput);
interface.reportResult(true);
emit finished();
return;
}
m_runConfigure = false;
AbstractProcessStep::run(interface);
}
示例2: GetQtHelpCollectionFile
QString ExampleAppPluginActivator::GetQtHelpCollectionFile() const
{
if (!helpCollectionFile.isEmpty())
{
return helpCollectionFile;
}
QString collectionFilename = "ExampleAppQtHelpCollection.qhc";
QFileInfo collectionFileInfo = context->getDataFile(collectionFilename);
QFileInfo pluginFileInfo = QFileInfo(QUrl(context->getPlugin()->getLocation()).toLocalFile());
if (!collectionFileInfo.exists() ||
pluginFileInfo.lastModified() > collectionFileInfo.lastModified())
{
// extract the qhc file from the plug-in
QByteArray content = context->getPlugin()->getResource(collectionFilename);
if (content.isEmpty())
{
BERRY_WARN << "Could not get plug-in resource: " << collectionFilename.toStdString();
}
else
{
QFile file(collectionFileInfo.absoluteFilePath());
file.open(QIODevice::WriteOnly);
file.write(content);
file.close();
}
}
if (QFile::exists(collectionFileInfo.absoluteFilePath()))
{
helpCollectionFile = collectionFileInfo.absoluteFilePath();
}
return helpCollectionFile;
}
示例3: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// QDir * _dir=new QDir();
// // _dir->mkdir("tmp//audio");
// _dir->mkpath("tmp/audio");
/**/
QDir directory(this->getPath());
qDebug()<<"getIOSFilePath,m :"<<this->getPath();
QFileInfoList fileInfoList;
if (this->hiddenFiles)
{
fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
}
else
{
fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
}
QFileInfo fileInfo;
File file;
QList<File> *fileList = new QList<File>;
QFileIconProvider *provider = new QFileIconProvider;
while (!fileInfoList.isEmpty())
{
if (this->procesEvents)
qApp->processEvents();
fileInfo = fileInfoList.takeFirst();
file.fileIcon = provider->icon(fileInfo);
file.fileName = fileInfo.fileName();
qDebug()<<"IOSFileName:"<<file.fileName;
file.fileSize = QString::number(fileInfo.size());
file.fileDate = fileInfo.lastModified().toString("MMM dd yyyy");
file.filePath = fileInfo.absoluteFilePath();
file.filePermissions = "";
file.fileOwner = fileInfo.owner();
if (fileInfo.isDir())
file.fileType = "dir";
else
file.fileType = "file";
fileList->append(file);
}
delete provider;
return fileList;
return a.exec();
}
示例4: info
TEST(codegen, DISABLED_collectionWithFileAndReference)
{
soft::File file;
soft::Reference reference;
QFileInfo info ("/tmp/thermo-edited.dat");
QFile data(info.absoluteFilePath());
if (!data.open(QIODevice::ReadOnly)) {
FAIL();
}
reference.uri = "file://" + info.absoluteFilePath().toStdString();
reference.created = info.created().toString("dd-mm-yyyy").toStdString();
reference.owner = info.owner().toStdString();
reference.lastModified = info.lastModified().toString("dd-mm-yyyy").toStdString();
reference.sha1 = toStdBlob(sha1(info.absoluteFilePath()));
file.filename = info.fileName().toStdString();
file.suffix = info.suffix().toStdString();
file.size = info.size();
auto buffer = data.readAll();
file.data = toStdBlob(buffer);
data.close();
soft::Collection collection;
collection.setName("thermo");
collection.setVersion("1.0");
collection.attachEntity("file1", &file);
collection.attachEntity("ref", &reference);
collection.connect("file1", "has-info", "ref");
soft::Storage storage("mongo2", "mongodb://localhost", "db=codegentest;coll=collectiontest3");
storage.save(&collection);
soft::Collection copyCollection(collection.id());
soft::Reference refCopy;
copyCollection.attachEntity("myref", &refCopy);
storage.load(©Collection);
std::string name, version, ns, id;
copyCollection.findEntity("ref", name, version, ns, id);
soft::Reference refCopy2(id);
storage.load(&refCopy2);
ASSERT_EQ(refCopy.sha1, reference.sha1);
ASSERT_EQ(refCopy2.sha1, reference.sha1);
ASSERT_EQ(refCopy.uri, reference.uri);
ASSERT_EQ(refCopy2.uri, reference.uri);
ASSERT_EQ(refCopy.created, reference.created);
ASSERT_EQ(refCopy2.created, reference.created);
}
示例5:
/**
* fast hash created from canonical path of file,
* stringified timestamp, and stringified size of file.
*/
std::string
FileAnnouncer::fileStatHash(const QFileInfo& fileInfo)
{
QString str;
irg::SHA1Hash hash;
hash.init();
str = fileInfo.absoluteFilePath();
hash.update((const unsigned char*)qPrintable(str), str.length());
str = fileInfo.lastModified().toString("yy.MMM.dd-hh:mm:ss.zzz");
hash.update((const unsigned char*)qPrintable(str), str.length());
str.setNum(fileInfo.size());
hash.update((const unsigned char*)qPrintable(str), str.length());
return hash.hexString(hash.final());
}
示例6: fileHandler
bool ImgDirSink::fileHandler(const QFileInfo &finfo)
{
const QString fname = finfo.fileName();
if (knownImageExtension(fname))
{
imgfiles.append(finfo.absoluteFilePath());
timestamps.insert(finfo.absoluteFilePath(), FileStatus(finfo.lastModified()));
return true;
}
if (fname.endsWith(".nfo", Qt::CaseInsensitive) || fname == "file_id.diz")
{
txtfiles.append(finfo.absoluteFilePath());
return true;
}
otherfiles.append(finfo.absoluteFilePath());
return false;
}
示例7: updateTableWidget
void OpenSavedGameDialog::updateTableWidget(const QString &subdir) {
if (!savedir) {
// cannot do anything
return;
}
// go to the given subdirectory
if (!savedir->cd(subdir)) {
QMessageBox::critical(this, tr("Error"), tr("Unable to load the save-files!"));
return;
}
// clear our table and current save game
ui->tableWidget->clearContents();
m_saveDirectory = QString("");
m_saveName = QString("");
// get all the files in the subdirectory and cd back out
QFileInfoList list = savedir->entryInfoList(QDir::AllDirs, QDir::Time);
int row = 0;
for (QFileInfoList::iterator it = list.begin(); it != list.end(); ++it) {
// grab everything after the first dash
QFileInfo file = (*it);
QString name = file.baseName().section("-", 1);
// we don't care about empty folders or the quick/auto-save folders
if (name.isEmpty() || name == strQuickSave || name == strAutoSave) {
continue;
}
// add the option to the table
ui->tableWidget->insertRow(row);
ui->tableWidget->setItem(row, 0, new QTableWidgetItem(name));
ui->tableWidget->setItem(row, 1, new QTableWidgetItem(file.lastModified().toString()));
ui->tableWidget->setItem(row, 2, new QTableWidgetItem(file.canonicalFilePath()));
// go to the next row
++row;
}
// show the table if we have any rows
ui->tableWidget->setEnabled((row > 0));
// jump back up
savedir->cdUp();
}
示例8: save
void VBoxVMLogViewer::save()
{
/* Prepare "save as" dialog */
QFileInfo fileInfo (mLogFiles.at(mLogList->currentIndex()).first);
QDateTime dtInfo = fileInfo.lastModified();
QString dtString = dtInfo.toString ("yyyy-MM-dd-hh-mm-ss");
QString defaultFileName = QString ("%1-%2.log")
.arg (mMachine.GetName()).arg (dtString);
QString defaultFullName = QDir::toNativeSeparators (
QDir::home().absolutePath() + "/" + defaultFileName);
QString newFileName = QFileDialog::getSaveFileName (this,
tr ("Save VirtualBox Log As"), defaultFullName);
/* Copy log into the file */
if (!newFileName.isEmpty())
QFile::copy(mMachine.QueryLogFilename(mLogList->currentIndex()), newFileName);
}
示例9: arrangeBy
void Desk::arrangeBy (int type)
{
myPtrList<File> todo;
int order, steps = 0;
// fill in the date & field
File *f;
/* FIXME: this sorts by the position of the top left of the object, which is
not the same as the top left of the image */
foreach (f, _files)
{
QFileInfo fi (f->pathname ());
f->setTime (fi.lastModified ());
todo.append (f);
}
示例10: deleteOldFiles
void SpaceChecker::deleteOldFiles()
{
// QDir videoDir("/sdcard/DCIM/DashCam/Video");
QDir videoDir;//("/Users/ratmandu/Pictures");
videoDir.setPath("/Users/ratmandu");
if (videoDir.count() > 1) {
// delete oldest file
videoDir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
videoDir.setSorting(QDir::Time | QDir::Reversed);
QFileInfoList list = videoDir.entryInfoList();
for (int i = 0; i < list.size(); i++) {
QFileInfo fileinfo = list.at(i);
qDebug() << fileinfo.absoluteFilePath() << fileinfo.size() << fileinfo.lastModified();
}
}
}
示例11: display
void LoacalFileServer::display(QString* currentPath)
{
//QString currentPath = root;
this->setWindowTitle("LocalFileServer : "+(*currentPath));
QDir rootDir(*currentPath);
QList<QTreeWidgetItem *> itemList;
QStringList tmplist;
tmplist << "*";
QFileInfoList list = rootDir.entryInfoList(tmplist);
for(unsigned int i = 0;i<list.count();i++)
{
QFileInfo tmpFileInfo = list.at(i);
QTreeWidgetItem *item = new QTreeWidgetItem;
if(tmpFileInfo.fileName() == "." || tmpFileInfo.fileName() == "..")
continue;
item->setText(0,tmpFileInfo.fileName());
if(tmpFileInfo.isDir())
{
item->setText(1,QString(""));
}
else
{
item->setText(1,QString::number(tmpFileInfo.size()));
}
item->setText(2,tmpFileInfo.created().toString("MMM dd yyyy"));
item->setText(3,tmpFileInfo.lastModified().toString("MMM dd yyyy"));
QPixmap pixmap(tmpFileInfo.isDir()?"./dir.png":"./file.png");
item->setIcon(0,pixmap);
itemList.push_back(item);
//the path is whether the directory
isDirectory[tmpFileInfo.fileName()] = tmpFileInfo.isDir();
}
fileWidget->addTopLevelItems(itemList);
}
示例12: autoload
void commutil::autoload(QString db_type, QString data_dir, QString subdir){
QDir dir(Config::single()->mp[data_dir]);
dir.setFilter(QDir::Dirs);
QFileInfoList list = dir.entryInfoList();
int total = list.count();
QDateTime lastdate;
QFile f(Config::single()->mp[data_dir] + "/modify.txt");
if(!f.open(QIODevice::ReadOnly)){
QLOG_ERROR() << "open:" << Config::single()->mp[data_dir] + "/modify.txt" << " error";
return;
}
QDataStream stream(&f);
stream >> lastdate;
f.close();
//prepare database
for(int i = 0; i < total; ++i){
QFileInfo it = list.at(i);
auto filename = it.fileName();
if(filename == "." || filename == ".."){
continue;
}
auto date = it.lastModified();
//may debug
if(date > lastdate){
auto patient_name = ImageMatrix::get_patientname((Config::single()->mp[data_dir] + "/" + filename + "/" + Config::single()->mp[subdir]).toStdString());
//bug in dcmtk lib
int bug_pos = patient_name.find(":bah:");
if(bug_pos != -1){
patient_name = patient_name.substr(0,bug_pos);
}
auto patient_id = ImageMatrix::get_patientid((Config::single()->mp[data_dir] + "/" + filename + "/" + Config::single()->mp[subdir]).toStdString());
DataCon::getinstance(db_type.toStdString()) -> add(patient_id.c_str(), patient_name.c_str(),date.toString(), date.toString());
}
}
//update check time
lastdate = QDateTime::currentDateTime();
if(!f.open(QIODevice::WriteOnly)){
QLOG_ERROR() << "open:" << Config::single()->mp[data_dir] + "/modify.txt" << " error";
return;
}
stream.setDevice(&f);
stream << lastdate;
f.close();
}
示例13: ListFilesInDirectory
void ListFilesInDirectory(QDir dir, bool Hash)
{
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setSorting(QDir::Size | QDir::Reversed);
QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i)
{
QFileInfo fileInfo = list.at(i);
if (fileInfo.isFile())
{
QDateTime date = fileInfo.lastModified();
QString lastModified = date.toString();
std::cout << qPrintable(QString("%1 lastModified=%2 ").arg(fileInfo.absoluteFilePath()).arg(lastModified)) << std::endl;
if (Hash) GetFileMd5hash(fileInfo.absoluteFilePath());
}
}
}
示例14: saveResources
void FlashcardsDeck::saveResources (QString deckFileName, bool verbose)
{
if (resourceAbsoluteToDeckPathMap.empty()) return;
verify (!(mediaDirectoryName.isEmpty() || mediaDirectoryName.isNull()), "Media directory not specified or empty.");
QDir createMediaIn = QFileInfo (deckFileName).dir();
verify (createMediaIn.exists(), "Failed to access parent directory of '" + deckFileName + "'.");
verify (createMediaIn.mkpath (mediaDirectoryName), "Failed to create media subdirectory '" + mediaDirectoryName + "' for deck file '" + deckFileName +"'.");
for (std::pair <QString, QString> absoluteToRelative : resourceAbsoluteToDeckPathMap.toStdMap())
{
QString destination = createMediaIn.absolutePath() + "/" + mediaDirectoryName + "/" + absoluteToRelative.second;
QFileInfo sourceFile (absoluteToRelative.first), destinationFile (destination);
if (destinationFile.exists() && sourceFile.lastModified() == destinationFile.lastModified() && sourceFile.size() == destinationFile.size())
{
if (verbose)
qstderr << "File '" << absoluteToRelative.first << "' has same last accessed time as '" << destination << "': skipping." << endl;
continue;
}
//bool copied = QFile::copy (absoluteToRelative.first, destination);
// Copy preserving timestamps via 'cp'
bool copied = false;
#ifdef Q_OS_LINUX
QProcess process;
process.start ("cp", QStringList() << sourceFile.absoluteFilePath() << destinationFile.absoluteFilePath() << "--preserve=timestamps");
verify (process.waitForFinished(), "Failed to wait for 'cp' to finish.");
copied = process.exitCode() == 0;
#else
#error This platform is not supported. Add more cases or test if the existing code works.
#endif
verify (copied, "Failed to copy '" + absoluteToRelative.first + "' to '" + destination + "'.");
if (verbose)
qstderr << "Copied resource '" + absoluteToRelative.first + "' to '" + destination + "'." << endl;
}
if (verbose)
qstderr << resourceAbsoluteToDeckPathMap.size() << " resources saved." << endl;
}
示例15: operationListChildren
void QLocalFs::operationListChildren( QNetworkOperation *op )
{
#ifdef QLOCALFS_DEBUG
qDebug( "QLocalFs: operationListChildren" );
#endif
op->setState( StInProgress );
dir = QDir( url()->path() );
dir.setNameFilter( url()->nameFilter() );
dir.setMatchAllDirs( TRUE );
if ( !dir.isReadable() ) {
QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
op->setState( StFailed );
op->setProtocolDetail( msg );
op->setErrorCode( (int)ErrListChildren );
emit finished( op );
return;
}
const QFileInfoList *filist = dir.entryInfoList( QDir::All | QDir::Hidden | QDir::System );
if ( !filist ) {
QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
op->setState( StFailed );
op->setProtocolDetail( msg );
op->setErrorCode( (int)ErrListChildren );
emit finished( op );
return;
}
emit start( op );
QFileInfoListIterator it( *filist );
QFileInfo *fi;
QValueList<QUrlInfo> infos;
while ( ( fi = it.current() ) != 0 ) {
++it;
infos << QUrlInfo( fi->fileName(), convertPermissions(fi), fi->owner(), fi->group(),
fi->size(), fi->lastModified(), fi->lastRead(), fi->isDir(), fi->isFile(),
fi->isSymLink(), fi->isWritable(), fi->isReadable(), fi->isExecutable() );
}
emit newChildren( infos, op );
op->setState( StDone );
emit finished( op );
}