-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflags.cpp
64 lines (54 loc) · 1.61 KB
/
flags.cpp
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
// Copyright (c) 2024 by Christopher Antos
// License: http://opensource.org/licenses/MIT
// vim: set et ts=4 sw=4 cino={0s:
#include "pch.h"
#include "flags.h"
const DirFormatSettings* g_settings = nullptr;
void SkipColonOrEqual(const WCHAR*& p)
{
if (*p == ':' || *p == '=')
++p;
}
void FlipFlag(FormatFlags& flags, FormatFlags flag, bool& enable, bool default_enable)
{
if (enable)
flags |= flag;
else
flags &= ~flag;
enable = default_enable;
}
void FailFlag(WCHAR ch, const WCHAR* value, WCHAR short_opt, const LongOption<WCHAR>* long_opt, Error& e)
{
WCHAR tmp[2] = { ch, '\0' };
if (long_opt)
{
e.Set(L"Unrecognized option '%1' in '--%1=%2'.") << tmp << long_opt->name << value;
}
else
{
WCHAR short_name[2] = { short_opt, '\0' };
e.Set(L"Unrecognized option '%1' in '-%2%3'.") << tmp << short_name << value;
}
}
void DirFormatSettings::ClearMinMax()
{
memset(&m_min_time, 0xff, sizeof(m_min_time));
memset(&m_max_time, 0x00, sizeof(m_max_time));
memset(&m_min_size, 0xff, sizeof(m_min_size));
memset(&m_max_size, 0x00, sizeof(m_max_size));
}
void DirFormatSettings::UpdateMinMaxTime(WhichTimeStamp which, const FILETIME& ft)
{
ULONGLONG ull = FileTimeToULONGLONG(ft);
if (m_min_time[which] > ull)
m_min_time[which] = ull;
if (m_max_time[which] < ull)
m_max_time[which] = ull;
}
void DirFormatSettings::UpdateMinMaxSize(WhichFileSize which, ULONGLONG size)
{
if (m_min_size[which] > size)
m_min_size[which] = size;
if (m_max_size[which] < size)
m_max_size[which] = size;
}