Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
360dd4da
Commit
360dd4da
authored
Jun 23, 2015
by
Axel Rasmussen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32: define our own POSIX struct stat, and support USE_NSEC
parent
c963fe1d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
18 deletions
+58
-18
CMakeLists.txt
+1
-1
src/common.h
+1
-0
src/win32/mingw-compat.h
+0
-6
src/win32/msvc-compat.h
+0
-3
src/win32/w32_util.h
+14
-8
src/win32/win32-compat.h
+42
-0
No files found.
CMakeLists.txt
View file @
360dd4da
...
...
@@ -87,7 +87,7 @@ ENDIF()
CHECK_STRUCT_HAS_MEMBER
(
"struct stat"
st_mtim.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C
)
IF
(
HAVE_STRUCT_STAT_NSEC
)
IF
(
HAVE_STRUCT_STAT_NSEC
OR WIN32
)
OPTION
(
USE_NSEC
"Care about sub-second file mtimes and ctimes"
OFF
)
ENDIF
()
...
...
src/common.h
View file @
360dd4da
...
...
@@ -41,6 +41,7 @@
# include <ws2tcpip.h>
# include "win32/msvc-compat.h"
# include "win32/mingw-compat.h"
# include "win32/win32-compat.h"
# include "win32/error.h"
# include "win32/version.h"
# ifdef GIT_THREADS
...
...
src/win32/mingw-compat.h
View file @
360dd4da
...
...
@@ -11,12 +11,6 @@
#undef stat
#if _WIN32_WINNT >= 0x0601
#define stat __stat64
#else
#define stat _stati64
#endif
#if _WIN32_WINNT < 0x0600 && !defined(__MINGW64_VERSION_MAJOR)
#undef MemoryBarrier
void
__mingworg_MemoryBarrier
(
void
);
...
...
src/win32/msvc-compat.h
View file @
360dd4da
...
...
@@ -9,9 +9,6 @@
#if defined(_MSC_VER)
/* 64-bit stat information, regardless of USE_32BIT_TIME_T define */
#define stat __stat64
typedef
unsigned
short
mode_t
;
typedef
SSIZE_T
ssize_t
;
...
...
src/win32/w32_util.h
View file @
360dd4da
...
...
@@ -76,17 +76,23 @@ size_t git_win32__path_trim_end(wchar_t *str, size_t len);
size_t
git_win32__canonicalize_path
(
wchar_t
*
str
,
size_t
len
);
/**
* Converts a FILETIME structure to a
time_t
.
* Converts a FILETIME structure to a
struct timespec
.
*
* @param FILETIME A pointer to a FILETIME
* @
return A time_t containing the same time
* @
param ts A pointer to the timespec structure to fill in
*/
GIT_INLINE
(
time_t
)
git_win32__filetime_to_time_t
(
const
FILETIME
*
ft
)
GIT_INLINE
(
void
)
git_win32__filetime_to_timespec
(
const
FILETIME
*
ft
,
struct
timespec
*
ts
)
{
long
long
winTime
=
((
long
long
)
ft
->
dwHighDateTime
<<
32
)
+
ft
->
dwLowDateTime
;
winTime
-=
116444736000000000LL
;
/* Windows to Unix Epoch conversion */
winTime
/=
10000000
;
/* Nano to seconds resolution */
return
(
time_t
)
winTime
;
ts
->
tv_sec
=
(
time_t
)(
winTime
/
10000000
);
#ifdef GIT_USE_NSEC
ts
->
tv_nsec
=
(
winTime
%
10000000
)
*
100
;
#else
ts
->
tv_nsec
=
0
;
#endif
}
GIT_INLINE
(
void
)
git_win32__timeval_to_filetime
(
...
...
@@ -122,9 +128,9 @@ GIT_INLINE(int) git_win32__file_attribute_to_stat(
st
->
st_size
=
((
git_off_t
)
attrdata
->
nFileSizeHigh
<<
32
)
+
attrdata
->
nFileSizeLow
;
st
->
st_dev
=
_getdrive
()
-
1
;
st
->
st_rdev
=
st
->
st_dev
;
st
->
st_atime
=
git_win32__filetime_to_time_t
(
&
(
attrdata
->
ftLastAccessTime
));
st
->
st_mtime
=
git_win32__filetime_to_time_t
(
&
(
attrdata
->
ftLastWriteTime
));
st
->
st_ctime
=
git_win32__filetime_to_time_t
(
&
(
attrdata
->
ftCreationTime
));
git_win32__filetime_to_timespec
(
&
(
attrdata
->
ftLastAccessTime
),
&
(
st
->
st_atim
));
git_win32__filetime_to_timespec
(
&
(
attrdata
->
ftLastWriteTime
),
&
(
st
->
st_mtim
));
git_win32__filetime_to_timespec
(
&
(
attrdata
->
ftCreationTime
),
&
(
st
->
st_ctim
));
if
(
attrdata
->
dwFileAttributes
&
FILE_ATTRIBUTE_REPARSE_POINT
&&
path
)
{
git_win32_path
target
;
...
...
src/win32/win32-compat.h
0 → 100644
View file @
360dd4da
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_win32_compat__
#define INCLUDE_win32_compat__
#include <stdint.h>
#include <time.h>
#include <wchar.h>
#include <sys/stat.h>
#include <sys/types.h>
struct
p_timespec
{
time_t
tv_sec
;
long
tv_nsec
;
};
#define timespec p_timespec
struct
p_stat
{
_dev_t
st_dev
;
_ino_t
st_ino
;
mode_t
st_mode
;
short
st_nlink
;
short
st_uid
;
short
st_gid
;
_dev_t
st_rdev
;
uint64_t
st_size
;
struct
timespec
st_atim
;
struct
timespec
st_mtim
;
struct
timespec
st_ctim
;
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
};
#define stat p_stat
#endif
/* INCLUDE_win32_compat__ */
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