[gnome-commander] Add util functions...



commit 85bbe93a60c84f23a4dd77c8cb9d1875f3f9dd8c
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Mon Mar 4 21:04:16 2019 +0100

    Add util functions...
    
    1) get_package_config_dir for getting the config directory
    2) move_old_to_new_location for moving file or folder from old to new path

 src/utils.cc | 17 +++++++++++++++++
 src/utils.h  |  4 ++++
 2 files changed, 21 insertions(+)
---
diff --git a/src/utils.cc b/src/utils.cc
index 0a4f78a4..18282e11 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -1235,3 +1235,20 @@ gint get_string_pixel_size (const char *s, int len)
 
     return xSize;
 }
+
+
+gboolean move_old_to_new_location(const gchar* oldPath, const gchar* newPath)
+{
+    if (rename(oldPath, newPath) == 0)
+    {
+        return TRUE;
+    }
+    g_warning (_("Couldn’t move path from \"%s\" to \"%s\": %s"), oldPath, newPath, strerror (errno));
+
+    return FALSE;
+}
+
+gchar* get_package_config_dir()
+{
+    return g_build_filename (g_get_user_config_dir(), PACKAGE, NULL);
+}
\ No newline at end of file
diff --git a/src/utils.h b/src/utils.h
index d483d935..8d404fe7 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -414,3 +414,7 @@ inline std::string join(const COLL<T, Compare, Allocator> &coll, const std::stri
 }
 
 gint get_string_pixel_size (const char *s, int len);
+
+gboolean move_old_to_new_location(const gchar* oldPath, const gchar* newPath);
+
+gchar* get_package_config_dir();
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]