-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathWin32.cpp
More file actions
41 lines (32 loc) · 897 Bytes
/
PathWin32.cpp
File metadata and controls
41 lines (32 loc) · 897 Bytes
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
#include "../classes/Path.h"
#include <algorithm>
namespace fs {
char const Path::delim = '\\';
char const Path::otherDelim = '/';
wchar_t const wdelim = wchar_t(Path::delim);
wchar_t const wotherDelim = wchar_t(Path::otherDelim);
Filename Path::normalize(Filename path)
{
std::replace(path.wstr.begin(),path.wstr.end(),wotherDelim,wdelim);
if( ! path.empty() && path.wstr.back() == wdelim ) {
path.wstr.erase(std::prev(path.wstr.end()));
}
if( ! path.empty() && path.wstr.front() == wdelim ) {
path.wstr.erase(path.wstr.begin());
}
return path;
}
Filename Path::changeSeparator(Filename path, char ch)
{
return changeSeparator(path,wchar_t(ch));
}
Filename Path::changeSeparator(Filename path, wchar_t ch)
{
std::replace(path.wstr.begin(),path.wstr.end(),wdelim,ch);
return path;
}
void Path::addDelim()
{
path.wstr += wdelim;
}
}