]> git.sesse.net Git - vlc/blobdiff - src/text/filesystem.c
vlc_es.h: remove useless vlc_common.h include
[vlc] / src / text / filesystem.c
index 6bec646b46bc891f03a9d0614706843b0e80764a..6aa499d15976f64b951b38d3cbb923ef931cfcb6 100644 (file)
@@ -91,14 +91,18 @@ static int convert_path (const char *restrict path, wchar_t *restrict wpath)
  */
 int utf8_open (const char *filename, int flags, ...)
 {
-    mode_t mode = 0;
+    unsigned int mode = 0;
     va_list ap;
 
     va_start (ap, flags);
     if (flags & O_CREAT)
-        mode = va_arg (ap, mode_t);
+        mode = va_arg (ap, unsigned int);
     va_end (ap);
 
+#ifdef O_CLOEXEC
+    flags |= O_CLOEXEC;
+#endif
+
 #ifdef UNDER_CE
     /*_open translates to wchar internally on WinCE*/
     return _open (filename, flags, mode);
@@ -119,22 +123,11 @@ int utf8_open (const char *filename, int flags, ...)
         return -1;
     }
 
-    int fd;
-
-#ifdef O_CLOEXEC
-    fd = open (local_name, flags | O_CLOEXEC, mode);
-    if (fd == -1 && errno == EINVAL)
-#endif
-    {
-        fd = open (local_name, flags, mode);
+    int fd = open (local_name, flags, mode);
 #ifdef HAVE_FCNTL
-        if (fd != -1)
-        {
-            int flags = fcntl (fd, F_GETFD);
-            fcntl (fd, F_SETFD, FD_CLOEXEC | ((flags != -1) ? flags : 0));
-        }
+    if (fd != -1)
+        fcntl (fd, F_SETFD, FD_CLOEXEC);
 #endif
-    }
 
     LocaleFree (local_name);
     return fd;