]> git.sesse.net Git - vlc/blobdiff - modules/access/file.c
Change placholder to placeholder
[vlc] / modules / access / file.c
index 245fb9fe20c5d21146f4433ab309068ef155e274..5114f3881c669677b9433189d1b602bbe1c83b83 100644 (file)
@@ -58,6 +58,9 @@
 #   include <io.h>
 #   include <ctype.h>
 #   include <shlwapi.h>
+#   include <vlc_charset.h>
+#elif defined( __OS2__ )
+#   include <ctype.h>
 #else
 #   include <unistd.h>
 #endif
@@ -87,7 +90,7 @@ struct access_sys_t
     bool b_pace_control;
 };
 
-#ifndef WIN32
+#if !defined (WIN32) && !defined (__OS2__)
 static bool IsRemote (int fd)
 {
 #if defined (HAVE_FSTATVFS) && defined (MNT_LOCAL)
@@ -96,7 +99,7 @@ static bool IsRemote (int fd)
     if (fstatvfs (fd, &stf))
         return false;
     /* fstatvfs() is in POSIX, but MNT_LOCAL is not */
-    return !(s.f_flag & MNT_LOCAL);
+    return !(stf.f_flag & MNT_LOCAL);
 
 #elif defined (HAVE_LINUX_MAGIC_H)
     struct statfs stf;
@@ -104,7 +107,7 @@ static bool IsRemote (int fd)
     if (fstatfs (fd, &stf))
         return false;
 
-    switch (stf.f_type)
+    switch ((unsigned long)stf.f_type)
     {
         case AFS_SUPER_MAGIC:
         case CODA_SUPER_MAGIC:
@@ -134,7 +137,6 @@ static bool IsRemote (int fd)
 int Open( vlc_object_t *p_this )
 {
     access_t     *p_access = (access_t*)p_this;
-    const char   *path = p_access->psz_filepath;
 #ifdef WIN32
     bool is_remote = false;
 #endif
@@ -145,11 +147,11 @@ int Open( vlc_object_t *p_this )
     if (!strcasecmp (p_access->psz_access, "fd"))
     {
         char *end;
-        int oldfd = strtol (path, &end, 10);
+        int oldfd = strtol (p_access->psz_location, &end, 10);
 
         if (*end == '\0')
             fd = vlc_dup (oldfd);
-        else if (*end == '/' && end > path)
+        else if (*end == '/' && end > p_access->psz_location)
         {
             char *name = decode_URI_duplicate (end - 1);
             if (name != NULL)
@@ -162,6 +164,8 @@ int Open( vlc_object_t *p_this )
     }
     else
     {
+        const char *path = p_access->psz_filepath;
+
         msg_Dbg (p_access, "opening file `%s'", path);
         fd = vlc_open (path, O_RDONLY | O_NONBLOCK);
         if (fd == -1)
@@ -172,11 +176,10 @@ int Open( vlc_object_t *p_this )
         }
 
 #ifdef WIN32
-        wchar_t wpath[MAX_PATH+1];
-        if (MultiByteToWideChar (CP_UTF8, 0, path, -1,
-                                 wpath, MAX_PATH)
-         && PathIsNetworkPathW (wpath))
+        wchar_t *wpath = ToWide (path);
+        if (wpath != NULL && PathIsNetworkPathW (wpath))
             is_remote = true;
+        free (wpath);
 # define IsRemote( fd ) ((void)fd, is_remote)
 #endif
     }
@@ -215,9 +218,9 @@ int Open( vlc_object_t *p_this )
     p_access->p_sys = p_sys;
     p_sys->i_nb_reads = 0;
     p_sys->fd = fd;
-    p_sys->caching = var_CreateGetInteger (p_access, "file-caching");
+    p_sys->caching = var_InheritInteger (p_access, "file-caching");
     if (IsRemote(fd))
-        p_sys->caching += var_CreateGetInteger (p_access, "network-caching");
+        p_sys->caching += var_InheritInteger (p_access, "network-caching");
     p_sys->b_pace_control = true;
 
     if (S_ISREG (st.st_mode))
@@ -283,7 +286,7 @@ ssize_t FileRead( access_t *p_access, uint8_t *p_buffer, size_t i_len )
     int fd = p_sys->fd;
     ssize_t i_ret;
 
-#ifndef WIN32
+#if !defined (WIN32) && !defined (__OS2__)
     if (p_access->pf_seek == NoSeek)
         i_ret = net_Read (p_access, fd, NULL, p_buffer, i_len, false);
     else