本文整理汇总了C++中QDir::removeRecursively方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::removeRecursively方法的具体用法?C++ QDir::removeRecursively怎么用?C++ QDir::removeRecursively使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDir
的用法示例。
在下文中一共展示了QDir::removeRecursively方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cleanupTestCase
void cleanupTestCase()
{
// Do the same cleanups
QDir dir (PRIVILEGED_DATA_DIR);
dir.removeRecursively();
}
示例2: Clean
bool Builder::Clean(void)
{
msg.buildStage = 0;
project = workspace.GetCurrentProject();
if (project == NULL) {
msg.Add("Could not find detect the current project", mtError);
return false;
}
map <QString, BoardDef>::const_iterator board = config.boards.find(project->boardName);
if (board == config.boards.end()) {
msg.Add("Could not find board configuration for project: " + project->name, mtError);
return false;
}
// Create the build directory
buildPath = config.workspace + "/" + project->name + "/build";
QDir dir = QDir(buildPath);
bool ok = dir.removeRecursively();
if (ok==false) {
msg.Add("Error while cleaning project " + project->name + ".", mtError);
}
msg.ClearBuildInfo();
lastBuildStatus = 0;
return ok;
}
示例3: clearCache
void QSpotifySession::clearCache() {
qDebug() << "QSpotifySession::clearCache";
QString dataPath = settings.value("dataPath").toString();
if(dataPath.contains(".local/share") || dataPath.contains("/mnt/sdcard/")) {
QDir *dataDir = new QDir(dataPath);
dataDir->removeRecursively();
}
}
示例4: removeFromFileSystem
/**
* Removes the directory recursively from the file system
*/
bool NoteSubFolder::removeFromFileSystem() {
QDir dir = this->dir();
if (dir.exists()) {
return dir.removeRecursively();
}
return false;
}
示例5: out
rm::rm(QString cmd) {
QTextStream out (stdout);
QString dirNAME = cmd.mid(3);
QDir path;
if(cmd.contains(".txt"))
path.remove(dirNAME);
else if(cmd.contains(" -r"))
path.removeRecursively();
else
path.rmdir(dirNAME);
}
示例6: _clearmydocs
bool _clearmydocs(){
//Delete and recreate MyDocuments\Aquamark3 folder
QDir mydocs; mydocs.setPath(qApp->property("Benchmark_My_Docs_Folder").toString());
QDir benchpath; benchpath.setPath(qApp->property("Benchmark_Install_Path").toString());
mydocs.removeRecursively(); WriteLog("mydocs removed:" + mydocs.absolutePath() );
if (!mydocs.exists()) {
mydocs.mkpath(".");
WriteLog("mydocs created: " + mydocs.absolutePath() );
return true;
} else {
return false;
}
}
示例7: if
rm::rm(QString cmd){
char dec;
QString dirNAME = cmd.mid(3);
QDir path;
if(cmd.contains(".txt"))
path.remove(dirNAME);
else if(cmd.contains(" -r")){
out << "Are you sure about this? It's gonna delete everything." <<endl;
in >> dec;
if(dec == 'Y')
path.removeRecursively();
}
示例8: preparePatches
void TestAusmt::preparePatches()
{
GET_DIR;
GET_FILES_DIR;
GET_PATCHES_DIR;
// Dump patches
QDir patchesResDir (":/patches/");
foreach (const QString &fileName, patchesResDir.entryList(QDir::Files)) {
QFile file (patchesResDir.absoluteFilePath(fileName));
if (patchesDir.exists(fileName)) {
QVERIFY(QFileInfo(patchesDir.absoluteFilePath(fileName)).isFile());
QVERIFY(patchesDir.remove(fileName));
}
QVERIFY(file.copy(patchesDir.absoluteFilePath(fileName)));
}
foreach (const QString &dirName, patchesResDir.entryList(QDir::Dirs)) {
if (patchesDir.exists(dirName)) {
QVERIFY(QFileInfo(patchesDir.absoluteFilePath(dirName)).isDir());
QDir subDir (patchesDir);
QVERIFY(subDir.cd(dirName));
QVERIFY(subDir.removeRecursively());
}
patchesDir.mkdir(dirName);
QDir patchesSubDir (patchesDir);
QVERIFY(patchesSubDir.cd(dirName));
QDir patchesResSubDir (patchesResDir);
QVERIFY(patchesResSubDir.cd(dirName));
foreach (const QString &fileName, patchesResSubDir.entryList(QDir::Files)) {
QFile file (patchesResSubDir.absoluteFilePath(fileName));
QVERIFY(file.copy(patchesSubDir.absoluteFilePath(fileName)));
}
}
// Update patches
QString makePatchName = patchesDir.absoluteFilePath(MAKE_PATCH_SH);
QFile makePatch (makePatchName);
QVERIFY(makePatch.exists());
QVERIFY(makePatch.setPermissions(QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ExeUser));
QProcess makePatchProcess;
makePatchProcess.setWorkingDirectory(patchesDir.absolutePath());
makePatchProcess.start(patchesDir.absoluteFilePath(MAKE_PATCH_SH),
QStringList() << filesDir.absolutePath());
makePatchProcess.waitForFinished(-1);
QCOMPARE(makePatchProcess.exitCode(), 0);
}
示例9: disconnect
void TokenManager::disconnect()
{
setToken(QString());
// We need to remove the cache TODO: move this as independant of app names ?
QString sharePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
if (!sharePath.contains(QCoreApplication::instance()->applicationName())) {
return;
}
if (!sharePath.contains(QCoreApplication::instance()->organizationName())) {
return;
}
QDir dataDir (sharePath);
dataDir.removeRecursively();
}
示例10: deleteTodoLists
void LocalXmlBackend::deleteTodoLists()
{
QList<ITodoList*> todoLists;
do {
todoLists = m_database->getTodoLists( IDatabase::QueryDisposed, 100 );
for ( ITodoList *todoList : todoLists ) {
QString fileName = m_localStorageDirectory + "/" +
todoList->metaAttributes().value( TodoListMetaFileName, QString() ).toString();
QFileInfo fi( fileName );
if ( fi.exists() ) {
QDir dir = fi.absoluteDir();
dir.removeRecursively();
}
m_database->deleteTodoList( todoList );
delete todoList;
}
} while ( !todoLists.isEmpty() );
}
示例11: testUninstallRemove
void TestAusmt::testUninstallRemove()
{
prepareSimple();
GET_DIR;
GET_FILES_DIR;
GET_PATCHES_DIR;
// The user uninstalled the patch package, and is trying to remove the patch
QCOMPARE(QProcess::execute(dir.absoluteFilePath(AUSMT_INSTALL), QStringList() << "simple-patch1"), 0);
checkSimple1Applied();
// Remove the installed patch
QDir simplePatchDir (patchesDir.absoluteFilePath("simple-patch1"));
QVERIFY(simplePatchDir.removeRecursively());
// Unapply
QCOMPARE(QProcess::execute(dir.absoluteFilePath(AUSMT_REMOVE), QStringList() << "simple-patch1"), 0);
checkUnapplied();
}
示例12: checkCrashsaves
void CrashHandler::checkCrashsaves()
{
MainWindow *mw = MainWinConnect::pMainWin;
QDir crashSave;
crashSave.setCurrent(AppPathManager::userAppDir());
if(crashSave.exists("__crashsave"))
{
crashSave.cd("__crashsave");
QStringList allCrashFiles = crashSave.entryList(QDir::Files | QDir::NoDotAndDotDot);
for(QString &file : allCrashFiles)
{
QString fPath = crashSave.absoluteFilePath(file);
mw->OpenFile(fPath, false);
}
QList<QMdiSubWindow *> listOfAllSubWindows = mw->allEditWins();
for(QMdiSubWindow *subWin : listOfAllSubWindows)
{
/*if(MainWinConnect::pMainWin->activeChildWindow(subWin) == 1){
MainWinConnect::pMainWin->activeLvlEditWin()->makeCrashState();
}else */
if(mw->activeChildWindow(subWin) == MainWindow::WND_NpcTxt)
mw->activeNpcEditWin()->makeCrashState();
/*else if(MainWinConnect::pMainWin->activeChildWindow(subWin) == 3){
MainWinConnect::pMainWin->activeWldEditWin()->makeCrashState();
}*/
}
//Clean up all files from crash-save folder after restoring
crashSave.removeRecursively();
QMessageBox::information(mw,
tr("Crash recovery", "Crash recovery - emergency file saving after crash. A title of message box."),
tr("Since the last crash, the editor recovered some files.\n"
"Please save them before doing anything else."),
QMessageBox::Ok);
}
}
示例13: onRemoveRepoAction
void Gitarre::onRemoveRepoAction()
{
int i = RepoView->currentIndex().row();
QMessageBox messageBox (QMessageBox::NoIcon, "Remove repository", "Do you want to remove this repository or delete it?");
QPushButton *buttonRemove = messageBox.addButton ("Remove", QMessageBox::AcceptRole);
QPushButton *buttonDelete = messageBox.addButton ("Delete", QMessageBox::RejectRole);
messageBox.addButton (QMessageBox::Cancel);
messageBox.exec();
if (messageBox.clickedButton() == buttonRemove)
RemoveRepo (i);
else if (messageBox.clickedButton() == buttonDelete)
{
int res = QMessageBox::warning (this, "Delete repository", "This will permanently delete the working directory from file system. Proceed?", QMessageBox::Ok | QMessageBox::Cancel);
if (res == QMessageBox::Ok)
{
QDir dir = Repos[i]->GetDir();
RemoveRepo (i);
dir.removeRecursively();
}
else
onRemoveRepoAction();
}
}
示例14: initTestCase
void TestAusmt::initTestCase()
{
// Dirs
QDir srcDir (QStandardPaths::writableLocation(QStandardPaths::TempLocation));
if (!srcDir.exists(AUSMTSRC_SUBDIR)) {
QVERIFY(srcDir.mkdir(AUSMTSRC_SUBDIR));
}
QVERIFY(srcDir.cd(AUSMTSRC_SUBDIR));
GET_DIR;
GET_VAR_DIR;
GET_FILES_DIR;
GET_PATCHES_DIR;
// Dump AUSMT into src dir
QDir ausmtResDir (":/ausmtsrc/");
foreach (const QString &fileName, ausmtResDir.entryList(QDir::Files)) {
QFile file (ausmtResDir.absoluteFilePath(fileName));
if (srcDir.exists(fileName)) {
QVERIFY(QFileInfo(srcDir.absoluteFilePath(fileName)).isFile());
QVERIFY(srcDir.remove(fileName));
}
QVERIFY(file.copy(srcDir.absoluteFilePath(fileName)));
}
QDir ausmtTestResDir (":/ausmtsrc-test/");
foreach (const QString &fileName, ausmtTestResDir.entryList(QDir::Files)) {
QFile file (ausmtTestResDir.absoluteFilePath(fileName));
if (srcDir.exists(fileName)) {
QVERIFY(QFileInfo(srcDir.absoluteFilePath(fileName)).isFile());
QVERIFY(srcDir.remove(fileName));
}
QVERIFY(file.copy(srcDir.absoluteFilePath(fileName)));
}
// Make a better constants_root.sh
QFile constantsRoot (srcDir.absoluteFilePath(CONSTANTS_ROOT_SH));
QVERIFY(constantsRoot.open(QIODevice::WriteOnly));
QTextStream constantsRootStream (&constantsRoot);
constantsRootStream << QString("AUSMT_VAR_DIR=%1\n").arg(varDir.absolutePath());
constantsRootStream << QString("PATCH_ROOT_DIR=%1\n").arg(patchesDir.absolutePath());
constantsRootStream << QString("FILES_DIR=%1\n").arg(filesDir.absolutePath());
constantsRootStream << QString("NOTIFY_WRAPPER_EXEC=echo\n");
constantsRoot.close();
// Build AUSMT
QString buildName = srcDir.absoluteFilePath(BUILD_SH);
QFile build (buildName);
QVERIFY(build.exists());
QVERIFY(build.setPermissions(QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ExeUser));
QProcess buildProcess;
buildProcess.setWorkingDirectory(srcDir.absolutePath());
buildProcess.start(PYTHON, QStringList() << buildName);
buildProcess.waitForFinished(-1);
QCOMPARE(buildProcess.exitCode(), 0);
foreach (const QString &fileName, dir.entryList(QDir::Files)) {
QFile file (dir.absoluteFilePath(fileName));
QVERIFY(file.setPermissions(QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ExeUser));
}
// Remove src
QVERIFY(srcDir.removeRecursively());
// Prepare patches
preparePatches();
}
示例15: saveSession
bool saveSession(DocEngine* docEngine, TopEditorContainer* editorContainer, QString sessionPath, QString cacheDirPath)
{
const bool cacheModifiedFiles = !cacheDirPath.isEmpty();
QDir cacheDir;
// Clear the cache directory by deleting and recreating it.
if (cacheModifiedFiles) {
cacheDir = QDir(cacheDirPath);
bool success = false;
if (cacheDir.exists())
success = cacheDir.removeRecursively();
success |= cacheDir.mkpath(cacheDirPath);
if(!success)
return false;
}
std::vector<ViewData> viewData;
//Loop through all tabwidgets and their tabs
const int tabWidgetsCount = editorContainer->count();
for (int i = 0; i < tabWidgetsCount; i++) {
EditorTabWidget *tabWidget = editorContainer->tabWidget(i);
const int tabCount = tabWidget->count();
viewData.push_back( ViewData() );
ViewData& currentViewData = viewData.back();
for (int j = 0; j < tabCount; j++) {
Editor* editor = tabWidget->editor(j);
bool isClean = editor->isClean();
bool isOrphan = editor->fileName().isEmpty();
if (isOrphan && !cacheModifiedFiles)
continue; // Don't save temporary files if we're not caching tabs
TabData td;
if (!isClean && cacheModifiedFiles) {
// Tab is dirty, meaning it needs to be cached.
QUrl cacheFilePath = PersistentCache::createValidCacheName(cacheDir, tabWidget->tabText(j));
td.cacheFilePath = cacheFilePath.toLocalFile();
if (docEngine->saveDocument(tabWidget, j, cacheFilePath, true) != DocEngine::saveFileResult_Saved) {
return false;
}
} else if (isOrphan) {
// Since we didn't cache the file and it is an orphan, we won't save it in the session.
continue;
}
// Else tab is an openened unmodified file, we don't have to do anything special.
td.filePath = !isOrphan ? editor->fileName().toLocalFile() : "";
// Finally save other misc information about the tab.
const auto& scrollPos = editor->scrollPosition();
td.scrollX = scrollPos.first;
td.scrollY = scrollPos.second;
td.active = tabWidget->currentEditor() == editor;
td.language = editor->language();
// If we're caching and there's a file opened in the tab we want to inform the
// user whether the file's contents have changed since Nqq was last opened.
// For this we save and later compare the modification date.
if (!isOrphan && cacheModifiedFiles) {
// As a special case, if the file has *already* changed we set the modification
// time to 1 so we always trigger the warning.
if (editor->fileOnDiskChanged())
td.lastModified = 1;
else
td.lastModified = QFileInfo(td.filePath).lastModified().toMSecsSinceEpoch();
}
currentViewData.tabs.push_back( td );
} // end for
} // end for
// Write all information to a session file
QFile file(sessionPath);
file.open(QIODevice::WriteOnly);
if (!file.isOpen())
return false;
SessionWriter sessionWriter(file);
for (const auto& view : viewData)
sessionWriter.addViewData(view);
return true;
}