acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
file_time.h
1
#pragma once
2
3
4
#include "file_time_span.h"
5
6
7
struct
file_time_t
{};
8
9
10
class
CLASS_DECL_ACME file_time
11
{
12
public
:
13
14
15
// Microseconds between 1601-01-01 00:00:00 UTC and 1970-01-01 00:00:00 UTC
16
inline
static
constexpr ::u64 EPOCH_DIFFERENCE_100NS = 116444736000000000ull;
17
18
19
// Contains a 64-bit value representing the number
20
// of 100-nanosecond intervals since January 1, 1601 (UTC).
21
::u64 m_uFileTime;
22
23
24
file_time()
noexcept
{ m_uFileTime = 0; }
25
file_time(
file_time_t
, ::u64 uFileTime)
noexcept
{ m_uFileTime = uFileTime; }
26
explicit
file_time(
const
system_time
& systemtime);
27
explicit
file_time(const ::posix_time &
time
);
28
explicit
file_time(
const
class ::time &
time
);
29
explicit
file_time(const ::earth::gregorian_time & gregoriantime);
30
// ystem_time_as_file_time();
31
//file_time(local_const ::file_time & filetime);
32
//file_time(const ::earth::time & time);
33
file_time(
now_t
);
34
35
static
file_time now()
noexcept
;
36
37
38
//explicit operator file_time_t &() { return m_filetime; }
39
//explicit operator file_time_t () const { return m_filetime; }
40
41
42
file_time& operator +=(
file_time_span
span)
noexcept
;
43
file_time& operator-=(
file_time_span
span)
noexcept
;
44
45
file_time operator +(
file_time_span
span)
const
noexcept
;
46
file_time operator-(
file_time_span
span)
const
noexcept
;
47
file_time_span
operator-(file_time ft)
const
noexcept
;
48
49
bool
operator==(file_time ft)
const
noexcept
;
50
std::strong_ordering operator<=>(file_time ft)
const
noexcept
;
51
//bool operator<(file_time ft) const noexcept;
52
//bool operator>(file_time ft) const noexcept;
53
//bool operator<=(file_time ft) const noexcept;
54
//bool operator>=(file_time ft) const noexcept;
55
56
::u64 get_file_time()
const
noexcept
;
57
void
set_file_time(::u64 nTime)
noexcept
;
58
59
60
61
//file_time UTCToLocal() const noexcept;
62
//file_time LocalToUTC() const noexcept;
63
64
//static const file_time_t Millisecond;
65
//static const file_time_t Second;
66
//static const file_time_t Minute;
67
//static const file_time_t Hour;
68
//static const file_time_t Day;
69
//static const file_time_t Week;
70
71
};
72
73
74
// Used only if these strings could not be found in resources.
75
extern
CLASS_DECL_ACME const_char_pointer
const
szInvalidDateTime;
76
extern
CLASS_DECL_ACME const_char_pointer
const
szInvalidDateTimeSpan;
77
78
const ::i32 maxTimeBufferSize = 128;
79
const
long
maxDaysInSpan = 3615897L;
80
81
82
//CLASS_DECL_ACME file_time_t get_file_time_now();
83
84
85
struct
CLASS_DECL_ACME file_time_set
86
{
87
88
89
file_time
m_filetimeCreation;
90
file_time
m_filetimeModified;
91
file_time
m_filetimeAccess;
// Not used at Windows?
92
93
94
file_time_set() {}
95
96
97
bool
operator == (
const
file_time_set & file_timeset)
const
98
{
99
return
100
&file_timeset ==
this
||
101
(
102
m_filetimeCreation == file_timeset.m_filetimeCreation
103
&& m_filetimeModified == file_timeset.m_filetimeModified
104
&& m_filetimeAccess == file_timeset.m_filetimeAccess
105
);
106
}
107
108
109
110
bool
modified_timeout(
const
file_time
& current, ::i32 iSeconds)
const
111
{
112
113
if
((current - m_filetimeModified).m_iFileTimeSpan > (iSeconds * 10'000'000))
114
{
115
116
return
true
;
117
118
}
119
120
return
false
;
121
122
}
123
124
125
bool
modified_timeout(::i32 iSeconds)
const
;
126
127
};
128
129
130
namespace
earth
131
{
132
133
class
time
;
134
class
zone_time;
135
136
}
// namespace earth
137
138
139
CLASS_DECL_ACME
bool
file_modified_timeout(const ::file::path & path, ::i32 iSeconds);
140
141
142
CLASS_DECL_ACME
void
get_file_time_set(const ::file::path & path,
file_time_set
&
time
);
143
144
CLASS_DECL_ACME
void
get_file_time_set(const ::file::path & path,
file_time
& creation,
file_time
& modified);
145
146
CLASS_DECL_ACME
void
set_modified_file_time(const ::file::path & path,
const
class ::time &
time
);
147
148
CLASS_DECL_ACME
void
set_modified_file_time(const ::file::path & path,
const
file_time
& modified);
149
150
inline
file_time_set
get_file_time_set(const ::file::path & path)
151
{
152
153
file_time_set
filetimeset;
154
155
try
156
{
157
158
get_file_time_set(path, filetimeset);
159
160
}
161
catch
(...)
162
{
163
164
return
{};
165
166
}
167
168
return
filetimeset;
169
170
}
171
172
173
//CLASS_DECL_ACME file_time __file_time(const ::earth::time & time);
174
175
176
//posix_time __time(const file_time & file_time);
177
178
179
180
CLASS_DECL_ACME
file_time
as_local_file_time(const ::file_time & filetime);
181
182
183
file_time_span
Definition
file_time_span.h:8
file_time
Definition
file_time.h:11
system_time
Definition
system_time.h:8
time
Definition
aaa_time.h:13
file_time_set
Definition
file_time.h:86
file_time_t
Definition
file_time.h:7
now_t
Definition
_structures.h:48
prototype
datetime
file_time.h
Generated by
1.17.0