libgpac
Documentation of the core library of GPAC
URL tools

URL manipulation tools. More...

+ Collaboration diagram for URL tools:

Functions

Bool gf_url_is_local (const char *url)
 URL local test. More...
 
char * gf_url_get_absolute_path (const char *pathName, const char *parentPath)
 gets absolute file path More...
 
char * gf_url_concatenate (const char *parentName, const char *pathName)
 URL concatenation. More...
 
char * gf_url_concatenate_parent (const char *parentName, const char *pathName)
 URL concatenation. More...
 
char * gf_url_percent_encode (const char *path)
 URL encoding. More...
 
char * gf_url_percent_decode (const char *path)
 URL decoding. More...
 
void gf_url_to_fs_path (char *url)
 URL to file system. More...
 
Bool gf_url_is_relative (const char *url)
 check relative URL More...
 
char * gf_url_colon_suffix (const char *URL, char assign_sep)
 get first after a filename/path More...
 
const char * gf_url_get_resource_name (const char *url)
 Extract resource name from URL. More...
 
const char * gf_url_get_path (const char *url)
 Gets resource path from URL. More...
 

Detailed Description

Function Documentation

◆ gf_url_is_local()

Bool gf_url_is_local ( const char *  url)

Tests whether a URL describes a local file or not

Parameters
urlthe url to analyze
Returns
1 if the URL describes a local file, 0 otherwise

◆ gf_url_get_absolute_path()

char* gf_url_get_absolute_path ( const char *  pathName,
const char *  parentPath 
)

Gets the absolute file path from a relative path and its parent absolute one. This can only be used with file paths.

Parameters
pathNamethe relative path name of a file
parentPaththe absolute parent path name
Returns
absolute path name of the file, or NULL if bad paths are provided.
Note
the returned string must be freed by user

◆ gf_url_concatenate()

char* gf_url_concatenate ( const char *  parentName,
const char *  pathName 
)

Concatenates a relative URL with its parent URL

Parameters
parentNameURL of the parent service
pathNameURL of the service
Returns
absolute path name of the service, or NULL if bad paths are provided or if the service path is already an absolute one.
Note
the returned string must be freed by user

◆ gf_url_concatenate_parent()

char* gf_url_concatenate_parent ( const char *  parentName,
const char *  pathName 
)

Same as gf_url_concatenate but if both paths are relative, resolved url is relative to parent path.

Parameters
parentNameURL of the parent service
pathNameURL of the service
Returns
absolute path name of the service, or NULL if bad paths are provided or if the service path is already an absolute one.
Note
the returned string must be freed by user

◆ gf_url_percent_encode()

char* gf_url_percent_encode ( const char *  path)

Encodes URL by replacing special characters with their % encodings.

Parameters
pathURL of the service
Returns
encoded path name , or NULL if bad paths are provided.
Note
the returned string must be freed by user

◆ gf_url_percent_decode()

char* gf_url_percent_decode ( const char *  path)

Decodes URL by % encodings with the special characters they correspond to

Parameters
pathencoded URL of the service
Returns
decoded path name , or NULL if error
Note
the returned string must be freed by user

◆ gf_url_to_fs_path()

void gf_url_to_fs_path ( char *  url)

Converts a local URL to a file system value. Removes all white spaces and similar

Parameters
urlurl to convert

◆ gf_url_is_relative()

Bool gf_url_is_relative ( const char *  url)

Checks if given URL is absolute or relative

Parameters
urlurl to check
Returns
GF_TRUE if URL is relative

◆ gf_url_colon_suffix()

char* gf_url_colon_suffix ( const char *  URL,
char  assign_sep 
)

Returns a pointer to the first colon at the end of a filename or URL, if any.

If assign_sep is specified, for example '=', the function will make sure that the colon is after the file extension if found and that '=' is not present between colon and file ext. This is used to parse 'a:b.mp4:c' (expected result ':c...' and not ':b...') vs 'a:b=c.mp4' ' (expected result ':b')

Parameters
URLpath or URL to inspect
assign_sepvalue of assignment operand character. If 0, only checks for colon, otherwise chec that no assign sep or colon is present before file extension, if present
Returns
position of first colon, or NULL

◆ gf_url_get_resource_name()

const char* gf_url_get_resource_name ( const char *  url)

Extracts the resource name from the URL

Parameters
urlinput url
Returns
resource name.

◆ gf_url_get_path()

const char* gf_url_get_path ( const char *  url)

Gets the resource path and name from the URL, stripping scheme, server ID, port...

Parameters
urlinput url
Returns
the extracted path, or the original path if no scheme indication, or NULL of no path