]> git.sesse.net Git - vlc/blobdiff - src/text/filesystem.c
flac decoder: supports avformat extradata
[vlc] / src / text / filesystem.c
index 21d58dde563f6df6be5618dc42a01e6ab1fa925a..f3eb1d7f4c05c68bdaa4f0af08090db5dd22c6eb 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * filesystem.c: Common file system helpers
  *****************************************************************************
- * Copyright (C) 2005-2006 the VideoLAN team
+ * Copyright (C) 2005-2006 VLC authors and VideoLAN
  * Copyright © 2005-2008 Rémi Denis-Courmont
  *
  * Authors: Rémi Denis-Courmont <rem # videolan.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -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':
@@ -72,11 +70,15 @@ FILE *vlc_fopen (const char *filename, const char *mode)
                 oflags |= O_CREAT | O_TRUNC;
                 break;
 
+            case 'x':
+                oflags |= O_EXCL;
+                break;
+
             case '+':
                 rwflags = O_RDWR;
                 break;
 
-#ifdef O_TEXT
+#ifdef O_BINARY
             case 'b':
                 oflags = (oflags & ~O_TEXT) | O_BINARY;
                 break;
@@ -92,12 +94,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);