From bba246f83a4e3825974b4e06c8671dc866d8a31b Mon Sep 17 00:00:00 2001 From: Jorg Schuler Date: Sun, 6 May 2007 15:00:03 +0000 Subject: * src/itdb_itunesdb.c src/itdb_device.c src/itdb_private.h src/itdb.h: New API functions to facilitate copying to the iPod in a background thread and implementation of own copying code. itdb_cp_get_dest_filename(): obtain a valid filename on the iPod to where a track can be copied. This function can be used in a thread-safe way. itdb_cp_finalize(): to be called after the track was copied to the iPod to update some fields in the Itdb_Track structure. This function can also be used in a thread-safe way. You can use the already existing function itdb_cp() to copy a track to the iPod and itdb_cp_track_to_ipod() remains available unchanged in functionality. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1426 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- src/itdb_device.c | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) (limited to 'src/itdb_device.c') diff --git a/src/itdb_device.c b/src/itdb_device.c index 8c5b9fb..cbff36e 100644 --- a/src/itdb_device.c +++ b/src/itdb_device.c @@ -31,6 +31,7 @@ */ #include "itdb_device.h" +#include "itdb_private.h" #include #include #include @@ -573,6 +574,36 @@ itdb_device_get_artwork_formats (Itdb_Device *device) } + +/* Determine the number of F.. directories in iPod_Control/Music.*/ +G_GNUC_INTERNAL gint +itdb_musicdirs_number_by_mountpoint (const gchar *mountpoint) +{ + gint dir_num; + gchar *music_dir = itdb_get_music_dir (mountpoint); + + if (!music_dir) return 0; + + /* count number of dirs */ + for (dir_num=0; ;++dir_num) + { + gchar *dir_filename; + gchar dir_num_str[6]; + + g_snprintf (dir_num_str, 6, "F%02d", dir_num); + + dir_filename = itdb_get_path (music_dir, dir_num_str); + + g_free (dir_filename); + if (!dir_filename) break; + } + + g_free (music_dir); + + return dir_num; +} + + /* Determine the number of F.. directories in iPod_Control/Music. If device->musicdirs is already set, simply return the previously @@ -581,29 +612,11 @@ itdb_device_get_artwork_formats (Itdb_Device *device) G_GNUC_INTERNAL gint itdb_device_musicdirs_number (Itdb_Device *device) { - gchar *dir_filename = NULL; - gint dir_num; - g_return_val_if_fail (device, 0); if (device->musicdirs <= 0) { - gchar *music_dir = itdb_get_music_dir (device->mountpoint); - if (!music_dir) return 0; - /* count number of dirs */ - for (dir_num=0; ;++dir_num) - { - gchar dir_num_str[5]; - - g_snprintf (dir_num_str, 5, "F%02d", dir_num); - - dir_filename = itdb_get_path (music_dir, dir_num_str); - - if (!dir_filename) break; - g_free (dir_filename); - } - device->musicdirs = dir_num; - g_free (music_dir); + device->musicdirs = itdb_musicdirs_number_by_mountpoint (device->mountpoint); } return device->musicdirs; } -- cgit