]> git.sesse.net Git - vlc/blobdiff - modules/access/file.c
channels.conf demux: parse symbol-rate from playlist
[vlc] / modules / access / file.c
index 10dc7a866ee0fda3d1fdd3b2d82626a267e03f80..eefa2a2590a81e592d77ceb1193883eb4b4fe46c 100644 (file)
@@ -48,7 +48,7 @@
 #   include <fcntl.h>
 #endif
 
-#if defined( WIN32 ) && !defined( UNDER_CE )
+#if defined( WIN32 )
 #   include <io.h>
 #   include <ctype.h>
 #else
 #   endif
 #   define lseek _lseeki64
 #elif defined( UNDER_CE )
-#   ifdef read
-#      undef read
-#   endif
-#   define read(a,b,c) fread(b,1,c,a)
-#   define close(a) fclose(a)
-#   ifdef lseek
-#      undef lseek
-#   endif
-#   define lseek fseek
+/* FIXME the commandline on wince is a mess */
+# define dup(a) -1
 #endif
 
 #include <vlc_charset.h>
@@ -86,18 +79,18 @@ static void Close( vlc_object_t * );
     "Caching value for files. This " \
     "value should be set in milliseconds." )
 
-vlc_module_begin();
-    set_description( N_("File input") );
-    set_shortname( N_("File") );
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_ACCESS );
-    add_integer( "file-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, true );
-    add_obsolete_string( "file-cat" );
-    set_capability( "access", 50 );
-    add_shortcut( "file" );
-    add_shortcut( "stream" );
-    set_callbacks( Open, Close );
-vlc_module_end();
+vlc_module_begin ()
+    set_description( N_("File input") )
+    set_shortname( N_("File") )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACCESS )
+    add_integer( "file-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, true )
+    add_obsolete_string( "file-cat" )
+    set_capability( "access", 50 )
+    add_shortcut( "file" )
+    add_shortcut( "stream" )
+    set_callbacks( Open, Close )
+vlc_module_end ()
 
 
 /*****************************************************************************
@@ -223,7 +216,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
 #else
     i_ret = read (fd, p_buffer, i_len);
 #endif
-    
+
     if( i_ret < 0 )
     {
         switch (errno)
@@ -241,7 +234,7 @@ static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
     }
     else if( i_ret > 0 )
         p_access->info.i_pos += i_ret;
-    else if( i_ret == 0 )
+    else
         p_access->info.b_eof = true;
 
     p_sys->i_nb_reads++;
@@ -348,21 +341,6 @@ static int open_file (access_t *p_access, const char *path)
         path++;
 #endif
 
-#ifdef UNDER_CE
-    p_sys->fd = utf8_fopen( path, "rb" );
-    if ( !p_sys->fd )
-    {
-        msg_Err( p_access, "cannot open file %s", path );
-        intf_UserFatal( p_access, false, _("File reading failed"),
-                        _("VLC could not open the file \"%s\"."), path );
-        return VLC_EGENERIC;
-    }
-
-    fseek( p_sys->fd, 0, SEEK_END );
-    p_access->info.i_size = ftell( p_sys->fd );
-    p_access->info.i_update |= INPUT_UPDATE_SIZE;
-    fseek( p_sys->fd, 0, SEEK_SET );
-#else
     int fd = utf8_open (path, O_RDONLY | O_NONBLOCK /* O_LARGEFILE*/, 0666);
     if (fd == -1)
     {
@@ -372,10 +350,15 @@ static int open_file (access_t *p_access, const char *path)
         return -1;
     }
 
-# if defined(HAVE_FCNTL_H) && defined(F_FDAHEAD) && defined(F_NOCACHE)
+#if defined(HAVE_FCNTL)
+    fcntl (fd, F_SETFD, fcntl (fd, F_GETFD) | FD_CLOEXEC);
+
     /* We'd rather use any available memory for reading ahead
      * than for caching what we've already seen/heard */
+# if defined(F_RDAHEAD)
     fcntl (fd, F_RDAHEAD, 1);
+# endif
+# if defined(F_NOCACHE)
     fcntl (fd, F_NOCACHE, 1);
 # endif
 #endif