Commit 7834663b authored by Rémi Denis-Courmont's avatar 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.
parent 19cc40ec
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
FILE *vlc_fopen (const char *filename, const char *mode) FILE *vlc_fopen (const char *filename, const char *mode)
{ {
int rwflags = 0, oflags = 0; int rwflags = 0, oflags = 0;
bool append = false;
for (const char *ptr = mode; *ptr; ptr++) for (const char *ptr = mode; *ptr; ptr++)
{ {
...@@ -63,8 +62,7 @@ FILE *vlc_fopen (const char *filename, const char *mode) ...@@ -63,8 +62,7 @@ FILE *vlc_fopen (const char *filename, const char *mode)
case 'a': case 'a':
rwflags = O_WRONLY; rwflags = O_WRONLY;
oflags |= O_CREAT; oflags |= O_CREAT | O_APPEND;
append = true;
break; break;
case 'w': case 'w':
...@@ -92,12 +90,6 @@ FILE *vlc_fopen (const char *filename, const char *mode) ...@@ -92,12 +90,6 @@ FILE *vlc_fopen (const char *filename, const char *mode)
if (fd == -1) if (fd == -1)
return NULL; return NULL;
if (append && (lseek (fd, 0, SEEK_END) == -1))
{
close (fd);
return NULL;
}
FILE *stream = fdopen (fd, mode); FILE *stream = fdopen (fd, mode);
if (stream == NULL) if (stream == NULL)
close (fd); close (fd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment