From 603dee7e51c02b5fdf340fada903e3e7aab4899e Mon Sep 17 00:00:00 2001 From: Jorg Schuler Date: Sat, 24 Jun 2006 11:09:53 +0000 Subject: * src/itdb_itunesdb.c src/itdb.h: Added itdb_get_itunessd_path (). itdb_init_ipod() will no longer overwrite existing iTunesDB and iTunesSD. git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1304 f01d2545-417e-4e96-918e-98f8d0dbbcb6 --- src/itdb.h | 3 ++- src/itdb_itunesdb.c | 54 +++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 48 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/itdb.h b/src/itdb.h index e914ca0..68f8eca 100644 --- a/src/itdb.h +++ b/src/itdb.h @@ -1,4 +1,4 @@ -/* Time-stamp: <2006-06-07 00:56:08 jcs> +/* Time-stamp: <2006-06-24 19:52:24 jcs> | | Copyright (C) 2002-2005 Jorg Schuler | Part of the gtkpod project. @@ -853,6 +853,7 @@ gchar *itdb_get_photos_dir (const gchar *mountpoint); gchar *itdb_get_photos_thumb_dir (const gchar *mountpoint); gchar *itdb_get_device_dir (const gchar *mountpoint); gchar *itdb_get_itunesdb_path (const gchar *mountpoint); +gchar *itdb_get_itunessd_path (const gchar *mountpoint); gchar *itdb_get_artworkdb_path (const gchar *mountpoint); gchar *itdb_get_photodb_path (const gchar *mountpoint); gchar *itdb_get_path (const gchar *dir, const gchar *file); diff --git a/src/itdb_itunesdb.c b/src/itdb_itunesdb.c index 43f7ca6..b4b0ac3 100644 --- a/src/itdb_itunesdb.c +++ b/src/itdb_itunesdb.c @@ -1,4 +1,4 @@ -/* Time-stamp: <2006-06-08 00:35:09 jcs> +/* Time-stamp: <2006-06-24 19:52:24 jcs> | | Copyright (C) 2002-2005 Jorg Schuler | Part of the gtkpod project. @@ -4496,7 +4496,7 @@ gboolean itdb_shuffle_write (Itdb_iTunesDB *itdb, GError **error) * @filename: file to write to, cannot be NULL * @error: return location for a #GError or NULL * - * Do the actual writing to the iTuneSsD + * Do the actual writing to the iTunesSD * * Return value: TRUE on success, FALSE on error, in which case @error is * set accordingly. @@ -5352,6 +5352,32 @@ gchar *itdb_get_itunesdb_path (const gchar *mountpoint) return path; } +/** + * itdb_get_itunessd_path: + * @mountpoint: the iPod mountpoint + * + * Retrieve a path to the iTunesSD + * + * Return value: path to the iTunesSD or NULL if non-existent. Must g_free() + * after use. + **/ +gchar *itdb_get_itunessd_path (const gchar *mountpoint) +{ + gchar *itunes_dir, *path=NULL; + + g_return_val_if_fail (mountpoint, NULL); + + itunes_dir = itdb_get_itunes_dir (mountpoint); + + if (itunes_dir) + { + path = itdb_get_path (itunes_dir, "iTunesSD"); + g_free (itunes_dir); + } + + return path; +} + /** * itdb_get_artworkdb_path: * @mountpoint: the iPod mountpoint @@ -5460,6 +5486,7 @@ gboolean itdb_init_ipod (const gchar *mountpoint, gboolean writeok; Itdb_iTunesDB *itdb = NULL; Itdb_Playlist *mpl = NULL; + gchar *path; g_return_val_if_fail (mountpoint, FALSE); @@ -5504,20 +5531,31 @@ gboolean itdb_init_ipod (const gchar *mountpoint, itdb_playlist_set_mpl(mpl); itdb_playlist_add(itdb, mpl, -1); - /* Write both the iTunesDB and iTunesSD files to the new ipod */ - writeok = itdb_write(itdb, error); - if(! writeok) + /* Write both the iTunesDB and iTunesSD files to the new ipod, + * unless they already exist */ + path = itdb_get_itunesdb_path (mountpoint); + if (!path) { + writeok = itdb_write(itdb, error); + if(! writeok) + { itdb_free (itdb); return FALSE; + } } - - writeok = itdb_shuffle_write(itdb, error); - if(! writeok) + g_free (path); + + path = itdb_get_itunessd_path (mountpoint); + if (!path) { + writeok = itdb_shuffle_write(itdb, error); + if(! writeok) + { itdb_free (itdb); return FALSE; + } } + g_free (path); itdb_free (itdb); return TRUE; -- cgit