Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
c84d208c
Commit
c84d208c
authored
Aug 15, 2015
by
Mariusz Szczepańczyk
Committed by
Michael Niedermayer
Aug 15, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/avio_list_dir: add move and delete methods
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
4b0e1124
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
16 deletions
+76
-16
avio_list_dir.c
doc/examples/avio_list_dir.c
+76
-16
No files found.
doc/examples/avio_list_dir.c
View file @
c84d208c
...
@@ -54,28 +54,13 @@ static const char *type_string(int type)
...
@@ -54,28 +54,13 @@ static const char *type_string(int type)
return
"<UNKNOWN>"
;
return
"<UNKNOWN>"
;
}
}
int
main
(
int
argc
,
char
*
argv
[]
)
static
int
list_op
(
const
char
*
input_dir
)
{
{
const
char
*
input_dir
=
NULL
;
AVIODirEntry
*
entry
=
NULL
;
AVIODirEntry
*
entry
=
NULL
;
AVIODirContext
*
ctx
=
NULL
;
AVIODirContext
*
ctx
=
NULL
;
int
cnt
,
ret
;
int
cnt
,
ret
;
char
filemode
[
4
],
uid_and_gid
[
20
];
char
filemode
[
4
],
uid_and_gid
[
20
];
av_log_set_level
(
AV_LOG_DEBUG
);
if
(
argc
!=
2
)
{
fprintf
(
stderr
,
"usage: %s input_dir
\n
"
"API example program to show how to list files in directory "
"accessed through AVIOContext.
\n
"
,
argv
[
0
]);
return
1
;
}
input_dir
=
argv
[
1
];
/* register codecs and formats and other lavf/lavc components*/
av_register_all
();
avformat_network_init
();
if
((
ret
=
avio_open_dir
(
&
ctx
,
input_dir
,
NULL
))
<
0
)
{
if
((
ret
=
avio_open_dir
(
&
ctx
,
input_dir
,
NULL
))
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Cannot open directory: %s.
\n
"
,
av_err2str
(
ret
));
av_log
(
NULL
,
AV_LOG_ERROR
,
"Cannot open directory: %s.
\n
"
,
av_err2str
(
ret
));
goto
fail
;
goto
fail
;
...
@@ -114,6 +99,81 @@ int main(int argc, char *argv[])
...
@@ -114,6 +99,81 @@ int main(int argc, char *argv[])
fail:
fail:
avio_close_dir
(
&
ctx
);
avio_close_dir
(
&
ctx
);
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
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
op
=
NULL
;
int
ret
;
av_log_set_level
(
AV_LOG_DEBUG
);
if
(
argc
<
2
)
{
usage
(
argv
[
0
]);
return
1
;
}
/* register codecs and formats and other lavf/lavc components*/
av_register_all
();
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
);
}
avformat_network_deinit
();
avformat_network_deinit
();
return
ret
<
0
?
1
:
0
;
return
ret
<
0
?
1
:
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment