Revision: 2377
http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2377&view=rev
Author: phantom_sf
Date: 2009-08-02 16:36:58 +0000 (Sun, 02 Aug 2009)
Log Message:
-----------
* syncdir.c (sync_playlist):
Change to recurse into given sync directory's sub-directories for
files. Allows syncing of an hierarchical music directory layout.
Modified Paths:
--------------
gtkpod/trunk/src/syncdir.c
Modified: gtkpod/trunk/src/syncdir.c
===================================================================
--- gtkpod/trunk/src/syncdir.c 2009-08-01 08:53:42 UTC (rev 2376)
+++ gtkpod/trunk/src/syncdir.c 2009-08-02 16:36:58 UTC (rev 2377)
@@ -464,8 +464,53 @@
}
+/**
+ * cache_directory:
+ *
+ * Add the given directory to the given hash table then recurse into the
directory
+ * and add all its sub-directories.
+ *
+ * @dir: top-level directory to recurse into and store subdirectories
+ * @dirs_hash: pointer to a hash table that stores all directory paths
+ *
+ * Return value: none, dirs_hash stores all required paths
+ *
+ **/
+static void cache_directory (const gchar *dir, GHashTable *dirs_hash)
+{
+ GDir *dir_handle;
+ const gchar *filename;
+ gchar *path;
+ if (! g_file_test (dir, G_FILE_TEST_IS_DIR))
+ return;
+ /* dir represents a directory so store it in the hash table */
+ g_hash_table_insert(dirs_hash, g_strdup(dir), NULL);
+
+ dir_handle = g_dir_open (dir, 0, NULL);
+ if (dir_handle == NULL)
+ return;
+
+ /* Loop through the filenames in the directory */
+ while ((filename = g_dir_read_name(dir_handle)))
+ {
+ /* Construct absolute path from dir and filename */
+ path = g_build_filename(dir, filename);
+
+ /* If path is not directory then move on to next */
+ if (! g_file_test (path, G_FILE_TEST_IS_DIR))
+ continue;
+
+ /* recursively walk down into sub directory */
+ cache_directory (path, dirs_hash);
+ g_free (path);
+ }
+
+ g_dir_close(dir_handle);
+}
+
+
/**
* sync_playlist:
*
@@ -552,7 +597,7 @@
dir[len-1] = 0;
}
}
- g_hash_table_insert (dirs_hash, dir, NULL);
+ cache_directory (dir, dirs_hash);
}
else
{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2