ReactOS 0.4.15-dev-7942-gd23573b
timesup.c File Reference
#include "fatprocs.h"
Include dependency graph for timesup.c:

Go to the source code of this file.

Functions

 _Success_ (return !=FALSE)
 
LARGE_INTEGER FatFatDateToNtTime (_In_ PIRP_CONTEXT IrpContext, _In_ FAT_DATE FatDate)
 
LARGE_INTEGER FatFatTimeToNtTime (_In_ PIRP_CONTEXT IrpContext, _In_ FAT_TIME_STAMP FatTime, _In_ UCHAR TenMilliSeconds)
 
FAT_TIME_STAMP FatGetCurrentFatTime (_In_ PIRP_CONTEXT IrpContext)
 

Function Documentation

◆ _Success_()

_Success_ ( return = FALSE)

Definition at line 25 of file timesup.c.

63{
65
66 PAGED_CODE();
67
68 //
69 // Convert the input to the a time field record.
70 //
71
72 if (Rounding) {
73
74 //
75 // Add almost two seconds to round up to the nearest double second.
76 //
77
79 }
80
82
84
85 //
86 // Check the range of the date found in the time field record
87 //
88
89 if ((TimeFields.Year < 1980) || (TimeFields.Year > (1980 + 127))) {
90
92
93 return FALSE;
94 }
95
96 //
97 // The year will fit in Fat so simply copy over the information
98 //
99
100 FatTime->Time.DoubleSeconds = (USHORT)(TimeFields.Second / 2);
101 FatTime->Time.Minute = (USHORT)(TimeFields.Minute);
102 FatTime->Time.Hour = (USHORT)(TimeFields.Hour);
103
104 FatTime->Date.Year = (USHORT)(TimeFields.Year - 1980);
105 FatTime->Date.Month = (USHORT)(TimeFields.Month);
106 FatTime->Date.Day = (USHORT)(TimeFields.Day);
107
108 if (TenMsecs) {
109
110 if (!Rounding) {
111
112 //
113 // If the number of seconds was not divisible by two, then there
114 // is another second of time (1 sec, 3 sec, etc.) Note we round down
115 // the number of milleconds onto tens of milleseconds boundaries.
116 //
117
118#ifdef _MSC_VER
119#pragma warning( push )
120#pragma warning( disable: 4244 )
121#endif
123 ((TimeFields.Second % 2) * 100);
124#ifdef _MSC_VER
125#pragma warning( pop )
126#endif
127 } else {
128
129 //
130 // If we rounded up, we have in effect changed the NT time. Therefore,
131 // it does not differ from the FAT time.
132 //
133
134 *TenMsecs = 0;
135 }
136 }
137
138 if (Rounding) {
139
140 //
141 // Slice off non-FAT boundary time and convert back to 64bit form
142 //
143
146
147 } else {
148
149 //
150 // Round down to 10ms boundary
151 //
152
154 }
155
156 //
157 // Convert back to NT time
158 //
159
161
163
164 UNREFERENCED_PARAMETER( IrpContext );
165
166 return TRUE;
167}
#define PAGED_CODE()
#define VOID
Definition: acefi.h:82
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOLEAN RtlTimeToTimeFields(IN PLARGE_INTEGER Time, IN PTIME_FIELDS TimeFields)
BOOLEAN RtlTimeFieldsToTime(IN PTIME_FIELDS TimeFields, IN PLARGE_INTEGER Time)
#define ExLocalTimeToSystemTime(LocTime, SysTime)
Definition: env_spec_w32.h:738
#define ExSystemTimeToLocalTime(SysTime, LocTime)
Definition: env_spec_w32.h:729
#define AlmostTwoSeconds
Definition: fatdata.h:125
_In_ PLARGE_INTEGER NtTime
Definition: fatprocs.h:1914
_In_ PLARGE_INTEGER _In_ BOOLEAN _Out_ PFAT_TIME_STAMP _Out_opt_ PUCHAR TenMsecs
Definition: fatprocs.h:1918
_In_ PLARGE_INTEGER _In_ BOOLEAN _Out_ PFAT_TIME_STAMP FatTime
Definition: fatprocs.h:1916
_In_ PLARGE_INTEGER _In_ BOOLEAN Rounding
Definition: fatprocs.h:1915
static PTIME_FIELDS TimeFields
Definition: time.c:104
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
unsigned short USHORT
Definition: pedump.c:61
USHORT Milliseconds
Definition: env_spec_w32.h:717
LONGLONG QuadPart
Definition: typedefs.h:114

