コード例 #1
0
void _path_remove_recursive(const Glib::RefPtr<Gio::File> & dir)
{
    Glib::RefPtr<Gio::FileEnumerator> enumerator = dir->enumerate_children();
    Glib::RefPtr<Gio::FileInfo> file_info;
    while(file_info = enumerator->next_file()) {
        Glib::RefPtr<Gio::File> child;
        child = dir->get_child(file_info->get_name());
        if(file_info->get_type() == Gio::FILE_TYPE_DIRECTORY) {
            _path_remove_recursive(child);
        }
        child->remove();
    }
}
コード例 #2
0
bool
StateBrush_Context::scan_directory(const String &path, int scan_sub_levels, std::set<String> &out_files)
{
	if (scan_sub_levels < 0) return false;
	Glib::RefPtr<Gio::File> directory = Gio::File::create_for_path(path);
	Glib::RefPtr<Gio::FileEnumerator> e;

	try
	{
		e = directory->enumerate_children();
	}
	catch(Gio::Error&) { return false; }
	catch(Glib::FileError&) { return false; }

	Glib::RefPtr<Gio::FileInfo> info;
	while((bool)(info = e->next_file()))
	{
		String filepath = FileSystem::fix_slashes(directory->get_child(info->get_name())->get_path());
		if (!scan_directory(filepath, scan_sub_levels-1, out_files))
			out_files.insert(filepath);
	}

	return true;
}