@ -102,38 +102,15 @@ static int list_op(const char *input_dir)
return ret ;
}
static int del_op ( const char * url )
{
int ret = avpriv_io_delete ( url ) ;
if ( ret < 0 )
av_log ( NULL , AV_LOG_ERROR , " Cannot delete '%s': %s. \n " , url , av_err2str ( ret ) ) ;
return ret ;
}
static int move_op ( const char * src , const char * dst )
{
int ret = avpriv_io_move ( src , dst ) ;
if ( ret < 0 )
av_log ( NULL , AV_LOG_ERROR , " Cannot move '%s' into '%s': %s. \n " , src , dst , av_err2str ( ret ) ) ;
return ret ;
}
static void usage ( const char * program_name )
{
fprintf ( stderr , " usage: %s OPERATION entry1 [entry2] \n "
" API example program to show how to manipulate resources "
" accessed through AVIOContext. \n "
" OPERATIONS: \n "
" list list content of the directory \n "
" move rename content in directory \n "
" del delete content in directory \n " ,
program_name ) ;
fprintf ( stderr , " usage: %s input_dir \n "
" API example program to show how to list files in directory "
" accessed through AVIOContext. \n " , program_name ) ;
}
int main ( int argc , char * argv [ ] )
{
const char * op = NULL ;
int ret ;
av_log_set_level ( AV_LOG_DEBUG ) ;
@ -145,32 +122,7 @@ int main(int argc, char *argv[])
avformat_network_init ( ) ;
op = argv [ 1 ] ;
if ( strcmp ( op , " list " ) = = 0 ) {
if ( argc < 3 ) {
av_log ( NULL , AV_LOG_INFO , " Missing argument for list operation. \n " ) ;
ret = AVERROR ( EINVAL ) ;
} else {
ret = list_op ( argv [ 2 ] ) ;
}
} else if ( strcmp ( op , " del " ) = = 0 ) {
if ( argc < 3 ) {
av_log ( NULL , AV_LOG_INFO , " Missing argument for del operation. \n " ) ;
ret = AVERROR ( EINVAL ) ;
} else {
ret = del_op ( argv [ 2 ] ) ;
}
} else if ( strcmp ( op , " move " ) = = 0 ) {
if ( argc < 4 ) {
av_log ( NULL , AV_LOG_INFO , " Missing argument for move operation. \n " ) ;
ret = AVERROR ( EINVAL ) ;
} else {
ret = move_op ( argv [ 2 ] , argv [ 3 ] ) ;
}
} else {
av_log ( NULL , AV_LOG_INFO , " Invalid operation %s \n " , op ) ;
ret = AVERROR ( EINVAL ) ;
}
ret = list_op ( argv [ 1 ] ) ;
avformat_network_deinit ( ) ;