From: <jc...@us...> - 2006-06-24 11:10:01
|
Update of /cvsroot/gtkpod/libgpod/src In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv30508/src Modified Files: itdb.h itdb_itunesdb.c Log Message: * src/itdb_itunesdb.c src/itdb.h: Added itdb_get_itunessd_path (). itdb_init_ipod() will no longer overwrite existing iTunesDB and iTunesSD. Index: itdb.h =================================================================== RCS file: /cvsroot/gtkpod/libgpod/src/itdb.h,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- itdb.h 7 Jun 2006 15:41:50 -0000 1.38 +++ itdb.h 24 Jun 2006 11:09:52 -0000 1.39 @@ -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 <jcsjcs at users sourceforge net> | Part of the gtkpod project. @@ -853,6 +853,7 @@ 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); Index: itdb_itunesdb.c =================================================================== RCS file: /cvsroot/gtkpod/libgpod/src/itdb_itunesdb.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- itdb_itunesdb.c 7 Jun 2006 15:41:50 -0000 1.63 +++ itdb_itunesdb.c 24 Jun 2006 11:09:53 -0000 1.64 @@ -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 <jcsjcs at users sourceforge net> | Part of the gtkpod project. @@ -4496,7 +4496,7 @@ * @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. @@ -5353,6 +5353,32 @@ } /** + * 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 writeok; Itdb_iTunesDB *itdb = NULL; Itdb_Playlist *mpl = NULL; + gchar *path; g_return_val_if_fail (mountpoint, FALSE); @@ -5504,20 +5531,31 @@ 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; |