[vlc-commits] vlc_fopen: fix append mode

Rémi Denis-Courmont git at videolan.org
Thu Nov 3 19:03:22 CET 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Nov  3 19:24:14 2011 +0200| [7834663b7d9cae22164b035b51a72603c425e4fe] | committer: Rémi Denis-Courmont

vlc_fopen: fix append mode

In append mode, all write operations must occur at the end of the file.
Nevertheless the initial read offset is the beginning of the file.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7834663b7d9cae22164b035b51a72603c425e4fe
---

 src/text/filesystem.c |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)

diff --git a/src/text/filesystem.c b/src/text/filesystem.c
index 21d58dd..2e5f26e 100644
--- a/src/text/filesystem.c
+++ b/src/text/filesystem.c
@@ -51,7 +51,6 @@
 FILE *vlc_fopen (const char *filename, const char *mode)
 {
     int rwflags = 0, oflags = 0;
-    bool append = false;
 
     for (const char *ptr = mode; *ptr; ptr++)
     {
@@ -63,8 +62,7 @@ FILE *vlc_fopen (const char *filename, const char *mode)
 
             case 'a':
                 rwflags = O_WRONLY;
-                oflags |= O_CREAT;
-                append = true;
+                oflags |= O_CREAT | O_APPEND;
                 break;
 
             case 'w':
@@ -92,12 +90,6 @@ FILE *vlc_fopen (const char *filename, const char *mode)
     if (fd == -1)
         return NULL;
 
-    if (append && (lseek (fd, 0, SEEK_END) == -1))
-    {
-        close (fd);
-        return NULL;
-    }
-
     FILE *stream = fdopen (fd, mode);
     if (stream == NULL)
         close (fd);



More information about the vlc-commits mailing list