-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathStdFilesystem.h
85 lines (68 loc) · 2.53 KB
/
StdFilesystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*****************************************************************************
The Dark Mod GPL Source Code
This file is part of the The Dark Mod Source Code, originally based
on the Doom 3 GPL Source Code as published in 2011.
The Dark Mod Source Code is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version. For details, see LICENSE.TXT.
Project: The Dark Mod (http://www.thedarkmod.com/)
******************************************************************************/
#ifndef STD_FILESYSTEM_H_
#define STD_FILESYSTEM_H_
#include <stdint.h>
#include <string>
#include <memory>
#include <vector>
#include <system_error>
namespace stdext {
//all of these types and functions are equivalents to boost::filesystem namespace contents
//also, they neatly wrap std::filesystem code
struct path_impl;
class path {
public:
~path();
path();
path(const path& path);
path& operator= (const path &path);
path(path&& path);
path& operator= (path &&path);
path(const path_impl& impl);
path(const char *source);
path(const std::string &source);
std::string string() const;
path parent_path() const;
path filename() const;
path extension() const;
path stem() const;
path& remove_filename();
private:
std::unique_ptr<path_impl> d;
friend path_impl &get(path &path);
friend const path_impl &get(const path &path);
};
path operator/(const path& lhs, const path& rhs);
path& operator/=(path& lhs, const path& rhs);
bool operator==(const path& lhs, const path& rhs);
bool operator<(const path& lhs, const path& rhs);
bool is_directory(const path &path);
bool create_directory(const path &path);
bool exists(const path &path);
bool create_directories(const path &path);
bool remove(const path &path);
uint64_t file_size(const path &path);
uint64_t remove_all(const path& path);
void copy_file(const path &from, const path &to);
void rename(const path &from, const path &to);
//below is some replacement for C++ iterator mess
//(cost of memory allocation should be negligible compare to cost of filesystem access)
//replacement for directory_iterator
std::vector<path> directory_enumerate(const path &path);
//replacement for recursive_directory_iterator
std::vector<path> recursive_directory_enumerate(const path &path);
class filesystem_error : public std::system_error {
public:
filesystem_error(const char *what_arg, std::error_code ec);
};
}
#endif