Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
5641c4ba
Commit
5641c4ba
authored
May 08, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/Clock, fs/FileInfo: move FILETIME specific code to time/FileTime.hxx
parent
96f88927
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
38 deletions
+75
-38
FileInfo.hxx
src/fs/FileInfo.hxx
+1
-25
Clock.cxx
src/system/Clock.cxx
+3
-13
FileTime.hxx
src/time/FileTime.hxx
+71
-0
No files found.
src/fs/FileInfo.hxx
View file @
5641c4ba
...
...
@@ -24,7 +24,7 @@
#include "system/Error.hxx"
#ifdef _WIN32
#include
<fileapi.h>
#include
"time/FileTime.hxx"
#else
#include <sys/stat.h>
#endif
...
...
@@ -33,30 +33,6 @@
#include <stdint.h>
#ifdef _WIN32
static
constexpr
uint64_t
ConstructUint64
(
DWORD
lo
,
DWORD
hi
)
{
return
uint64_t
(
lo
)
|
(
uint64_t
(
hi
)
<<
32
);
}
static
constexpr
time_t
FileTimeToTimeT
(
FILETIME
ft
)
{
return
(
ConstructUint64
(
ft
.
dwLowDateTime
,
ft
.
dwHighDateTime
)
-
116444736000000000
)
/
10000000
;
}
static
std
::
chrono
::
system_clock
::
time_point
FileTimeToChrono
(
FILETIME
ft
)
{
// TODO: eliminate the time_t roundtrip, preserve sub-second resolution
return
std
::
chrono
::
system_clock
::
from_time_t
(
FileTimeToTimeT
(
ft
));
}
#endif
class
FileInfo
{
friend
bool
GetFileInfo
(
Path
path
,
FileInfo
&
info
,
bool
follow_symlinks
);
...
...
src/system/Clock.cxx
View file @
5641c4ba
/*
* Copyright 2003-201
8
The Music Player Daemon Project
* Copyright 2003-201
9
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -20,19 +20,9 @@
#include "Clock.hxx"
#ifdef _WIN32
#include
<windows.h>
#include
"time/FileTime.hxx"
gcc_const
static
std
::
chrono
::
seconds
DeltaFileTimeS
(
FILETIME
a
,
FILETIME
b
)
{
ULARGE_INTEGER
a2
,
b2
;
b2
.
LowPart
=
b
.
dwLowDateTime
;
b2
.
HighPart
=
b
.
dwHighDateTime
;
a2
.
LowPart
=
a
.
dwLowDateTime
;
a2
.
HighPart
=
a
.
dwHighDateTime
;
return
std
::
chrono
::
seconds
((
a2
.
QuadPart
-
b2
.
QuadPart
)
/
10000000
);
}
#include <windows.h>
std
::
chrono
::
seconds
GetProcessUptimeS
()
...
...
src/time/FileTime.hxx
0 → 100644
View file @
5641c4ba
/*
* Copyright 2013-2019 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef FILE_TIME_HXX
#define FILE_TIME_HXX
#include <fileapi.h>
#include <chrono>
#include <stdint.h>
static
constexpr
uint64_t
ConstructUint64
(
DWORD
lo
,
DWORD
hi
)
{
return
uint64_t
(
lo
)
|
(
uint64_t
(
hi
)
<<
32
);
}
static
constexpr
time_t
FileTimeToTimeT
(
FILETIME
ft
)
{
return
(
ConstructUint64
(
ft
.
dwLowDateTime
,
ft
.
dwHighDateTime
)
-
116444736000000000
)
/
10000000
;
}
static
inline
std
::
chrono
::
system_clock
::
time_point
FileTimeToChrono
(
FILETIME
ft
)
{
// TODO: eliminate the time_t roundtrip, preserve sub-second resolution
return
std
::
chrono
::
system_clock
::
from_time_t
(
FileTimeToTimeT
(
ft
));
}
gcc_const
static
inline
std
::
chrono
::
seconds
DeltaFileTimeS
(
FILETIME
a
,
FILETIME
b
)
{
ULARGE_INTEGER
a2
,
b2
;
b2
.
LowPart
=
b
.
dwLowDateTime
;
b2
.
HighPart
=
b
.
dwHighDateTime
;
a2
.
LowPart
=
a
.
dwLowDateTime
;
a2
.
HighPart
=
a
.
dwHighDateTime
;
return
std
::
chrono
::
seconds
((
a2
.
QuadPart
-
b2
.
QuadPart
)
/
10000000
);
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment