Mana
Loading...
Searching...
No Matches
mkdir.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2010-2024 The Mana Developers
4 *
5 * This file is part of The Mana Client.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <climits>
22#include <cstring>
23#include <cerrno>
24#include <filesystem>
25#include <iostream>
26
27#ifdef MKDIR_TEST
28// compile with -DMKDIR_TEST to get a standalone binary
29#include <cstdio>
30#include <cstdlib>
31#endif
32
33#include "mkdir.h"
34
36int mkdir_r(const char *pathname) {
37 try {
38 std::filesystem::create_directories(pathname);
39 return 0;
40 } catch (const std::exception&) {}
41
42 return -1;
43}
44
45#ifdef MKDIR_TEST
46int main(int argc, char** argv) {
47 if (argc < 2) exit(1);
48 mkdir_r(argv[1]);
49}
50#endif
int main(int argc, char *argv[])
Definition main.cpp:235
int mkdir_r(const char *pathname)
Create a directory, making leading components first if necessary.
Definition mkdir.cpp:36