◆ FatFatDateToNtTime()

LARGE_INTEGER FatFatDateToNtTime ( _In_ PIRP_CONTEXT  IrpContext,
_In_ FAT_DATE  FatDate 
)

Definition at line 171 of file timesup.c.

193{
196
197 PAGED_CODE();
198
199 //
200 // Pack the input time/date into a time field record
201 //
202
203 TimeFields.Year = (USHORT)(FatDate.Year + 1980);
204 TimeFields.Month = (USHORT)(FatDate.Month);
205 TimeFields.Day = (USHORT)(FatDate.Day);
210
211 //
212 // Convert the time field record to Nt LARGE_INTEGER, and set it to zero
213 // if we were given a bogus time.
214 //
215
217
218 Time.LowPart = 0;
219 Time.HighPart = 0;
220
221 } else {
222
224 }
225
226 return Time;
227
228 UNREFERENCED_PARAMETER( IrpContext );
229}
static PLARGE_INTEGER Time
Definition: time.c:105
ULONG LowPart
Definition: typedefs.h:106

Referenced by FatCreateDcb(), FatCreateFcb(), FatGetDirTimes(), and FatSetRenameInfo().

◆ FatFatTimeToNtTime()

LARGE_INTEGER FatFatTimeToNtTime ( _In_ PIRP_CONTEXT  IrpContext,
_In_ FAT_TIME_STAMP  FatTime,
_In_ UCHAR  TenMilliSeconds 
)

Definition at line 233 of file timesup.c.

258{
261
262 PAGED_CODE();
263
264 //
265 // Pack the input time/date into a time field record
266 //
267
268 TimeFields.Year = (USHORT)(FatTime.Date.Year + 1980);
269 TimeFields.Month = (USHORT)(FatTime.Date.Month);
270 TimeFields.Day = (USHORT)(FatTime.Date.Day);
271 TimeFields.Hour = (USHORT)(FatTime.Time.Hour);
272 TimeFields.Minute = (USHORT)(FatTime.Time.Minute);
273 TimeFields.Second = (USHORT)(FatTime.Time.DoubleSeconds * 2);
274
275 if (TenMilliSeconds != 0) {
276
277 TimeFields.Second += (USHORT)(TenMilliSeconds / 100);
278 TimeFields.Milliseconds = (USHORT)((TenMilliSeconds % 100) * 10);
279
280 } else {
281
283 }
284
285 //
286 // If the second value is greater than 59 then we truncate it to 0.
287 // Note that this can't happen with a proper FAT timestamp.
288 //
289
290 if (TimeFields.Second > 59) {
291
292 TimeFields.Second = 0;
293 }
294
295 //
296 // Convert the time field record to Nt LARGE_INTEGER, and set it to zero
297 // if we were given a bogus time.
298 //
299
301
302 Time.LowPart = 0;
303 Time.HighPart = 0;
304
305 } else {
306
308 }
309
310 return Time;
311
312 UNREFERENCED_PARAMETER( IrpContext );
313}

Referenced by FatCreateDcb(), FatCreateFcb(), FatGetDirTimes(), and FatSetRenameInfo().

◆ FatGetCurrentFatTime()

FAT_TIME_STAMP FatGetCurrentFatTime ( _In_ PIRP_CONTEXT  IrpContext)

Definition at line 317 of file timesup.c.

335{
339
340 PAGED_CODE();
341
342 //
343 // Get the current system time, and map it into a time field record.
344 //
345
347
349
350 //
351 // Always add almost two seconds to round up to the nearest double second.
352 //
353
355
357
358 //
359 // Now simply copy over the information
360 //
361
362 FatTime.Time.DoubleSeconds = (USHORT)(TimeFields.Second / 2);
363 FatTime.Time.Minute = (USHORT)(TimeFields.Minute);
364 FatTime.Time.Hour = (USHORT)(TimeFields.Hour);
365
366 FatTime.Date.Year = (USHORT)(TimeFields.Year - 1980);
367 FatTime.Date.Month = (USHORT)(TimeFields.Month);
368 FatTime.Date.Day = (USHORT)(TimeFields.Day);
369
370 UNREFERENCED_PARAMETER( IrpContext );
371
372 return FatTime;
373}
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570

Referenced by FatConstructLabelDirent().