Commit 9826be04 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Inline path_sanitize()

Also optimize it away where applicable.
parent c9b04765
...@@ -135,7 +135,37 @@ static inline char *str_format( input_thread_t *input, const char *fmt ) ...@@ -135,7 +135,37 @@ static inline char *str_format( input_thread_t *input, const char *fmt )
} }
void filename_sanitize(char *); void filename_sanitize(char *);
VLC_API void path_sanitize( char * );
/**
* Remove forbidden characters from full paths (leaves slashes)
*/
static inline void path_sanitize(char *str)
{
#if defined( _WIN32 ) || defined( __OS2__ )
/* check drive prefix if path is absolute */
if ((((unsigned char)(str[0] - 'A') < 26)
|| ((unsigned char)(str[0] - 'a') < 26)) && (str[1] == ':'))
str += 2;
while (*str != '\0')
{
if (strchr("*\"?:|<>", *str) != NULL)
*str = '_';
if (*str == '/')
*str = DIR_SEP_CHAR;
str++;
}
#elif defined( __APPLE__ )
while (*str != '\0')
{
if (*str == ':')
*str = '_';
str++;
}
#else
(void) str;
#endif
}
/** /**
* @} * @}
......
...@@ -285,7 +285,6 @@ net_SetCSCov ...@@ -285,7 +285,6 @@ net_SetCSCov
net_vaPrintf net_vaPrintf
net_Write net_Write
NTPtime64 NTPtime64
path_sanitize
picture_BlendSubpicture picture_BlendSubpicture
picture_CopyPixels picture_CopyPixels
picture_Hold picture_Hold
......
...@@ -887,29 +887,3 @@ void filename_sanitize( char *str ) ...@@ -887,29 +887,3 @@ void filename_sanitize( char *str )
*str = '_'; *str = '_';
} }
} }
/**
* Remove forbidden characters from full paths (leaves slashes)
*/
void path_sanitize( char *str )
{
#if defined( _WIN32 ) || defined( __OS2__ )
/* check drive prefix if path is absolute */
if( (((unsigned char)(str[0] - 'A') < 26)
|| ((unsigned char)(str[0] - 'a') < 26)) && (':' == str[1]) )
str += 2;
#endif
while( *str )
{
#if defined( __APPLE__ )
if( *str == ':' )
*str = '_';
#elif defined( _WIN32 ) || defined( __OS2__ )
if( strchr( "*\"?:|<>", *str ) )
*str = '_';
if( *str == '/' )
*str = DIR_SEP_CHAR;
#endif
str++;
}
}
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