[gnote] Add directory_get_directories that uses Gio::File
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Add directory_get_directories that uses Gio::File
- Date: Sat, 6 Apr 2019 16:58:02 +0000 (UTC)
commit fcfbe477aafc72cb38ebe78ea1d20c30bd086d5a
Author: Aurimas Černius <aurisc4 gmail com>
Date: Mon Jul 30 17:35:03 2018 +0300
Add directory_get_directories that uses Gio::File
src/sharp/directory.cpp | 25 +++++++++++++++++++++++++
src/sharp/directory.hpp | 5 ++++-
2 files changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/src/sharp/directory.cpp b/src/sharp/directory.cpp
index 5300e623..721f5434 100644
--- a/src/sharp/directory.cpp
+++ b/src/sharp/directory.cpp
@@ -28,6 +28,7 @@
#include <glib/gstdio.h>
#include <glibmm/fileutils.h>
+#include <glibmm/miscutils.h>
#include "sharp/directory.hpp"
#include "sharp/fileinfo.hpp"
@@ -78,6 +79,30 @@ namespace sharp {
}
}
+ void directory_get_directories(const Glib::RefPtr<Gio::File> & dir,
+ std::vector<Glib::RefPtr<Gio::File>> & files)
+ {
+ if(!dir || !dir->query_exists()) {
+ return;
+ }
+ auto info = dir->query_info();
+ if(!info || info->get_file_type() != Gio::FILE_TYPE_DIRECTORY) {
+ return;
+ }
+
+ auto children = dir->enumerate_children();
+ while(true) {
+ auto fileinfo = children->next_file();
+ if(!fileinfo) {
+ break;
+ }
+ if(fileinfo->get_file_type() & Gio::FILE_TYPE_DIRECTORY) {
+ auto child = Gio::File::create_for_uri(Glib::build_filename(dir->get_uri(), fileinfo->get_name()));
+ files.push_back(child);
+ }
+ }
+ }
+
void directory_get_files(const Glib::ustring & dir, std::list<Glib::ustring> & files)
{
directory_get_files_with_ext(dir, "", files);
diff --git a/src/sharp/directory.hpp b/src/sharp/directory.hpp
index 520af688..ce94356b 100644
--- a/src/sharp/directory.hpp
+++ b/src/sharp/directory.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2012,2017 Aurimas Cernius
+ * Copyright (C) 2012,2017-2018 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -30,6 +30,7 @@
#define __SHARP_DIRECTORY_HPP_
#include <list>
+#include <vector>
#include <giomm/file.h>
@@ -46,6 +47,8 @@ namespace sharp {
void directory_get_directories(const Glib::ustring & dir,
std::list<Glib::ustring> & files);
+ void directory_get_directories(const Glib::RefPtr<Gio::File> & dir,
+ std::vector<Glib::RefPtr<Gio::File>> & files);
void directory_get_files(const Glib::ustring & dir,
std::list<Glib::ustring> & files);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]