Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37381562
en ru br
Репозитории ALT
S:0.15.1b-alt10
5.1: 0.15.1b-alt6
4.1: 0.15.1b-alt5
4.0: 0.15.1b-alt5
3.0: 0.15.1b-alt4
www.altlinux.org/Changes

Группа :: Звук
Пакет: libid3tag

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: libid3tag-0.15.1b-file-write.patch
Скачать


diff -ur -x '*.lo' -x '*.o' -x config.h -x config.log libid3tag-0.15.1b/file.c libid3tag-0.15.1b-fixed/file.c
--- libid3tag-0.15.1b/file.c	2004-01-23 12:41:32.000000000 +0300
+++ libid3tag-0.15.1b-fixed/file.c	2005-05-24 23:34:08.000000000 +0400
@@ -37,6 +37,10 @@
 #  include <assert.h>
 # endif
 
+# ifdef HAVE_SYS_STAT_H
+#  include <sys/stat.h>
+# endif
+
 # include "id3tag.h"
 # include "file.h"
 # include "tag.h"
@@ -575,6 +579,10 @@
 int v2_write(struct id3_file *file,
 	     id3_byte_t const *data, id3_length_t length)
 {
+  struct stat st;
+  char *buffer;
+  id3_length_t datalen, offset;
+  
   assert(!data || length > 0);
 
   if (data &&
@@ -592,9 +600,25 @@
   }
 
   /* hard general case: rewrite entire file */
+  if (stat(file->path, &st) == -1)
+    return -1;
 
-  /* ... */
+  offset = file->tags ? file->tags[0].length : 0;
+  datalen = st.st_size - offset;
+  if ((buffer = (char *) malloc(datalen)) == NULL)
+    return -1;
 
+  if (fseek(file->iofile, offset, SEEK_SET) == -1 ||
+      fread(buffer, datalen, 1, file->iofile) != 1 ||
+      fseek(file->iofile, 0, SEEK_SET) == -1 ||
+      fwrite(data, length, 1, file->iofile) != 1 ||
+      fwrite(buffer, datalen, 1, file->iofile) != 1 ||
+      fflush(file->iofile) == EOF) {
+    free(buffer);
+    return -1;
+  }
+  free(buffer);
+  
  done:
   return 0;
 }
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin