summaryrefslogtreecommitdiff
path: root/src/gallery-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallery-utils.c')
-rw-r--r--src/gallery-utils.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gallery-utils.c b/src/gallery-utils.c
index 3caff02..d97cef3 100644
--- a/src/gallery-utils.c
+++ b/src/gallery-utils.c
@@ -154,6 +154,41 @@ copy_file (const gchar *src, const gchar *dst)
return TRUE;
}
+/*
+ * copy_file_dir: recursively copy file or directory from src to dst
+ */
+gboolean
+copy_file_dir (const gchar *src, const gchar *dst)
+{
+ int n;
+ struct dirent **namelist;
+ char *new_src, *new_dst;
+
+ if (g_file_test (src, G_FILE_TEST_IS_DIR)) {
+ if (g_mkdir_with_parents (dst, DEFAULT_DATA_DIR_MODE)) {
+ log_error ("error making target directory '%s': %s\n", dst, strerror (errno));
+ return FALSE;
+ }
+ n = scandir (src, &namelist, NULL, NULL);
+ if (n < 0) {
+ log_error ("error listing source directory '%s': %s\n", src, strerror (errno));
+ return FALSE;
+ }
+ while (n--) {
+ if (g_strcmp0 (".", namelist[n]->d_name) != 0 && g_strcmp0 ("..", namelist[n]->d_name) != 0) {
+ new_src = g_build_filename (src, namelist[n]->d_name, NULL);
+ new_dst = g_build_filename (dst, namelist[n]->d_name, NULL);
+ copy_file_dir (new_src, new_dst);
+ g_free (new_src);
+ g_free (new_dst);
+ }
+ free (namelist[n]);
+ }
+ free (namelist);
+ return TRUE;
+ } else return copy_file (src, dst);
+}
+
/*
* make_string: make string of 'substr' substrings