[vlc-devel] "file://localhost/" handling in input.c on win32

Michael A. Puls II shadow2531 at gmail.com
Mon Aug 22 06:06:55 CEST 2011


If Opera passes a file URI to vlc like this:

vlc.exe file://localhost/test.mp3

, vlc reports:

File reading failed:
VLC could not open the file "\\localhost\c:\test.mp3".
Your input can't be opened:
VLC is unable to open the MRL 'file://localhost/c:/test.mp3'. Check the
log for details.


In src/input/input.c, there's the following code for handling
"file://localhost/", but it looks like it's not defined for Win32.

----------
       /* FIXME: file:// handling plugins do not support URIs properly...
        * So we pre-decode the URI to a path for them. Note that we do not  
do
it
        * for non-standard VLC-specific schemes. */
       if( !strcmp( psz_access, "file" ) )
       {
           if( psz_path[0] != '/' )
#ifndef WIN32
           {   /* host specified -> only localhost is supported */
               static const size_t i_localhost = sizeof("localhost")-1;
               if( strncmp( psz_path, "localhost/", i_localhost + 1) != 0 )
               {
                   msg_Err( p_input, "cannot open remote file `%s://%s'",
                            psz_access, psz_path );
                   msg_Info( p_input, "Did you mean `%s:///%s'?",
                             psz_access, psz_path );
                   goto error;
               }
               psz_path += i_localhost;
           }
#else
           {
               /* XXX: very very ugly. Always true for valid URIs though. */
               if( (psz_path - psz_dup) >= 2 && psz_path[-2] && psz_path[-1]
)
               {
                   *(--psz_path) = '\\';
                   *(--psz_path) = '\\';
               }
           }
           else
               /* Strip leading slash in front of the drive letter */
               psz_path++;
#endif
           /* Then URI-decode the path. */
           decode_URI( psz_path );
#if (DIR_SEP_CHAR != '/')
           /* Turn slashes into anti-slashes */
           for( char *s = strchr( psz_path, '/' ); s; s = strchr( s + 1, '/'
) )
               *s = DIR_SEP_CHAR;
#endif
       }
----------

-- 
Michael



More information about the vlc-devel mailing list