/*! Converts a directory recursively. */ void ConverterCore::convertDirectory(const QDir &input, const QDir &output) { QDir tempInput = input; tempInput.makeAbsolute(); if (!tempInput.exists()) { qFatal("Error! Input: %s does not exist!", tempInput.path().toLocal8Bit().data()); } QStringList dirs(tempInput.entryList(QDir::Dirs | QDir::NoDotAndDotDot)); QStringList files(tempInput.entryList(QDir::Files)); QDir tempOutput = output; tempOutput.makeAbsolute(); if (!tempOutput.exists()) { if (!tempOutput.mkpath(output.path())) qFatal("Creating directory failed! %s", tempOutput.path().toLocal8Bit().data()); } foreach (const QString &file, files) { ConverterFile converter(tempInput.path() + "/" + file, output.path() + "/" + file, flags); converter.convertToQrc(); if (converter.isErrorState()) { enterErrorState(converter.errorMessage()); return; } }
bool MercurialPlugin::isValidDirectory(const QUrl &directory) { // Mercurial uses the same test, so we don't lose any functionality static const QString hgDir(".hg"); if (m_lastRepoRoot.isParentOf(directory)) return true; const QString initialPath(directory.adjusted(QUrl::StripTrailingSlash).toLocalFile()); const QFileInfo finfo(initialPath); QDir dir; if (finfo.isFile()) { dir = finfo.absoluteDir(); } else { dir = QDir(initialPath); dir.makeAbsolute(); } while (!dir.cd(hgDir) && dir.cdUp()) {} // cdUp, until there is a sub-directory called .hg if (hgDir != dir.dirName()) return false; dir.cdUp(); // Leave .hg // TODO: Check whether this is the right port, original code was: m_lastRepoRoot.setDirectory(dir.absolutePath()); m_lastRepoRoot.setPath(dir.absolutePath()); return true; }
bool GitRunner::isValidDirectory() { const QString initialPath(m_lastRepoRoot->toLocalFile(KUrl::RemoveTrailingSlash)); setDirectory(*m_lastRepoRoot); // A possible git repo has a .git subdicerctory const QString gitDir(".git"); // Also, git rev-parse --is-inside-work-tree returns "true" if we are // inside any subdirectory of the git tree. DvcsJob *job = new DvcsJob(); initJob(*job); *job << "rev-parse"; *job << "--is-inside-work-tree"; startJob(*job); QFileInfo finfo(initialPath); QDir dir; if (finfo.isFile()) { dir = finfo.absoluteDir(); } else { dir = QDir(initialPath); dir.makeAbsolute(); } return (dir.exists(gitDir) && m_result.compare("true")) ? true : false; }
QString findExeAtPath (const QString appname, const QString &path) { QDir dir (path); dir.makeAbsolute (); if (QFileInfo (dir.filePath (appname)).isExecutable ()) return dir.filePath (appname); #ifdef Q_WS_WIN if (QFileInfo (dir.filePath (appname + ".exe")).isExecutable ()) return dir.filePath (appname + ".exe"); if (QFileInfo (dir.filePath (appname + ".com")).isExecutable ()) return dir.filePath (appname + ".com"); if (QFileInfo (dir.filePath (appname + ".bat")).isExecutable ()) return dir.filePath (appname + ".bat"); #endif return QString (); }
void MainWidget::ShowOutput() { QString helpString; helpString += "projects\\" + leProjectName->text() + "\\output.html"; QDir dir; dir.setPath(helpString); dir.makeAbsolute(); helpString = dir.path(); emit showWebWidget(helpString); }
void CaptureDialog::on_exePath_textChanged(const QString &exe) { QFileInfo f(exe); QDir dir = f.dir(); bool valid = dir.makeAbsolute(); if(valid && f.isAbsolute()) ui->workDirPath->setPlaceholderText(QDir::toNativeSeparators(dir.absolutePath())); else if(exe == "") ui->workDirPath->setPlaceholderText(""); updateGlobalHook(); }
void CaptureDialog::on_exePath_textChanged(const QString &text) { QString exe = text; // This is likely due to someone pasting a full path copied using copy path. Removing the quotes // is safe in any case if(exe.startsWith(QLatin1Char('"')) && exe.endsWith(QLatin1Char('"')) && exe.count() > 2) { exe = exe.mid(1, exe.count() - 2); ui->exePath->setText(exe); return; } QFileInfo f(exe); QDir dir = f.dir(); bool valid = dir.makeAbsolute(); if(valid && f.isAbsolute()) { QString path = dir.absolutePath(); if(!m_Ctx.Replay().CurrentRemote()) path = QDir::toNativeSeparators(path); // match the path separators from the path if(exe.count(QLatin1Char('/')) > exe.count(QLatin1Char('\\'))) path = path.replace(QLatin1Char('\\'), QLatin1Char('/')); else path = path.replace(QLatin1Char('/'), QLatin1Char('\\')); ui->workDirPath->setPlaceholderText(path); } else if(exe.isEmpty()) { ui->workDirPath->setPlaceholderText(QString()); } UpdateGlobalHook(); }