24#define WIN32_LEAN_AND_MEAN
33WCHAR * filename(WCHAR * path) {
35 for (WCHAR * p = path;;) {
47 WCHAR * path, WCHAR
const * frontBegin, WCHAR
const * frontEnd,
48 WCHAR
const * backBegin, std::size_t backLength)
54 while (backLength >= 2 && backBegin[0] == L
'.' && backBegin[1] == L
'.' &&
55 (backLength == 2 || backBegin[2] == L
'\\'))
57 if (frontEnd - frontBegin < 2 || frontEnd[-1] != L
'\\' ||
58 frontEnd[-2] == L
'\\' || frontEnd[-2] == L
':' ||
59 (frontEnd[-2] == L
'.' &&
60 (frontEnd - frontBegin < 3 || frontEnd[-3] == L
'\\' ||
61 (frontEnd[-3] == L
'.' &&
62 (frontEnd - frontBegin < 4 || frontEnd[-4] == L
'\\')))))
66 WCHAR
const *
p = frontEnd - 1;
67 while (p != frontBegin && p[-1] != L
'\\') {
70 if (p == frontBegin) {
74 if (backLength == 2) {
86 if (frontBegin == path) {
87 p =
const_cast< WCHAR *
>(frontEnd);
90 while (frontBegin != frontEnd) {
94 for (; backLength > 0; --backLength) {
100 SetLastError(ERROR_FILENAME_EXCED_RANGE);
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)