[gnote] Replace std::string with Glib::ustring in directory
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Replace std::string with Glib::ustring in directory
- Date: Thu, 26 Jan 2017 21:40:11 +0000 (UTC)
commit dcbae793a5661620eea8a7759dbb873e9f201ba9
Author: Aurimas Černius <aurisc4 gmail com>
Date: Thu Jan 26 23:38:55 2017 +0200
Replace std::string with Glib::ustring in directory
src/addinmanager.cpp | 8 ++--
src/addins/bugzilla/bugzillapreferences.cpp | 7 +---
.../filesystemsyncserviceaddin.cpp | 6 ++--
src/addins/tomboyimport/tomboyimportaddin.cpp | 9 ++----
src/notemanager.cpp | 32 ++++++++------------
src/sharp/directory.cpp | 26 ++++++++--------
src/sharp/directory.hpp | 20 ++++++------
src/synchronization/filesystemsyncserver.cpp | 6 ++--
src/synchronization/fusesyncserviceaddin.cpp | 6 ++--
9 files changed, 54 insertions(+), 66 deletions(-)
---
diff --git a/src/addinmanager.cpp b/src/addinmanager.cpp
index 1b86248..8514aab 100644
--- a/src/addinmanager.cpp
+++ b/src/addinmanager.cpp
@@ -205,11 +205,11 @@ namespace {
void AddinManager::load_addin_infos(const std::string & path)
{
- std::list<std::string> files;
+ std::list<Glib::ustring> files;
sharp::directory_get_files_with_ext(path, ".desktop", files);
- for(std::list<std::string>::iterator iter = files.begin(); iter != files.end(); ++iter) {
+ for(auto file : files) {
try {
- AddinInfo addin_info(*iter);
+ AddinInfo addin_info(file);
if(!addin_info.validate(LIBGNOTE_RELEASE, LIBGNOTE_VERSION_INFO)) {
continue;
}
@@ -223,7 +223,7 @@ namespace {
}
}
catch(std::exception & e) {
- ERR_OUT(_("Failed to load addin info for %s: %s"), iter->c_str(), e.what());
+ ERR_OUT(_("Failed to load addin info for %s: %s"), file.c_str(), e.what());
}
}
}
diff --git a/src/addins/bugzilla/bugzillapreferences.cpp b/src/addins/bugzilla/bugzillapreferences.cpp
index 2a5eccc..992988d 100644
--- a/src/addins/bugzilla/bugzillapreferences.cpp
+++ b/src/addins/bugzilla/bugzillapreferences.cpp
@@ -140,12 +140,9 @@ namespace bugzilla {
icon_store->clear(); // clear out the old entries
- std::list<std::string> icon_files;
+ std::list<Glib::ustring> icon_files;
sharp::directory_get_files (s_image_dir, icon_files);
- for(std::list<std::string>::const_iterator iter = icon_files.begin();
- iter != icon_files.end(); ++iter) {
-
- const std::string & icon_file(*iter);
+ for(auto icon_file : icon_files) {
sharp::FileInfo file_info(icon_file);
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
diff --git a/src/addins/filesystemsyncservice/filesystemsyncserviceaddin.cpp
b/src/addins/filesystemsyncservice/filesystemsyncserviceaddin.cpp
index 83befc9..972b840 100644
--- a/src/addins/filesystemsyncservice/filesystemsyncserviceaddin.cpp
+++ b/src/addins/filesystemsyncservice/filesystemsyncserviceaddin.cpp
@@ -164,10 +164,10 @@ bool FileSystemSyncServiceAddin::save_configuration()
// Test ability to read
bool testFileFound = false;
- std::list<std::string> files;
+ std::list<Glib::ustring> files;
sharp::directory_get_files(syncPath, files);
- for(std::list<std::string>::iterator iter = files.begin(); iter != files.end(); ++iter) {
- if(*iter == testPath) {
+ for(auto file : files) {
+ if(file == testPath) {
testFileFound = true;
break;
}
diff --git a/src/addins/tomboyimport/tomboyimportaddin.cpp b/src/addins/tomboyimport/tomboyimportaddin.cpp
index 7aa66a2..e122c3b 100644
--- a/src/addins/tomboyimport/tomboyimportaddin.cpp
+++ b/src/addins/tomboyimport/tomboyimportaddin.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2011,2013-2014 Aurimas Cernius
+ * Copyright (C) 2010-2011,2013-2014,2017 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -71,13 +71,10 @@ bool TomboyImportAddin::first_run(gnote::NoteManager & manager)
DBG_OUT("import path is %s", m_tomboy_path.c_str());
if(sharp::directory_exists(m_tomboy_path)) {
- std::list<std::string> files;
+ std::list<Glib::ustring> files;
sharp::directory_get_files_with_ext(m_tomboy_path, ".note", files);
- for(std::list<std::string>::const_iterator iter = files.begin();
- iter != files.end(); ++iter) {
- const Glib::ustring & file_path(*iter);
-
+ for(auto file_path : files) {
to_import++;
gnote::NoteBase::Ptr note = manager.import_note(file_path);
diff --git a/src/notemanager.cpp b/src/notemanager.cpp
index 487a50a..276f14d 100644
--- a/src/notemanager.cpp
+++ b/src/notemanager.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2014 Aurimas Cernius
+ * Copyright (C) 2010-2014,2017 Aurimas Cernius
* Copyright (C) 2010 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -181,12 +181,10 @@ namespace gnote {
void NoteManager::load_notes()
{
- std::list<std::string> files;
+ std::list<Glib::ustring> files;
sharp::directory_get_files_with_ext(notes_dir(), ".note", files);
- for(std::list<std::string>::const_iterator iter = files.begin();
- iter != files.end(); ++iter) {
- const std::string & file_path(*iter);
+ for(auto file_path : files) {
try {
Note::Ptr note = Note::load(file_path, *this);
add_note(note);
@@ -231,35 +229,31 @@ namespace gnote {
void NoteManager::migrate_notes(const std::string & old_note_dir)
{
- std::list<std::string> files;
+ std::list<Glib::ustring> files;
sharp::directory_get_files_with_ext(old_note_dir, ".note", files);
- for (std::list<std::string>::const_iterator iter = files.begin();
- files.end() != iter; ++iter) {
- const Glib::RefPtr<Gio::File> src = Gio::File::create_for_path(
- *iter);
- const std::string dest_path
+ for(auto file : files) {
+ const Glib::RefPtr<Gio::File> src = Gio::File::create_for_path(file);
+ const Glib::ustring dest_path
= Glib::build_filename(notes_dir(),
- Glib::path_get_basename(*iter));
+ Glib::path_get_basename(file));
const Glib::RefPtr<Gio::File> dest = Gio::File::create_for_path(
dest_path);
src->copy(dest, Gio::FILE_COPY_NONE);
}
files.clear();
- const std::string old_backup_dir = Glib::build_filename(
+ const Glib::ustring old_backup_dir = Glib::build_filename(
old_note_dir,
"Backup");
sharp::directory_get_files_with_ext(old_backup_dir,
".note", files);
- for (std::list<std::string>::const_iterator iter = files.begin();
- files.end() != iter; ++iter) {
- const Glib::RefPtr<Gio::File> src = Gio::File::create_for_path(
- *iter);
- const std::string dest_path
+ for(auto file : files) {
+ const Glib::RefPtr<Gio::File> src = Gio::File::create_for_path(file);
+ const Glib::ustring dest_path
= Glib::build_filename(m_backup_dir,
- Glib::path_get_basename(*iter));
+ Glib::path_get_basename(file));
const Glib::RefPtr<Gio::File> dest = Gio::File::create_for_path(
dest_path);
src->copy(dest, Gio::FILE_COPY_NONE);
diff --git a/src/sharp/directory.cpp b/src/sharp/directory.cpp
index fa88f75..3f2ebe6 100644
--- a/src/sharp/directory.cpp
+++ b/src/sharp/directory.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2014 Aurimas Cernius
+ * Copyright (C) 2011-2014,2017 Aurimas Cernius
* Copyright (C) 2011 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -36,9 +36,9 @@
namespace sharp {
- void directory_get_files_with_ext(const std::string & dir,
- const std::string & ext,
- std::list<std::string> & list)
+ void directory_get_files_with_ext(const Glib::ustring & dir,
+ const Glib::ustring & ext,
+ std::list<Glib::ustring> & list)
{
if (!Glib::file_test(dir, Glib::FILE_TEST_EXISTS))
return;
@@ -49,7 +49,7 @@ namespace sharp {
Glib::Dir d(dir);
for (Glib::Dir::iterator itr = d.begin(); itr != d.end(); ++itr) {
- const std::string file(dir + "/" + *itr);
+ const Glib::ustring file(dir + "/" + *itr);
const sharp::FileInfo file_info(file);
const std::string & extension = file_info.get_extension();
@@ -60,8 +60,8 @@ namespace sharp {
}
}
- void directory_get_directories(const std::string & dir,
- std::list<std::string> & files)
+ void directory_get_directories(const Glib::ustring & dir,
+ std::list<Glib::ustring> & files)
{
if(!Glib::file_test(dir, Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_DIR)) {
return;
@@ -70,7 +70,7 @@ namespace sharp {
Glib::Dir d(dir);
for(Glib::Dir::iterator iter = d.begin(); iter != d.end(); ++iter) {
- const std::string file(dir + "/" + *iter);
+ const Glib::ustring file(dir + "/" + *iter);
if(Glib::file_test(file, Glib::FILE_TEST_IS_DIR)) {
files.push_back(file);
@@ -78,12 +78,12 @@ namespace sharp {
}
}
- void directory_get_files(const std::string & dir, std::list<std::string> & files)
+ void directory_get_files(const Glib::ustring & dir, std::list<Glib::ustring> & files)
{
directory_get_files_with_ext(dir, "", files);
}
- bool directory_exists(const std::string & dir)
+ bool directory_exists(const Glib::ustring & dir)
{
return Glib::file_test(dir, Glib::FILE_TEST_EXISTS) && Glib::file_test(dir, Glib::FILE_TEST_IS_DIR);
}
@@ -126,15 +126,15 @@ namespace sharp {
}
}
- bool directory_create(const std::string & dir)
+ bool directory_create(const Glib::ustring & dir)
{
return Gio::File::create_for_path(dir)->make_directory_with_parents();
}
- bool directory_delete(const std::string & dir, bool recursive)
+ bool directory_delete(const Glib::ustring & dir, bool recursive)
{
if(!recursive) {
- std::list<std::string> files;
+ std::list<Glib::ustring> files;
directory_get_files(dir, files);
if(files.size()) {
return false;
diff --git a/src/sharp/directory.hpp b/src/sharp/directory.hpp
index 34be03c..9570db5 100644
--- a/src/sharp/directory.hpp
+++ b/src/sharp/directory.hpp
@@ -40,17 +40,17 @@ namespace sharp {
* @param ext the extension. If empty, then all files are listed.
* @retval files the list of files
*/
- void directory_get_files_with_ext(const std::string & dir,
- const std::string & ext,
- std::list<std::string> & files);
+ void directory_get_files_with_ext(const Glib::ustring & dir,
+ const Glib::ustring & ext,
+ std::list<Glib::ustring> & files);
- void directory_get_directories(const std::string & dir,
- std::list<std::string> & files);
+ void directory_get_directories(const Glib::ustring & dir,
+ std::list<Glib::ustring> & files);
- void directory_get_files(const std::string & dir,
- std::list<std::string> & files);
+ void directory_get_files(const Glib::ustring & dir,
+ std::list<Glib::ustring> & files);
- bool directory_exists(const std::string & dir);
+ bool directory_exists(const Glib::ustring & dir);
/**
* @param src The source directory (or file)
@@ -60,9 +60,9 @@ namespace sharp {
const Glib::RefPtr<Gio::File> & dest)
throw(Gio::Error);
- bool directory_create(const std::string & dir);
+ bool directory_create(const Glib::ustring & dir);
- bool directory_delete(const std::string & dir, bool recursive);
+ bool directory_delete(const Glib::ustring & dir, bool recursive);
}
diff --git a/src/synchronization/filesystemsyncserver.cpp b/src/synchronization/filesystemsyncserver.cpp
index 7540775..b60b144 100644
--- a/src/synchronization/filesystemsyncserver.cpp
+++ b/src/synchronization/filesystemsyncserver.cpp
@@ -140,7 +140,7 @@ std::map<Glib::ustring, NoteUpdate> FileSystemSyncServer::get_note_updates_since
else {
// Empty the temp dir
try {
- std::list<std::string> files;
+ std::list<Glib::ustring> files;
sharp::directory_get_files(tempPath, files);
for(auto & iter : files) {
sharp::file_delete(iter);
@@ -349,7 +349,7 @@ bool FileSystemSyncServer::commit_sync_transaction()
if(sharp::file_exists(oldManifestFilePath)) {
// TODO: Do step #8 as described in http://bugzilla.gnome.org/show_bug.cgi?id=321037#c17
// Like this?
- std::list<std::string> files;
+ std::list<Glib::ustring> files;
sharp::directory_get_files(oldManifestFilePath, files);
for(auto & iter : files) {
Glib::ustring fileGuid = sharp::file_basename(iter);
@@ -406,7 +406,7 @@ int FileSystemSyncServer::latest_revision()
while (!foundValidManifest) {
if(latestRev < 0) {
// Look for the highest revision parent path
- std::list<std::string> directories;
+ std::list<Glib::ustring> directories;
sharp::directory_get_directories(m_server_path, directories);
for(auto & iter : directories) {
try {
diff --git a/src/synchronization/fusesyncserviceaddin.cpp b/src/synchronization/fusesyncserviceaddin.cpp
index 02ab9e7..3cbfb38 100644
--- a/src/synchronization/fusesyncserviceaddin.cpp
+++ b/src/synchronization/fusesyncserviceaddin.cpp
@@ -145,10 +145,10 @@ bool FuseSyncServiceAddin::save_configuration()
// Test ability to read
bool testFileFound = false;
- std::list<std::string> files;
+ std::list<Glib::ustring> files;
sharp::directory_get_files(m_mount_path, files);
- for(std::list<std::string>::iterator iter = files.begin(); iter != files.end(); ++iter) {
- if(*iter == testPath) {
+ for(auto file : files) {
+ if(file == testPath) {
testFileFound = true;
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]