FFmpeg
mkdir.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2026 Jun Zhao
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "config.h"
22 
23 #include <errno.h>
24 #include <stdio.h>
25 
26 #if HAVE_UNISTD_H
27 #include <unistd.h>
28 #endif
29 
30 #include "libavutil/random_seed.h"
31 
32 #include "libavformat/internal.h"
33 #include "libavformat/os_support.h"
34 
35 int main(void)
36 {
37  char parent[64];
38  char child[80];
39 
40  snprintf(parent, sizeof(parent), "ff-mkdir-test-%08x", av_get_random_seed());
41  snprintf(child, sizeof(child), "%s/child", parent);
42 
43  if (mkdir(parent, 0755) < 0) {
44  perror("mkdir parent");
45  return 1;
46  }
47 
48  if (ff_mkdir_p(child) < 0) {
49  perror("ff_mkdir_p");
50  rmdir(parent);
51  return 1;
52  }
53 
54  if (rmdir(child) < 0) {
55  perror("rmdir child");
56  rmdir(parent);
57  return 1;
58  }
59 
60  if (rmdir(parent) < 0) {
61  perror("rmdir parent");
62  return 1;
63  }
64 
65  return 0;
66 }
main
int main(void)
Definition: mkdir.c:35
os_support.h
av_get_random_seed
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
Definition: random_seed.c:196
internal.h
random_seed.h
ff_mkdir_p
int ff_mkdir_p(const char *path)
Automatically create sub-directories.
Definition: utils.c:424
snprintf
#define snprintf
Definition: snprintf.h:34