コード例 #1
0
bool deleteDirectory(wxString& path, wxString& item)
{
   {
      wxDir dir;
      wxString filePath = path + "\\" + item;
      
      wxString file;
      dir.Open(filePath);
      if (!dir.IsOpened()) return false;
      bool cont = false;
      if (dir.HasFiles() || dir.HasSubDirs())
         cont = dir.GetFirst(&file);
      while (cont)
      {
         wxString strFile = filePath + "\\" + file;
         
         if (dir.Exists(strFile))
            deleteDirectory(filePath, file);

         SetFileAttributes(strFile.c_str(), FILE_ATTRIBUTE_NORMAL); // Make it not read only, so we can delete it
         wxRemoveFile(strFile);

         cont = dir.GetNext(&file);
      }
   }
   return wxRmdir(path + "\\" + item);
}
コード例 #2
0
ファイル: vutils.cpp プロジェクト: liunianbanbo/vnote
bool VUtils::emptyDirectory(const VNotebook *p_notebook,
                            const QString &p_path,
                            bool p_skipRecycleBin)
{
    QDir dir(p_path);
    if (!dir.exists()) {
        return true;
    }

    QFileInfoList nodes = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden
                                            | QDir::NoSymLinks | QDir::NoDotAndDotDot);
    for (int i = 0; i < nodes.size(); ++i) {
        const QFileInfo &fileInfo = nodes.at(i);
        if (fileInfo.isDir()) {
            if (!deleteDirectory(p_notebook, fileInfo.absoluteFilePath(), p_skipRecycleBin)) {
                return false;
            }
        } else {
            Q_ASSERT(fileInfo.isFile());
            if (!deleteFile(p_notebook, fileInfo.absoluteFilePath(), p_skipRecycleBin)) {
                return false;
            }
        }
    }

    return true;
}
コード例 #3
0
void DataSourceView::showContextMenu(const QPoint &point)
{
	QModelIndex i = currentIndex();

	if (!i.isValid())
		return;

	QMenu *menu = new QMenu(this);

	menu->addAction(style()->standardIcon(QStyle::SP_DirOpenIcon), tr("Open"), this, SLOT(indexOpenPath()));
	menu->addAction(QIcon(":/gfx/tab-new.png"), tr("Open in a new tab"), this, SLOT(openInANewTab()));
	menu->addAction(QIcon(":/gfx/gohome.png"), tr("Set as working directory"), this, SLOT(setWorkingDirectory()));
	menu->addAction(style()->standardIcon(QStyle::SP_FileDialogNewFolder), tr("Create directory"), this, SLOT(createDirectory()));

	menu->addSeparator();

	menu->addAction(QIcon(":/gfx/document-edit.png"), tr("Edit"), this, SLOT(editDirectory()));
	menu->addAction(QIcon(":/gfx/list-remove.png"), tr("Delete"), this, SLOT(deleteDirectory()));

	menu->addSeparator();

	m_signalMapper->setMapping(menu->addAction(QIcon(":/gfx/external_programs/ZIMA-PTC-Cleaner.png"), tr("Clean with ZIMA-PTC-Cleaner"), m_signalMapper, SLOT(map())),
	                           ZimaUtils::internalNameForUtility(ZimaUtils::ZimaPtcCleaner));
	m_signalMapper->setMapping(menu->addAction(QIcon(":/gfx/external_programs/ZIMA-CAD-Sync.png"), tr("Sync with ZIMA-CAD-Sync"), m_signalMapper, SLOT(map())),
	                           ZimaUtils::internalNameForUtility(ZimaUtils::ZimaCadSync));
	m_signalMapper->setMapping(menu->addAction(QIcon(":/gfx/external_programs/ZIMA-PS2PDF.png"), tr("Convert postscript to PDF with ZIMA-PS2PDF"), m_signalMapper, SLOT(map())),
	                           ZimaUtils::internalNameForUtility(ZimaUtils::ZimaPs2Pdf));
	m_signalMapper->setMapping(menu->addAction(QIcon(":/gfx/external_programs/ZIMA-STEP-Edit.png"), tr("Edit step files with ZIMA-STEP-Edit"), m_signalMapper, SLOT(map())),
	                           ZimaUtils::internalNameForUtility(ZimaUtils::ZimaStepEdit));

	menu->exec(mapToGlobal(point));
	menu->deleteLater();
}
コード例 #4
0
void CustomKinestheticTeacher::startRecording(){

    store->setExportMode(SensorStorage::STORE_TIME | SensorStorage::STORE_RBT_CART_POS | SensorStorage::STORE_RBT_JNT_POS);
    deleteDirectory(recordingPath);
    recordingThread= store->startDataStorage(recordingPath);

}
コード例 #5
0
void CDownload::deleteDownloadDirectory()
{
	// détruit le répertoire de téléchargement
	MyString dir;
	dir = getPersistentPath();
	dir += ACTIVEGS_DIRECTORY_SEPARATOR;
	dir += activegsdownloaddir;	
	deleteDirectory(dir.c_str(),1);
	
}
コード例 #6
0
ファイル: main.cpp プロジェクト: caiolima/onair_server
JNIEXPORT jboolean JNICALL Java_com_five_onair_server_utils_FileUtils_deleteDirectoryWithRoot
(JNIEnv *env, jclass _class, jstring _path){
    char *path;
    
    path=const_cast<char *>(env->GetStringUTFChars(_path, NULL));
    
    return deleteDirectory(path);
    
    
}
コード例 #7
0
		TITANIUM_FUNCTION(File, deleteDirectory)
		{
			bool recursive = false;
			if (arguments.size() > 0) {
				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsBoolean());
				recursive = static_cast<bool>(_0);
			}

			return get_context().CreateBoolean(deleteDirectory(recursive));
		}
コード例 #8
0
void DirectoryMonitor::Server::failDirectory(const string& aPath, const string& aReason) {
	auto mon = monitors.find(aPath);
	if (mon == monitors.end())
		return;

	mon->second->stopMonitoring();
	mon->second->server->base->fire(DirectoryMonitorListener::DirectoryFailed(), mon->first, aReason);
	failedDirectories.insert(mon->first);

	deleteDirectory(mon);
}
コード例 #9
0
void Settings::setupGui() {
    ui.setupUi(this);

    connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings()));
    connect(ui.patternEdit, SIGNAL(textChanged(QString)), this, SLOT(changeAddPatternButtonState(QString)));

    connect(ui.patternAddButton, SIGNAL(clicked()), this, SLOT(addPattern()));
    connect(ui.patternDeleteButton, SIGNAL(clicked()), this, SLOT(deletePattern()));

    connect(ui.directoryOpenButton, SIGNAL(clicked()), this, SLOT(addDirectory()));
    connect(ui.directoryDeleteButton, SIGNAL(clicked()), this, SLOT(deleteDirectory()));
}
コード例 #10
0
bool deleteDirFile(wxString& path, wxString& item)
{
   wxFile file;
   wxDir dir;
   wxString filePath = path + "\\" + item;

   if (dir.Exists(filePath))
      return deleteDirectory(path, item);

   if (file.Exists(filePath))
   {
	   SetFileAttributes(filePath.c_str(), FILE_ATTRIBUTE_NORMAL); // Make it not read only, so we can delete it
      return wxRemoveFile(filePath);
   }

   return false;
}
コード例 #11
0
ファイル: recorder.cpp プロジェクト: crazyleen/upd-cam
void Recorder::deleteDirectory(QFileInfo fileList)
{

    if(fileList.isDir()){
        int childCount =0;
        QString dir = fileList.filePath();
        QDir thisDir(dir);
        childCount = thisDir.entryInfoList().count();
        QFileInfoList newFileList = thisDir.entryInfoList();
        if(childCount>2){
            for(int i=0;i<childCount;i++){
                if(newFileList.at(i).fileName().operator ==(".")|newFileList.at(i).fileName().operator ==("..")){
                    continue;
                }
                deleteDirectory(newFileList.at(i));
            }
        }
        fileList.absoluteDir().rmpath(fileList.fileName());
    }else if(fileList.isFile()){
        fileList.absoluteDir().remove(fileList.fileName());
    }

}
コード例 #12
0
ファイル: Filesystem.cpp プロジェクト: skumlos/relayserver
bool Filesystem::deleteDirectory(std::string path) {
        DIR *dir;
        struct dirent *ent = NULL;
	struct dirent *entryp = NULL;

        if ((dir = opendir(path.c_str())) == NULL) {
                printf("Cannot open dir %s\n",path.c_str());
                return false;
        }

	int name_max = pathconf(path.c_str(), _PC_NAME_MAX);
	if (name_max == -1)         /* Limit not defined, or error */
		name_max = 255;         /* Take a guess */
	int len = offsetof(struct dirent, d_name) + name_max + 1;
	entryp = (struct dirent*)malloc(len);

        while (readdir_r(dir,entryp,&ent) == 0 && ent != NULL) {
                std::string entry( ent->d_name );
                if(entry == "." || entry == "..") continue;
                struct stat st;
                stat(std::string(path+"/"+ent->d_name).c_str(),&st);
                if(st.st_mode & S_IFDIR) {
                        deleteDirectory(std::string(path+"/"+ent->d_name));
                } else {
			remove(std::string(path+"/"+ent->d_name).c_str());
		}
        }

	free(entryp);

	closedir(dir);

	rmdir(path.c_str());

	return true;
}
コード例 #13
0
// Slow but should be ok...
bool AbstractRemoteConnection::moveDirectory(const QString &src, const QString &dest, bool recursive)
{
    bool result = copyDirectory(src, dest, true);
    deleteDirectory(src, recursive);
    return result;
}
コード例 #14
0
ファイル: recorder.cpp プロジェクト: crazyleen/upd-cam
void Recorder::avconvFinish(int num,QProcess::ExitStatus status) {
    qDebug() << "avconv exit with " << num << status;
    qDebug() << "record delete folder " << picDir;
    deleteDirectory(QFileInfo(picDir));
    emit convertFinish();
}
コード例 #15
0
int DirectoryMonitor::Server::read() {
	DWORD		dwBytesXFered = 0;
	ULONG_PTR	ulKey = 0;
	OVERLAPPED*	pOl;

	auto ret = GetQueuedCompletionStatus(m_hIOCP, &dwBytesXFered, &ulKey, &pOl, INFINITE);
	auto dwError = GetLastError();
	if (!ret) {
		if (!m_hIOCP) {
			// shutting down
			return 0;
		}

		if (dwError == WAIT_TIMEOUT) {
			//harmless
			return 1;
		}
	}

	{
		WLock l(cs);
		auto mon = find_if(monitors | map_values, [ulKey](const Monitor* m) { return (ULONG_PTR)m->key == ulKey; });
		if (mon.base() != monitors.end()) {
			if (!(*mon)->m_hDirectory) {
				//this is going to be deleted
				deleteDirectory(mon.base());
				return 1;
			}

			try {
				if ((dwError != 0 && dwError != ERROR_INVALID_PARAMETER) || !ret) {
					// Too many changes to track, http://blogs.msdn.com/b/oldnewthing/archive/2011/08/12/10195186.aspx
					// The documentation only states the code ERROR_NOTIFY_ENUM_DIR for this, but according to the testing ERROR_NOT_ENOUGH_QUOTA and ERROR_ALREADY_EXISTS seem to be used instead....
					// (and ERROR_TOO_MANY_CMDS with network drives)
					if (dwError == ERROR_NOTIFY_ENUM_DIR || dwError == ERROR_NOT_ENOUGH_QUOTA || dwError == ERROR_ALREADY_EXISTS || dwError == ERROR_TOO_MANY_CMDS) {
						(*mon)->beginRead();
						auto monBase = (*mon)->server->base;
						monBase->callAsync([=] { monBase->fire(DirectoryMonitorListener::Overflow(), (*mon)->path); });
					} else {
						throw MonitorException(getErrorStr(dwError));
					}
				} else {
					if ((*mon)->errorCount > 0) {
						(*mon)->errorCount = 0;
					}

					if (dwBytesXFered > 0) {
						(*mon)->changes++;
						(*mon)->queueNotificationTask(dwBytesXFered);
					} /*else {
						LogManager::getInstance()->message("An empty notification was received when monitoring " + Text::fromT((*mon)->path) + " (report this)", LogMessage::SEV_WARNING);
					}*/

					(*mon)->beginRead();
				}
			} catch (const MonitorException& e) {
				(*mon)->errorCount++;
				if ((*mon)->errorCount < 60) {
					//we'll most likely get the error instantly again...
					Thread::sleep(1000);

					try {
						(*mon)->openDirectory(m_hIOCP);
						(*mon)->beginRead();
						return 1;
					} catch (const MonitorException& /*e*/) {
						//go to removal
					}
				}

				failDirectory((*mon)->path, e.getError());
			}
		}
	}

	return 1;
}
コード例 #16
0
ファイル: invocation.cpp プロジェクト: agul/atester
void Invocation::clearEnvironment() {
	if (!deleteDirectory(params->getInvocationDirectory(), false)) error("Cannot delete working directory");
	environmentCreated = false;
}