]> git.sesse.net Git - vlc/blobdiff - modules/access/file.c
Removes trailing spaces. Removes tabs.
[vlc] / modules / access / file.c
index 4d4b667cafc35c10803cf812011cf7ecedd651a9..01aa0e28a177ff2b2123070c07c1a0b3842d252b 100644 (file)
  * Preamble
  *****************************************************************************/
 #include <vlc/vlc.h>
-#include <vlc/input.h>
-#include <vlc_interaction.h>
+#include <vlc_input.h>
+#include <vlc_access.h>
+#include <vlc_interface.h>
 
-#include <stdlib.h>
-#include <string.h>
 #include <errno.h>
 #ifdef HAVE_SYS_TYPES_H
 #   include <sys/types.h>
@@ -51,8 +50,6 @@
 #endif
 
 #if defined( WIN32 ) && !defined( UNDER_CE )
-/* fstat() support for large files on win32 */
-#   define fstat(a,b) _fstati64(a,b)
 #   ifdef lseek
 #      undef lseek
 #   endif
@@ -69,7 +66,7 @@
 #   define lseek fseek
 #endif
 
-#include "charset.h"
+#include <vlc_charset.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -92,7 +89,7 @@ vlc_module_begin();
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_ACCESS );
     add_integer( "file-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
-    add_deprecated( "file-cat", VLC_TRUE );
+    add_obsolete_string( "file-cat" );
     set_capability( "access2", 50 );
     add_shortcut( "file" );
     add_shortcut( "stream" );
@@ -198,6 +195,7 @@ static int Open( vlc_object_t *p_this )
         p_sys->b_seekable = VLC_FALSE;
 #else
     p_sys->b_seekable = !b_stdin;
+# warning File size not known!
 #endif
 
     if (p_sys->b_seekable && (p_access->info.i_size == 0))
@@ -320,24 +318,22 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
  *****************************************************************************/
 static int Seek (access_t *p_access, int64_t i_pos)
 {
-    access_sys_t *p_sys = p_access->p_sys;
-
-    if (p_access->info.i_size < p_access->info.i_pos)
+    if (i_pos > p_access->info.i_size)
     {
         msg_Err (p_access, "seeking too far");
-        i_pos = p_access->info.i_pos = p_access->info.i_size;
+        i_pos = p_access->info.i_size;
     }
-    else if (p_access->info.i_pos < 0)
+    else if (i_pos < 0)
     {
         msg_Err (p_access, "seeking too early");
-        i_pos = p_access->info.i_pos = 0;
+        i_pos = 0;
     }
 
     p_access->info.i_pos = i_pos;
     p_access->info.b_eof = VLC_FALSE;
 
     /* Determine which file we need to access */
-    lseek (p_sys->fd, i_pos, SEEK_SET);
+    lseek (p_access->p_sys->fd, i_pos, SEEK_SET);
     return VLC_SUCCESS;
 }
 
@@ -434,7 +430,7 @@ static int open_file (access_t *p_access, const char *psz_name)
     if ( !p_sys->fd )
     {
         msg_Err( p_access, "cannot open file %s", psz_name );
-        intf_UserFatal( p_access, VLC_FALSE, _("File reading failed"), 
+        intf_UserFatal( p_access, VLC_FALSE, _("File reading failed"),
                         _("VLC could not open file \"%s\"."), psz_name );
         free (path);
         return VLC_EGENERIC;
@@ -445,24 +441,13 @@ static int open_file (access_t *p_access, const char *psz_name)
     p_access->info.i_update |= INPUT_UPDATE_SIZE;
     fseek( p_sys->fd, 0, SEEK_SET );
 #else
-    const char *psz_localname = ToLocale (path);
-    if (psz_localname == NULL)
-    {
-        msg_Err (p_access, "incorrect file name %s", psz_name);
-        free (path);
-        return -1;
-    }
-
-    // FIXME: support non-ANSI filenames on Win32
-    int fd = open (path, O_NONBLOCK /*| O_LARGEFILE*/);
-    LocaleFree (psz_localname);
+    int fd = utf8_open (path, O_RDONLY | O_NONBLOCK /* O_LARGEFILE*/, 0666);
     free (path);
-
     if (fd == -1)
     {
         msg_Err (p_access, "cannot open file %s (%s)", psz_name,
                  strerror (errno));
-        intf_UserFatal (p_access, VLC_FALSE, _("File reading failed"), 
+        intf_UserFatal (p_access, VLC_FALSE, _("File reading failed"),
                         _("VLC could not open file \"%s\" (%s)."),
                         psz_name, strerror (errno));
         return -1;