/*****************************************************************************
* 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.
*****************************************************************************/
/*****************************************************************************
FILE *vlc_fopen (const char *filename, const char *mode)
{
int rwflags = 0, oflags = 0;
- bool append = false;
for (const char *ptr = mode; *ptr; ptr++)
{
case 'a':
rwflags = O_WRONLY;
- oflags |= O_CREAT;
- append = true;
+ oflags |= O_CREAT | O_APPEND;
break;
case 'w':
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;
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);