Commit 04fb7e89 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Namespace/rename make_path to vlc_uri2path

parent 7b331c54
......@@ -28,9 +28,34 @@
/**
* \file
* This file defines functions for manipulating URL in vlc
*
* \ingroup strings
* @{
*/
/**
* Converts local path to URL.
*
* Builds a URL representation from a local UTF-8 null-terminated file path.
*
* @param path file path
* @param scheme URI scheme to use (default is auto: "file", "fd" or "smb")
* @return a heap-allocated URI string on success
* or NULL in case of error (errno will be set accordingly)
*/
VLC_API char *vlc_path2uri(const char *path, const char *scheme) VLC_MALLOC;
VLC_API char *vlc_path2uri (const char *path, const char *scheme) VLC_MALLOC;
/**
* Converts a URI to a local path.
*
* Builds a local path (UTF-8-encoded null-terminated string) from a URI if
* the URI scheme allows.
*
* @param url URI
* @return a heap-allocated string or success
* or NULL on error
*/
VLC_API char *vlc_uri2path(const char *url) VLC_MALLOC;
struct vlc_url_t
{
......@@ -48,8 +73,10 @@ struct vlc_url_t
VLC_API char * decode_URI_duplicate( const char *psz ) VLC_MALLOC;
VLC_API char * decode_URI( char *psz );
VLC_API char * encode_URI_component( const char *psz ) VLC_MALLOC;
VLC_API char * make_path( const char *url ) VLC_MALLOC;
/** @} */
VLC_API void vlc_UrlParse (vlc_url_t *, const char *);
VLC_API void vlc_UrlClean (vlc_url_t *);
#endif
......@@ -1070,7 +1070,7 @@ static int DrawStatus(intf_thread_t *intf, input_thread_t *p_input)
char *path, *uri;
uri = input_item_GetURI(input_GetItem(p_input));
path = make_path(uri);
path = vlc_uri2path(uri);
mvnprintw(y++, 0, COLS, _(" Source : %s"), path?path:uri);
free(uri);
......
......@@ -281,7 +281,7 @@ void MetaPanel::update( input_item_t *p_item )
char *psz_art = input_item_GetArtURL( p_item );
if( psz_art )
{
char *psz = make_path( psz_art );
char *psz = vlc_uri2path( psz_art );
free( psz_art );
file = qfu( psz );
free( psz );
......
......@@ -313,7 +313,7 @@ void StandardPLPanel::popupAction( QAction *action )
case VLCModelSubInterface::ACTION_EXPLORE:
/* locally handled only */
temp = model->getURI( index );
if( ! temp.isEmpty() ) path = make_path( temp.toLatin1().constData() );
if( ! temp.isEmpty() ) path = vlc_uri2path( temp.toLatin1().constData() );
if( path == NULL ) return;
QDesktopServices::openUrl(
QUrl::fromLocalFile( QFileInfo( qfu( path ) ).absolutePath() ) );
......
......@@ -195,7 +195,7 @@ void MediaInfoDialog::updateURI( const QString& uri )
QString location;
/* If URI points to a local file, show the path instead of the URI */
char *path = make_path( qtu( uri ) );
char *path = vlc_uri2path( qtu( uri ) );
if( path != NULL )
{
location = qfu( path );
......
......@@ -781,7 +781,7 @@ void DialogsProvider::loadSubtitlesFile()
char *path2 = NULL;
if( path )
{
path2 = make_path( path );
path2 = vlc_uri2path( path );
free( path );
if( path2 )
{
......
......@@ -718,7 +718,7 @@ const QString InputManager::decodeArtURL( input_item_t *p_item )
char *psz_art = input_item_GetArtURL( p_item );
if( psz_art )
{
char *psz = make_path( psz_art );
char *psz = vlc_uri2path( psz_art );
free( psz_art );
psz_art = psz;
}
......
......@@ -88,7 +88,7 @@ void RecentsMRL::addRecent( const QString &mrl )
#ifdef _WIN32
/* Add to the Windows 7 default list in taskbar */
char* path = make_path( qtu( mrl ) );
char* path = vlc_uri2path( qtu( mrl ) );
if( path )
{
wchar_t *wmrl = ToWide( path );
......
......@@ -264,7 +264,7 @@ void TopWindow::processEvent( EvtDragDrop &rEvtDragDrop )
if( files.size() == 1 && pInput != NULL )
{
std::list<std::string>::const_iterator it = files.begin();
char* psz_file = make_path( it->c_str() );
char* psz_file = vlc_uri2path( it->c_str() );
if( psz_file )
{
is_subtitle = !input_AddSubtitleOSD( pInput, psz_file, true, true );
......
......@@ -754,7 +754,7 @@ void VlcProc::update_current_input()
// Update local path (if possible) or full uri
char *psz_uri = input_item_GetURI( pItem );
char *psz_path = make_path( psz_uri );
char *psz_path = vlc_uri2path( psz_uri );
char *psz_save = psz_path ? psz_path : psz_uri;
SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_save ) );
free( psz_path );
......
......@@ -95,7 +95,7 @@ static int vlclua_make_uri( lua_State *L )
static int vlclua_make_path( lua_State *L )
{
const char *psz_input = luaL_checkstring( L, 1 );
char *psz_path = make_path( psz_input);
char *psz_path = vlc_uri2path( psz_input);
lua_pushstring( L, psz_path );
free( psz_path );
return 1;
......
......@@ -92,7 +92,7 @@ static int FindMeta( vlc_object_t *p_this )
free( psz_uri );
return VLC_EGENERIC;
}
char *psz_basedir = make_path( psz_path );
char *psz_basedir = vlc_uri2path( psz_path );
FREENULL( psz_path );
if( psz_basedir == NULL )
{
......@@ -107,7 +107,7 @@ static int FindMeta( vlc_object_t *p_this )
if ( psz_path == NULL )
{
char *psz_basedir = make_path( psz_uri );
char *psz_basedir = vlc_uri2path( psz_uri );
if( psz_basedir == NULL )
{
free( psz_uri );
......
......@@ -32,7 +32,7 @@
#include <vlc_demux.h> /* demux_meta_t */
#include <vlc_strings.h> /* vlc_b64_decode_binary */
#include <vlc_input.h> /* for attachment_new */
#include <vlc_url.h> /* make_path */
#include <vlc_url.h> /* vlc_uri2path */
#include <vlc_mime.h> /* mime type */
#include <vlc_fs.h>
......@@ -689,7 +689,7 @@ static int ReadMeta( vlc_object_t* p_this)
if( unlikely(psz_uri == NULL) )
return VLC_ENOMEM;
char *psz_path = make_path( psz_uri );
char *psz_path = vlc_uri2path( psz_uri );
free( psz_uri );
if( psz_path == NULL )
return VLC_EGENERIC;
......@@ -916,7 +916,7 @@ static void WriteMetaToId3v2( ID3v2::Tag* tag, input_item_t* p_item )
if( psz_url == NULL )
return;
char *psz_path = make_path( psz_url );
char *psz_path = vlc_uri2path( psz_url );
free( psz_url );
if( psz_path == NULL )
return;
......
......@@ -108,7 +108,7 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root,
vlc_mutex_unlock( &p_current->p_input->lock );
/* Stupid third party players don't understand file: URIs. */
char *psz_path = make_path( psz_uri );
char *psz_path = vlc_uri2path( psz_uri );
if( psz_path != NULL )
{
free( psz_uri );
......
......@@ -205,7 +205,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
if( psz_arturl )
{
char *psz = make_path( psz_arturl );
char *psz = vlc_uri2path( psz_arturl );
free( psz_arturl );
psz_arturl = psz;
}
......
......@@ -257,7 +257,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
char *psz_arturl = input_item_GetArtURL( p_item );
if( psz_arturl )
{
char *psz = make_path( psz_arturl );
char *psz = vlc_uri2path( psz_arturl );
free( psz_arturl );
psz_arturl = psz;
}
......
......@@ -758,7 +758,7 @@ static void SDPHandleUrl( sout_stream_t *p_stream, const char *psz_url )
msg_Err( p_stream, "you can use sdp=file:// only once" );
goto out;
}
p_sys->psz_sdp_file = make_path( psz_url );
p_sys->psz_sdp_file = vlc_uri2path( psz_url );
if( p_sys->psz_sdp_file == NULL )
goto out;
FileSetup( p_stream );
......
......@@ -44,12 +44,12 @@ char *get_path(const char *location)
char *url, *path;
/* Prepending "file://" is a bit hackish. But then again, we do not want
* to hard-code the list of schemes that use file paths in make_path().
* to hard-code the list of schemes that use file paths in vlc_uri2path().
*/
if (asprintf(&url, "file://%s", location) == -1)
return NULL;
path = make_path (url);
path = vlc_uri2path (url);
free (url);
return path;
}
......
......@@ -273,7 +273,7 @@ int input_item_WriteMeta( vlc_object_t *obj, input_item_t *p_item )
goto error;
char *psz_uri = input_item_GetURI( p_item );
p_export->psz_file = make_path( psz_uri );
p_export->psz_file = vlc_uri2path( psz_uri );
if( p_export->psz_file == NULL )
msg_Err( p_export, "cannot write meta to remote media %s", psz_uri );
free( psz_uri );
......
......@@ -259,7 +259,7 @@ char **subtitles_Detect( input_thread_t *p_this, char *psz_path,
if( !psz_name_org )
return NULL;
char *psz_fname = make_path( psz_name_org );
char *psz_fname = vlc_uri2path( psz_name_org );
if( !psz_fname )
return NULL;
......
......@@ -245,7 +245,7 @@ libvlc_ArtRequest
vlc_UrlParse
vlc_UrlClean
vlc_path2uri
make_path
vlc_uri2path
mdate
module_config_free
module_config_get
......
......@@ -169,7 +169,7 @@ int main (void)
assert (val != -1);*/
/* URI to path tests */
#define test( a, b ) test (make_path, a, b)
#define test( a, b ) test (vlc_uri2path, a, b)
test ("mailto:john@example.com", NULL);
test ("http://www.example.com/file.html#ref", NULL);
test ("file://", NULL);
......
......@@ -143,13 +143,6 @@ char *encode_URI_component (const char *str)
return ret;
}
/**
* Builds a URL representation from a local file path.
* @param path path to convert (or URI to copy)
* @param scheme URI scheme to use (default is auto: "file", "fd" or "smb")
* @return a nul-terminated URI string (use free() to release it),
* or NULL in case of error (errno will be set accordingly)
*/
char *vlc_path2uri (const char *path, const char *scheme)
{
if (path == NULL)
......@@ -252,13 +245,7 @@ char *vlc_path2uri (const char *path, const char *scheme)
return buf;
}
/**
* Tries to convert a URI to a local (UTF-8-encoded) file path.
* @param url URI to convert
* @return NULL on error, a nul-terminated string otherwise
* (use free() to release it)
*/
char *make_path (const char *url)
char *vlc_uri2path (const char *url)
{
char *ret = NULL;
char *end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment