-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.inl
75 lines (66 loc) · 1.79 KB
/
file.inl
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
/* THOR - THOR Template Library
* Joshua M. Kriegshauser
*
* file.inl
*
* Utility for working with directories -- inline implementation
*/
#include "file.h"
namespace thor
{
namespace file
{
inline void normalize_path(const char* path, string& out)
{
basic_string<wchar_t, 256> wpath, wout;
bool b = utf8_to_wide(path, wpath);
THOR_UNUSED(b); THOR_ASSERT(b);
normalize_path(wpath.c_str(), wout);
b = wide_to_utf8(wout, out);
THOR_ASSERT(b);
}
inline bool move(const char* pathFrom, const char* pathTo)
{
basic_string<wchar_t, 256> wpathFrom, wpathTo;
bool b = utf8_to_wide(pathFrom, wpathFrom);
b &= utf8_to_wide(pathTo, wpathTo);
THOR_UNUSED(b); THOR_ASSERT(b);
return move(wpathFrom.c_str(), wpathTo.c_str());
}
inline bool remove(const char* path)
{
basic_string<wchar_t, 256> wpath;
bool b = utf8_to_wide(path, wpath);
THOR_UNUSED(b); THOR_ASSERT(b);
return remove(wpath.c_str());
}
inline bool set_properties(const char* path, const properties& props)
{
basic_string<wchar_t, 256> wpath;
bool b = utf8_to_wide(path, wpath);
THOR_UNUSED(b); THOR_ASSERT(b);
return set_properties(wpath.c_str(), props);
}
inline bool exists(const char* path, properties* props)
{
basic_string<wchar_t, 256> wpath;
bool b = utf8_to_wide(path, wpath);
THOR_UNUSED(b); THOR_ASSERT(b);
return exists(wpath.c_str(), props);
}
inline bool relative_to_full_path(const char* path, string& out)
{
basic_string<wchar_t, 256> wpath, wout;
bool b = utf8_to_wide(path, wpath);
THOR_UNUSED(b); THOR_ASSERT(b);
bool ret = relative_to_full_path(wpath.c_str(), wout);
if (ret)
{
b = wide_to_utf8(wout.c_str(), out);
THOR_ASSERT(b);
return true;
}
return false;
}
} // namespace file
} // namespace thor