Autosave::AutosaveResult MainWindow::autosave() { QString path = currentPath(); if (path.isEmpty() || !controller) { return Autosave::PermanentFailure; } else if (controller->isEditingInProgress()) { return Autosave::TemporaryFailure; } else { showStatusBarMessage(tr("Autosaving..."), 0); if (controller->exportTo(autosavePath(currentPath()))) { // Success clearStatusBarMessage(); return Autosave::Success; } else { // Failure showStatusBarMessage(tr("Autosaving failed!"), 6000); return Autosave::PermanentFailure; } } }
bool MainWindow::removeAutosaveFile() const { if (!currentPath().isEmpty() && !has_autosave_conflict) { QFile autosave_file(autosavePath(currentPath())); return !autosave_file.exists() || autosave_file.remove(); } return false; }
static QString applicationFilePath_fromArgv(const char* argv0Param) { QString argv0; if (argv0Param) { argv0 = QString::fromUtf8(argv0Param); } QString absPath; if ( !argv0.isEmpty() && ( argv0.at(0) == QLatin1Char('/') ) ) { /* If argv0 starts with a slash, it is already an absolute file path. */ absPath = argv0; } else if ( argv0.contains( QLatin1Char('/') ) ) { /* If argv0 contains one or more slashes, it is a file path relative to the current directory. */ absPath = currentPath(); absPath.append(argv0); } else { /* Otherwise, the file path has to be determined using the PATH environment variable. */ QByteArray pEnv = qgetenv("PATH"); QString currentDirPath = currentPath(); QStringList paths = QString::fromLocal8Bit( pEnv.constData() ).split( QLatin1Char(':') ); for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) { if ( (*p).isEmpty() ) { continue; } QString candidate = currentDirPath; candidate.append(*p + QLatin1Char('/') + argv0); struct stat _s; if (stat(candidate.toStdString().c_str(), &_s) == -1) { continue; } if ( S_ISDIR(_s.st_mode) ) { continue; } absPath = candidate; break; } } absPath = QDir::cleanPath(absPath); return absPath; } // applicationFilePath_fromArgv
// See the specification for details of what this function does. QString KoStore::toExternalNaming( const QString & _internalNaming ) const { if ( _internalNaming == ROOTPART ) return expandEncodedDirectory( currentPath() ) + MAINNAME; QString intern; if ( _internalNaming.startsWith( "tar:/" ) ) // absolute reference intern = _internalNaming.mid( 5 ); // remove protocol else intern = currentPath() + _internalNaming; return expandEncodedPath( intern ); }
void QchDirectory::setCurrentPath(const QString &path) { if (path != currentPath()) { if (QDir::setCurrent(path)) { emit currentPathChanged(); } } }
QModelIndex QFileSystemModelEx::index(const QString &path, int column) const { QFileInfo info(path); if(info.exists() && info.isDir()) { QString fullPath = QDir::fromNativeSeparators(info.canonicalFilePath()); QStringList parts = fullPath.split('/', QString::SkipEmptyParts); for(int i = 2; i <= parts.count(); i++) { QFileInfo currentPath(((QStringList) parts.mid(0, i)).join("/")); if((!currentPath.exists()) || (!currentPath.isDir()) || currentPath.isHidden()) { return QModelIndex(); } } QModelIndex index = QFileSystemModel::index(fullPath, column); if(index.isValid()) { QModelIndex temp = index; while(temp.isValid()) { removeFromCache(filePath(temp).toLower()); temp = temp.parent(); } return index; } } return QModelIndex(); }
//static QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) { if (entry.isAbsolute() && entry.isClean()) return entry; QByteArray orig = entry.nativeFilePath(); QByteArray result; if (orig.isEmpty() || !orig.startsWith('/')) { QFileSystemEntry cur(currentPath()); result = cur.nativeFilePath(); } if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) { if (!result.isEmpty() && !result.endsWith('/')) result.append('/'); result.append(orig); } if (result.length() == 1 && result[0] == '/') return QFileSystemEntry(result, QFileSystemEntry::FromNativePath()); const bool isDir = result.endsWith('/'); /* as long as QDir::cleanPath() operates on a QString we have to convert to a string here. * ideally we never convert to a string since that loses information. Please fix after * we get a QByteArray version of QDir::cleanPath() */ QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath()); QString stringVersion = QDir::cleanPath(resultingEntry.filePath()); if (isDir) stringVersion.append(QLatin1Char('/')); return QFileSystemEntry(stringVersion); }
void FileSystemRemoteDialog::getContentFolder() { m_bWaitResponse = false; controlsChangeState(m_bWaitResponse); emit requestFolderContents(currentPath(), false); }
QString FileSystemRemoteDialog::selectFolder() const { if(table->selectionModel()->selectedRows(0).size() != 1) return QString(); return currentPath() + table->selectionModel()->selectedRows(0)[0].data(Qt::DisplayRole).toString(); }
// virtual // Tells maya that color per vertex will be needed. int hwColorPerVertexShader::normalsPerVertex() { unsigned int numNormals = mNormalsPerVertex; MStringArray setNames; const MDagPath & path = currentPath(); if (path.hasFn( MFn::kMesh ) ) { // Check the # of uvsets. If no uvsets // then can't return tangent or binormals // // MGlobal::displayInfo( path.fullPathName() ); MFnMesh fnMesh( path.node() ); if (fnMesh.numUVSets() == 0) { // Put out a warnnig if we're asking for too many uvsets. MString dispWarn("Asking for more uvsets then available for shape: "); MString pathName = path.fullPathName(); dispWarn = dispWarn + pathName; MGlobal::displayWarning( dispWarn ); numNormals = (mNormalsPerVertex > 1 ? 1 : 0); } } return numNormals; }
bool MainWindow::savePath(const QString &path) { if (!controller) return false; if (path.isEmpty()) return showSaveAsDialog(); const FileFormat *format = FileFormats.findFormatForFilename(path); if (format->isExportLossy()) { QString message = tr("This map is being saved as a \"%1\" file. Information may be lost.\n\nPress Yes to save in this format.\nPress No to choose a different format.").arg(format->description()); int result = QMessageBox::warning(this, tr("Warning"), message, QMessageBox::Yes, QMessageBox::No); if (result != QMessageBox::Yes) return showSaveAsDialog(); } if (!controller->save(path)) return false; setMostRecentlyUsedFile(path); setHasAutosaveConflict(false); removeAutosaveFile(); if (path != currentPath()) { setCurrentPath(path); removeAutosaveFile(); } setHasUnsavedChanges(false); return true; }
void MainWindow::switchActualPath(const QString& path) { if (path == actual_path) { return; } int ret = QMessageBox::Ok; if (has_unsaved_changes) { ret = QMessageBox::warning(this, appName(), tr("The file has been modified.\n" "Do you want to discard your changes?"), QMessageBox::Discard | QMessageBox::Cancel); } if (ret != QMessageBox::Cancel) { const QString& current_path = currentPath(); MainWindowController* const new_controller = MainWindowController::controllerForFile(current_path); if (new_controller && new_controller->load(path, this)) { setController(new_controller, current_path); actual_path = path; setHasUnsavedChanges(false); } } emit actualPathChanged(actual_path); activateWindow(); }
void RecurseWorker::workDir( const QString &dir ) { QFileInfoList files( QDir(dir).entryInfoList() ); emit currentPath( dir ); foreach( const QFileInfo &fileInfo, files ) { if( mCancel ) { break; } if( fileInfo.fileName().left(1) == "." ) { continue; } if( fileInfo.isDir() ) { workDir( fileInfo.absoluteFilePath() ); } if( fileInfo.isFile() ) { mpDatabase->getTrackInfo( this, SLOT(updateTrackInfo(TrackInfo)), fileInfo.absoluteFilePath() ); } } }
bool MainWindow::showSaveOnCloseDialog() { if (has_opened_file && (has_unsaved_changes || has_autosave_conflict)) { // Show the window in case it is minimized setWindowState( (windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); raise(); activateWindow(); QMessageBox::StandardButton ret; if (!has_unsaved_changes && actual_path != autosavePath(currentPath())) { ret = QMessageBox::warning(this, appName(), tr("Do you want to remove the autosaved version?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); } else { ret = QMessageBox::warning(this, appName(), tr("The file has been modified.\n" "Do you want to save your changes?"), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); } switch (ret) { case QMessageBox::Cancel: return false; case QMessageBox::Discard: if (has_autosave_conflict) setHasAutosaveConflict(false); else removeAutosaveFile(); break; case QMessageBox::Save: if (!save()) return false; // fall through case QMessageBox::Yes: setHasAutosaveConflict(false); removeAutosaveFile(); break; case QMessageBox::No: setHasAutosaveConflict(false); break; default: Q_ASSERT(false && "Unsupported return value from message box"); break; } } return true; }
void MenuSAT::RunSATPlug(ScribusDoc* doc) { QDir templates(ScPaths::getApplicationDataDir()); if (!templates.exists("templates")) { templates.mkdir("templates"); } QString currentPath(QDir::currentPath()); QString currentFile(doc->DocName); bool hasName = doc->hasName; bool isModified = doc->isModified(); QString userTemplatesDir = PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates; PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs"); QString oldCollect = dirs->get("collect", "."); QString templatesDir = "."; if (userTemplatesDir.isEmpty()) templatesDir = ScPaths::getApplicationDataDir() + "templates"; else { if (userTemplatesDir.right(1) == "/") userTemplatesDir.chop(1); templatesDir = userTemplatesDir; } dirs->set("collect", templatesDir); if (doc->scMW()->fileCollect().isEmpty()) return; if (oldCollect != ".") dirs->set("collect", oldCollect); QString docPath = doc->DocName; QString docDir = docPath.left(docPath.lastIndexOf('/')); QString docName = docPath.right(docPath.length() - docPath.lastIndexOf('/') - 1); docName = docName.left(docName.lastIndexOf(".s")); if (currentFile != doc->DocName) { SATDialog* satdia = new SATDialog(doc->scMW(),docName, static_cast<int>(doc->pageWidth() + 0.5), static_cast<int>(doc->pageHeight() + 0.5)); if (satdia->exec()) { sat* s = new sat(doc, satdia, docPath.right(docPath.length() - docPath.lastIndexOf('/') - 1),docDir); s->createImages(); s->createTmplXml(); delete s; } // Restore the state that was before ScMW->Collect() doc->DocName = currentFile; doc->hasName = hasName; doc->setModified(isModified); QString newCaption=currentFile; if (isModified) newCaption.append('*'); doc->scMW()->updateActiveWindowCaption(newCaption); doc->scMW()->removeRecent(docPath); QDir::setCurrent(currentPath); delete satdia; } }
const QUrl AddressManager::currentAddress() const { QUrl hifiURL; hifiURL.setScheme(HIFI_URL_SCHEME); hifiURL.setHost(_host); hifiURL.setPath(currentPath()); return hifiURL; }
bool KoStore::leaveDirectory() { if ( m_currentPath.isEmpty() ) return false; m_currentPath.pop_back(); return enterAbsoluteDirectory( expandEncodedDirectory( currentPath() ) ); }
void StackComponentManager::addRepository(std::string repoPath) { while(!repoPath.empty()) { //Extract paths from the repository string size_t pos = repoPath.find_first_of(';'); string str(repoPath, 0, pos); repoPath.erase(0, pos); // break out of the while if str is empty (e.g. with a repos="/path/to/1;") if (str.empty()) break; bfs::path currentPath(str); //Check that the path exists and is a directory if(!bfs::exists(currentPath) || !bfs::is_directory(currentPath)) { LOG(LFATAL) << "Could not add repository " << str << " path does not exist or is not a directory."; throw ResourceNotFoundException("Could not add repository " + str + " path does not exist or is not a directory."); } //Create a repository object Repository tmp; tmp.path = currentPath; //Go through files in the repository and add to the repository vector of component libraries bfs::directory_iterator dir_iter(currentPath), dir_end; for(;dir_iter != dir_end; ++dir_iter) { //Check that the file path contains the system library extension #if BOOST_FILESYSTEM_VERSION == 2 string filename = dir_iter->path().leaf(); #else string filename = dir_iter->path().filename().string(); #endif size_t pos = filename.find_last_of('.'); if(pos != string::npos) { string extension = filename.substr(pos); if(extension == SharedLibrary::getSystemExtension()) { size_t pre = SharedLibrary::getSystemPrefix().length(); string stem = filename.substr(pre,pos-pre); //Remove library prefix and postfix ComponentLibrary current; current.path = dir_iter->path(); current.name = stem; boost::to_lower(current.name); tmp.componentLibs.push_back(current); } } } //Add to vector of repository paths repositories_.push_back(tmp); } }
bool KoStore::leaveDirectory() { Q_D(KoStore); if (d->currentPath.isEmpty()) return false; d->currentPath.pop_back(); return enterAbsoluteDirectory(d->expandEncodedDirectory(currentPath())); }
QStringList FileSystemRemoteDialog::selectFiles() const { QStringList list; for(QModelIndex model: table->selectionModel()->selectedRows(0)) { if(!model.data(Qt::UserRole).toBool()) list.append(currentPath() + model.data(Qt::DisplayRole).toString()); } return list; }
void FmFileWidget::on_driveWatcher_driveAddedOrChanged() { FM_LOG( QString( "FmFileDialog_FmFileWidget::on_driveWatcher_driveAddedOrChanged start" ) ); mDriveModel->refresh(); if( currentViewType() == DriveView ) { setModel( 0 ); setModel( mDriveModel ); emit pathChanged( QString() ); } else if( currentViewType() == DirView ) { if( FmErrNone != FmUtils::isPathAccessabel( currentPath().absoluteFilePath() ) ) { // path not available, set model to drive FM_LOG( QString( "FmFileDialog_FmFileWidget::on_driveWatcher_driveAddedOrChanged path not availeable, set drivemodel:" + currentPath().absoluteFilePath() ) ); setModel( mDriveModel ); emit pathChanged( QString() ); } } FM_LOG( QString( "FmFileDialog_FmFileWidget::on_driveWatcher_driveAddedOrChanged end" ) ); }
bool FmFileWidget::cdUp() { QString path( FmUtils::checkFolderToDriveFilter( currentPath().absoluteFilePath() ) ); QFileInfo fileInfo( path ); QString cdUpPath; // path length>3 means current path is a sub folder, then get up level path and navigate to it // Otherwise means current path is a top level drive path, Should navigate to drive view. So setRootPath with empty path string. if( path.length() > 3 ) { cdUpPath = fileInfo.dir().absolutePath(); } setRootPath( FmUtils::fillPathWithSplash( cdUpPath ) ); return true; }
void BootstrapPlatformSpecific(string path) { // Add runtime path and all module paths to PATH path = app->runtime->path + ";" + path; string currentPath(EnvironmentUtils::Get("PATH")); EnvironmentUtils::Set("KR_ORIG_PATH", currentPath); // make sure the runtime folder is used before system DLL directories SetDllDirectoryW(KrollUtils::UTF8ToWide(app->runtime->path).c_str()); if (!currentPath.empty()) path = path + ";" + currentPath; EnvironmentUtils::Set("PATH", path); }
const QUrl AddressManager::currentAddress() const { QUrl hifiURL; hifiURL.setScheme(HIFI_URL_SCHEME); hifiURL.setHost(_host); if (_port != 0 && _port != DEFAULT_DOMAIN_SERVER_PORT) { hifiURL.setPort(_port); } hifiURL.setPath(currentPath()); return hifiURL; }
bool TestRunner::visitEnter(TestSuite& suite) { if (m_context->shouldStop()) return false; if (!TestQualifier::visitEnter(suite)) return false; if (shouldVisit(currentPath())) return true; TestQualifier::visitLeave(suite); return false; }
/// indefinitely loops over user input expecting commands int loop(teasafe::TeaSafe &theBfs) { std::string currentPath("/"); while (1) { std::string commandStr; std::cout<<"ts$> "; commandStr = getInputString(theBfs, currentPath); try { parse(theBfs, commandStr, currentPath); } catch (...) { std::cout<<"Some error occurred!"<<std::endl; } } return 0; }
void PageReader::include(const std::string& path) { Poco::Path currentPath(_path); Poco::Path includePath(path); currentPath.resolve(includePath); _page.handler() << "\t// begin include " << currentPath.toString() << "\n"; Poco::FileInputStream includeStream(currentPath.toString()); PageReader includeReader(*this, currentPath.toString()); includeReader.emitLineDirectives(_emitLineDirectives); includeReader.parse(includeStream); _page.handler() << "\t// end include " << currentPath.toString() << "\n"; }
std::string getFile(const std::string& aPath, const std::string& mask) { boost::filesystem::path currentPath(aPath); currentPath /= mask; std::string foundFile; if (boost::filesystem::exists(currentPath) && boost::filesystem::is_regular_file(currentPath)) foundFile = currentPath.string(); if (foundFile.empty()) { std::cout << "file found in " + aPath << std::endl; exit(EXIT_FAILURE); } std::cout << "File: " + foundFile << std::endl; return foundFile; }
bool TestRunner::visit(TestCase& test) { if (m_context->shouldStop()) return false; if (!shouldVisit(currentPath() + test.name())) return false; int rst = runTestCase(test, *m_context, logS()); if( 0 != rst ) m_failures++; m_tests++; // Always continue, regardless of test result, unless the context // object says otherwise. return !m_context->shouldStop(); }
// virtual // Tells maya that color per vertex will be needed. int hwColorPerVertexShader::colorsPerVertex() { int returnVal = 0; // Going to be displaying false coloring, // so skip getting internal colors. if (mNormalsPerVertex) return 0; else { const MDagPath & path = currentPath(); if (path.hasFn( MFn::kMesh ) ) { MFnMesh fnMesh( path.node() ); unsigned int numColorSets = fnMesh.numColorSets(); if (numColorSets < 2) returnVal = numColorSets; else returnVal = 2; } } return returnVal; }