void JobTest::copyLocalFile(const QString &src, const QString &dest) { KURL u; u.setPath(src); KURL d; d.setPath(dest); // copy the file with file_copy bool ok = KIO::NetAccess::file_copy(u, d); assert(ok); assert(QFile::exists(dest)); assert(QFile::exists(src)); // still there { // check that the timestamp is the same (#24443) // Note: this only works because of copy() in kio_file. // The datapump solution ignores mtime, the app has to call FileCopyJob::setModificationTime() QFileInfo srcInfo(src); QFileInfo destInfo(dest); assert(srcInfo.lastModified() == destInfo.lastModified()); } // cleanup and retry with KIO::copy() QFile::remove(dest); ok = KIO::NetAccess::dircopy(u, d, 0); assert(ok); assert(QFile::exists(dest)); assert(QFile::exists(src)); // still there { // check that the timestamp is the same (#24443) QFileInfo srcInfo(src); QFileInfo destInfo(dest); assert(srcInfo.lastModified() == destInfo.lastModified()); } }
void JobTest::copyLocalDirectory(const QString &src, const QString &_dest, int flags) { assert(QFileInfo(src).isDir()); assert(QFileInfo(src + "/testfile").isFile()); KURL u; u.setPath(src); QString dest(_dest); KURL d; d.setPath(dest); if(flags & AlreadyExists) assert(QFile::exists(dest)); else assert(!QFile::exists(dest)); bool ok = KIO::NetAccess::dircopy(u, d, 0); assert(ok); if(flags & AlreadyExists) { dest += "/" + u.fileName(); // kdDebug() << "Expecting dest=" << dest << endl; } assert(QFile::exists(dest)); assert(QFileInfo(dest).isDir()); assert(QFileInfo(dest + "/testfile").isFile()); assert(QFile::exists(src)); // still there { // check that the timestamp is the same (#24443) QFileInfo srcInfo(src); QFileInfo destInfo(dest); assert(srcInfo.lastModified() == destInfo.lastModified()); } }
inline bool PhaseMgr::CheckDefinition(PhaseDefinition const* phaseDefinition) { ConditionList const* conditions = sConditionMgr->GetConditionsForPhaseDefinition(phaseDefinition->zoneId, phaseDefinition->entry); if (!conditions) return true; ConditionSourceInfo srcInfo(player); return sConditionMgr->IsObjectMeetToConditions(srcInfo, *conditions); }
void JobTest::copyFileToSystem(bool resolve_local_urls) { kdDebug() << k_funcinfo << resolve_local_urls << endl; extern KIO_EXPORT bool kio_resolve_local_urls; kio_resolve_local_urls = resolve_local_urls; const QString src = homeTmpDir() + "fileFromHome"; createTestFile(src); KURL u; u.setPath(src); KURL d = systemTmpDir(); d.addPath("fileFromHome_copied"); kdDebug() << "copying " << u << " to " << d << endl; // copy the file with file_copy KIO::FileCopyJob *job = KIO::file_copy(u, d); connect(job, SIGNAL(mimetype(KIO::Job *, const QString &)), this, SLOT(slotMimetype(KIO::Job *, const QString &))); bool ok = KIO::NetAccess::synchronousRun(job, 0); assert(ok); QString dest = realSystemPath() + "fileFromHome_copied"; assert(QFile::exists(dest)); assert(QFile::exists(src)); // still there { // do NOT check that the timestamp is the same. // It can't work with file_copy when it uses the datapump, // unless we use setModificationTime in the app code. } // Check mimetype kdDebug() << m_mimetype << endl; // There's no mimemagic determination in kio_file in kde3. Fixing this for kde4... assert(m_mimetype == "application/octet-stream"); // assert( m_mimetype == "text/plain" ); // cleanup and retry with KIO::copy() QFile::remove(dest); ok = KIO::NetAccess::dircopy(u, d, 0); assert(ok); assert(QFile::exists(dest)); assert(QFile::exists(src)); // still there { // check that the timestamp is the same (#79937) QFileInfo srcInfo(src); QFileInfo destInfo(dest); assert(srcInfo.lastModified() == destInfo.lastModified()); } // restore normal behavior kio_resolve_local_urls = true; }
RDOValue RDOFunAlgorithmicCalc::doCalc(const LPRDORuntime& pRuntime) { RDOCalcList::const_iterator actionIt = m_actionList.begin(); for (const auto& condition: m_conditionList) { if (condition->calcValue(pRuntime).getAsBool()) { return (*actionIt)->calcValue(pRuntime); } ++actionIt; } // До сюда дело дойти не должно, т.к. последний conditions должен быть значением по молчанию pRuntime->error().push("Внутренняя ошибка, RDOFunAlgorithmicCalc", srcInfo()); return RDOValue(); }
bool Util::copyDir(const QString &srcPath, const QString &dstPath, bool overwrite) { QDir parentDstDir(QFileInfo(dstPath).path()); parentDstDir.mkdir(QFileInfo(dstPath).fileName()); QFileInfo srcInfo(srcPath); if (srcInfo.isFile()) { QString dstItemPath = dstPath + "/" + srcInfo.fileName(); if (QFile::exists(dstItemPath) && overwrite) QFile::remove(dstItemPath); return QFile::copy(srcPath, dstItemPath); } QDir srcDir(srcPath); foreach(const QFileInfo &info, srcDir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { QString srcItemPath = srcPath + "/" + info.fileName(); QString dstItemPath = dstPath + "/" + info.fileName(); if (info.isDir()) { if (!copyDir(srcItemPath, dstItemPath, overwrite)) { return false; } } else if (info.isFile()) { if (QFile::exists(dstItemPath) && overwrite) QFile::remove(dstItemPath); if (!QFile::copy(srcItemPath, dstItemPath)) { return false; } } } return true; }
void RenameImagesWidget::slotNext() { QTreeWidgetItem* it = ui->m_listView->selectedItems().first(); if (!it) { slotAbort(); return; } BatchProcessImagesItem* item = static_cast<BatchProcessImagesItem*>(it); KUrl src; src.setPath(item->pathSrc()); KUrl dst = src.upUrl(); dst.addPath(item->text(2)); bool skip = false; bool overwrite = false; if (!m_overwriteAll) { KDE_struct_stat info; while (KDE_stat(QFile::encodeName(dst.toLocalFile()), &info) == 0) { if (m_autoSkip) { skip = true; break; } QPointer<KIO::RenameDialog> dlg = new KIO::RenameDialog(this, i18n("Rename File"), src.path(), dst.path(), KIO::RenameDialog_Mode(KIO::M_MULTI | KIO::M_OVERWRITE | KIO::M_SKIP)); int result = dlg->exec(); dst = dlg->newDestUrl(); delete dlg; switch (result) { case KIO::R_CANCEL: { slotAbort(); return; } case KIO::R_SKIP: { skip = true; break; } case KIO::R_AUTO_SKIP: { m_autoSkip = true; skip = true; break; } case KIO::R_OVERWRITE: { overwrite = true; break; } case KIO::R_OVERWRITE_ALL: { m_overwriteAll = true; overwrite = true; break; } default: break; } if (skip || overwrite) break; } } if (skip) { item->changeResult(i18nc("batch process result", "Skipped")); } else { // Get the src info KIPIPlugins::KPImageInfo srcInfo(src); if (KDE_rename(QFile::encodeName(src.toLocalFile()), QFile::encodeName(dst.toLocalFile())) == 0) { // Rename XMP sidecar file KIPIPlugins::KPMetadata::moveSidecar(src, dst); srcInfo.setName(dst.fileName()); item->changeResult(i18nc("batch process result", "OK")); } else { item->changeResult(i18nc("batch process result", "Failed")); } } m_progress->progressBar()->setValue(m_progress->progressBar()->value() + 1); it = ui->m_listView->itemBelow(it); if (it) { ui->m_listView->setCurrentItem(it); ui->m_listView->scrollToItem(it); m_timer->setSingleShot(true); m_timer->start(0); } }