forked from diasurgical/DevilutionX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_util.h
More file actions
53 lines (42 loc) · 1.43 KB
/
file_util.h
File metadata and controls
53 lines (42 loc) · 1.43 KB
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
#pragma once
#include <cstdint>
#include <cstdio>
#include <memory>
#include <string>
#include <string_view>
#include <vector>
namespace devilution {
#ifdef _WIN32
constexpr char DirectorySeparator = '\\';
#define DIRECTORY_SEPARATOR_STR "\\"
#else
constexpr char DirectorySeparator = '/';
#define DIRECTORY_SEPARATOR_STR "/"
#endif
bool FileExists(const char *path);
inline bool FileExists(const std::string &str)
{
return FileExists(str.c_str());
}
bool DirectoryExists(const char *path);
std::string_view Dirname(std::string_view path);
bool FileExistsAndIsWriteable(const char *path);
bool GetFileSize(const char *path, std::uintmax_t *size);
/**
* @brief Creates a single directory (non-recursively).
*
* @return True if the directory already existed or has been created successfully.
*/
bool CreateDir(const char *path);
void RecursivelyCreateDir(const char *path);
bool ResizeFile(const char *path, std::uintmax_t size);
void RenameFile(const char *from, const char *to);
void CopyFileOverwrite(const char *from, const char *to);
void RemoveFile(const char *path);
FILE *OpenFile(const char *path, const char *mode);
#if defined(_WIN32) && !defined(DEVILUTIONX_WINDOWS_NO_WCHAR)
std::unique_ptr<wchar_t[]> ToWideChar(std::string_view path);
#endif
std::vector<std::string> ListDirectories(const char *path);
std::vector<std::string> ListFiles(const char *path);
} // namespace devilution