changeset 2513:1e6d2d719876 trunk

[svn] - delete id3 tag feature has been added. - debug code in id3_render_paddedstring() which had prevented proper id3v1 rendering has been removed.
author yaz
date Tue, 13 Feb 2007 05:48:33 -0800
parents 3a1fc6f7c187
children 7934ac463591
files ChangeLog src/audacious/build_stamp.c src/libid3tag/file.c src/libid3tag/render.c
diffstat 4 files changed, 54 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Feb 12 14:26:29 2007 -0800
+++ b/ChangeLog	Tue Feb 13 05:48:33 2007 -0800
@@ -1,3 +1,11 @@
+2007-02-12 22:26:29 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [4034]
+  - unbreak relative path support. closes #791.
+  
+  trunk/src/audacious/main.c |   19 +++++++++++++++----
+  1 file changed, 15 insertions(+), 4 deletions(-)
+
+
 2007-02-12 20:51:11 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [4032]
   - add Catalan translation file. Closes #786.
--- a/src/audacious/build_stamp.c	Mon Feb 12 14:26:29 2007 -0800
+++ b/src/audacious/build_stamp.c	Tue Feb 13 05:48:33 2007 -0800
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070212-4032";
+const gchar *svn_stamp = "20070212-4034";
--- a/src/libid3tag/file.c	Mon Feb 12 14:26:29 2007 -0800
+++ b/src/libid3tag/file.c	Tue Feb 13 05:48:33 2007 -0800
@@ -349,7 +349,6 @@
 
   /* restore seek position */
 
-//  if (fsetpos(file->iofile, &save_position) == -1)
   if (vfs_fseek(file->iofile, save_position, SEEK_SET) == -1)
     return -1;
 
@@ -546,7 +545,7 @@
 int v1_write(struct id3_file *file,
 	     id3_byte_t const *data, id3_length_t length)
 {
-  assert(!data || length == 128);
+//  assert(!data || length == 128);
 
   if (data) {
     long location;
@@ -589,7 +588,6 @@
 	(length >= 0 && length < 128))
       return -1;
 
-//    if (ftruncate(fileno(file->iofile), length - 128) == -1) //XXX
     if (vfs_truncate(file->iofile, length - 128) == -1)
       return -1;
 
@@ -612,7 +610,45 @@
 int v2_write(struct id3_file *file,
 	     id3_byte_t const *data, id3_length_t length)
 {
-  assert(!data || length > 0);
+//  assert(!data || length > 0);
+
+    // delete tag request
+    if(!data && length == 0){
+        int file_size;
+        int remainder_size;
+        char *remainder;
+
+        /* read in the remainder of the file */
+        vfs_fseek(file->iofile, 0, SEEK_END);
+        file_size = vfs_ftell(file->iofile);
+        remainder_size = file_size - file->tags[0].location - file->tags[0].length;
+        remainder = (char*)malloc(remainder_size);
+
+        if (vfs_fseek(file->iofile, file->tags[0].location + file->tags[0].length, SEEK_SET) == -1 ||
+            vfs_fread(remainder, remainder_size, 1, file->iofile) != 1) {
+            free(remainder);
+            return -1;
+        }
+
+        /* write the remainder where the old tag was */
+        if (vfs_fseek(file->iofile, file->tags[0].location, SEEK_SET) == -1 ||
+            vfs_fwrite(remainder, remainder_size, 1, file->iofile) != 1) {
+            free(remainder);
+            return -1;
+        }
+
+        free(remainder);
+
+        /* flush the FILE */
+#ifndef AUDACIOUS
+        if (fflush(file->iofile) == EOF)
+            return -1;
+#endif
+        /* truncate if required */
+        if (vfs_ftell(file->iofile) < file_size)
+            vfs_truncate(file->iofile, vfs_ftell(file->iofile));
+
+    }
 
   // append a new id3v2 tag to the file which doesn't have any tag or only have v1tag.
   if(data &&
@@ -669,14 +705,14 @@
     remainder = (char*)malloc(remainder_size);
     if (vfs_fseek(file->iofile, file->tags[0].location + file->tags[0].length, SEEK_SET) == -1 ||
 	vfs_fread(remainder, remainder_size, 1, file->iofile) != 1) {
-      free(remainder);
+	    free(remainder);
       return -1;
     }
 
     /* write the tag where the old one was */
     if (vfs_fseek(file->iofile, file->tags[0].location, SEEK_SET) == -1 ||
 	vfs_fwrite(data, length, 1, file->iofile) != 1) {
-      free(remainder);
+	    free(remainder);
       return -1;
     }
 
@@ -753,7 +789,7 @@
 
   /* write tags */
 
-  if (v2_write(file, id3v2, v2size) == -1 ||
+  if (v2_write(file, id3v2, v2size) == -1 &&
       v1_write(file, id3v1, v1size) == -1)
     goto fail;
 
--- a/src/libid3tag/render.c	Mon Feb 12 14:26:29 2007 -0800
+++ b/src/libid3tag/render.c	Tue Feb 13 05:48:33 2007 -0800
@@ -116,7 +116,7 @@
   id3_length_t size;
 
   if (latin1 == 0)
-    latin1 = "";
+      latin1 = (id3_latin1_t *)"";
 
   size = id3_latin1_size(latin1);
   if (!terminate)
@@ -196,6 +196,5 @@
 
   *data = 0;
 
-  return length;
-//  return id3_latin1_serialize(ptr, padded, 0);
+  return id3_latin1_serialize(ptr, padded, 0);
 }