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
d4cff0cb
Commit
d4cff0cb
authored
Aug 13, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename git__win32_path fns to git_win32_path
parent
3869a171
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
29 deletions
+32
-29
src/fileops.c
+1
-1
src/path.c
+1
-1
src/transports/winhttp.c
+1
-1
src/win32/dir.c
+3
-3
src/win32/posix.h
+1
-1
src/win32/posix_w32.c
+13
-13
src/win32/utf-conv.h
+7
-4
tests-clar/clar_libgit2.c
+5
-5
No files found.
src/fileops.c
View file @
d4cff0cb
...
...
@@ -60,7 +60,7 @@ int git_futils_creat_locked(const char *path, const mode_t mode)
#ifdef GIT_WIN32
git_win32_path
buf
;
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
fd
=
_wopen
(
buf
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_EXCL
|
O_BINARY
|
O_CLOEXEC
,
mode
);
#else
...
...
src/path.c
View file @
d4cff0cb
...
...
@@ -492,7 +492,7 @@ bool git_path_is_empty_dir(const char *path)
if
(
!
git_path_isdir
(
path
))
return
false
;
git_buf_printf
(
&
pathbuf
,
"%s
\\
*"
,
path
);
git_
_
win32_path_from_c
(
wbuf
,
git_buf_cstr
(
&
pathbuf
));
git_win32_path_from_c
(
wbuf
,
git_buf_cstr
(
&
pathbuf
));
hFind
=
FindFirstFileW
(
wbuf
,
&
ffd
);
if
(
INVALID_HANDLE_VALUE
==
hFind
)
{
...
...
src/transports/winhttp.c
View file @
d4cff0cb
...
...
@@ -920,7 +920,7 @@ static int winhttp_connect(
return
-
1
;
/* Prepare host */
git_
_
win32_path_from_c
(
host
,
t
->
host
);
git_win32_path_from_c
(
host
,
t
->
host
);
/* Establish session */
t
->
session
=
WinHttpOpen
(
...
...
src/win32/dir.c
View file @
d4cff0cb
...
...
@@ -39,7 +39,7 @@ git__DIR *git__opendir(const char *dir)
if
(
!
new
->
dir
)
goto
fail
;
git_
_
win32_path_from_c
(
filter_w
,
filter
);
git_win32_path_from_c
(
filter_w
,
filter
);
new
->
h
=
FindFirstFileW
(
filter_w
,
&
new
->
f
);
if
(
new
->
h
==
INVALID_HANDLE_VALUE
)
{
...
...
@@ -79,7 +79,7 @@ int git__readdir_ext(
if
(
wcslen
(
d
->
f
.
cFileName
)
>=
sizeof
(
entry
->
d_name
))
return
-
1
;
git_
_
win32_path_to_c
(
entry
->
d_name
,
d
->
f
.
cFileName
);
git_win32_path_to_c
(
entry
->
d_name
,
d
->
f
.
cFileName
);
entry
->
d_ino
=
0
;
*
result
=
entry
;
...
...
@@ -115,7 +115,7 @@ void git__rewinddir(git__DIR *d)
if
(
!
init_filter
(
filter
,
sizeof
(
filter
),
d
->
dir
))
return
;
git_
_
win32_path_from_c
(
filter_w
,
filter
);
git_win32_path_from_c
(
filter_w
,
filter
);
d
->
h
=
FindFirstFileW
(
filter_w
,
&
d
->
f
);
if
(
d
->
h
==
INVALID_HANDLE_VALUE
)
...
...
src/win32/posix.h
View file @
d4cff0cb
...
...
@@ -24,7 +24,7 @@ GIT_INLINE(int) p_mkdir(const char *path, mode_t mode)
{
git_win32_path
buf
;
GIT_UNUSED
(
mode
);
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
return
_wmkdir
(
buf
);
}
...
...
src/win32/posix_w32.c
View file @
d4cff0cb
...
...
@@ -17,7 +17,7 @@
int
p_unlink
(
const
char
*
path
)
{
git_win32_path
buf
;
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
_wchmod
(
buf
,
0666
);
return
_wunlink
(
buf
);
}
...
...
@@ -63,7 +63,7 @@ static int do_lstat(
wchar_t
lastch
;
int
flen
;
flen
=
git_
_
win32_path_from_c
(
fbuf
,
file_name
);
flen
=
git_win32_path_from_c
(
fbuf
,
file_name
);
/* truncate trailing slashes */
for
(;
flen
>
0
;
--
flen
)
{
...
...
@@ -189,7 +189,7 @@ int p_readlink(const char *link, char *target, size_t target_len)
}
}
git_
_
win32_path_from_c
(
link_w
,
link
);
git_win32_path_from_c
(
link_w
,
link
);
hFile
=
CreateFileW
(
link_w
,
// file to open
GENERIC_READ
,
// open for reading
...
...
@@ -258,7 +258,7 @@ int p_open(const char *path, int flags, ...)
git_win32_path
buf
;
mode_t
mode
=
0
;
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
if
(
flags
&
O_CREAT
)
{
va_list
arg_list
;
...
...
@@ -274,7 +274,7 @@ int p_open(const char *path, int flags, ...)
int
p_creat
(
const
char
*
path
,
mode_t
mode
)
{
git_win32_path
buf
;
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
return
_wopen
(
buf
,
_O_WRONLY
|
_O_CREAT
|
_O_TRUNC
|
_O_BINARY
,
mode
);
}
...
...
@@ -317,14 +317,14 @@ int p_stat(const char* path, struct stat* buf)
int
p_chdir
(
const
char
*
path
)
{
git_win32_path
buf
;
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
return
_wchdir
(
buf
);
}
int
p_chmod
(
const
char
*
path
,
mode_t
mode
)
{
git_win32_path
buf
;
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
return
_wchmod
(
buf
,
mode
);
}
...
...
@@ -332,7 +332,7 @@ int p_rmdir(const char* path)
{
int
error
;
git_win32_path
buf
;
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
error
=
_wrmdir
(
buf
);
...
...
@@ -349,7 +349,7 @@ int p_rmdir(const char* path)
int
p_hide_directory__w32
(
const
char
*
path
)
{
git_win32_path
buf
;
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
return
(
SetFileAttributesW
(
buf
,
FILE_ATTRIBUTE_HIDDEN
)
!=
0
)
?
0
:
-
1
;
}
...
...
@@ -359,7 +359,7 @@ char *p_realpath(const char *orig_path, char *buffer)
git_win32_path
orig_path_w
;
git_win32_path
buffer_w
;
git_
_
win32_path_from_c
(
orig_path_w
,
orig_path
);
git_win32_path_from_c
(
orig_path_w
,
orig_path
);
/* Implicitly use GetCurrentDirectory which can be a threading issue */
ret
=
GetFullPathNameW
(
orig_path_w
,
GIT_WIN_PATH_UTF16
,
buffer_w
,
NULL
);
...
...
@@ -450,7 +450,7 @@ int p_setenv(const char* name, const char* value, int overwrite)
int
p_access
(
const
char
*
path
,
mode_t
mode
)
{
git_win32_path
buf
;
git_
_
win32_path_from_c
(
buf
,
path
);
git_win32_path_from_c
(
buf
,
path
);
return
_waccess
(
buf
,
mode
);
}
...
...
@@ -459,8 +459,8 @@ int p_rename(const char *from, const char *to)
git_win32_path
wfrom
;
git_win32_path
wto
;
git_
_
win32_path_from_c
(
wfrom
,
from
);
git_
_
win32_path_from_c
(
wto
,
to
);
git_win32_path_from_c
(
wfrom
,
from
);
git_win32_path_from_c
(
wto
,
to
);
return
MoveFileExW
(
wfrom
,
wto
,
MOVEFILE_REPLACE_EXISTING
|
MOVEFILE_COPY_ALLOWED
)
?
0
:
-
1
;
}
...
...
src/win32/utf-conv.h
View file @
d4cff0cb
...
...
@@ -11,22 +11,25 @@
#ifndef INCLUDE_git_utfconv_h__
#define INCLUDE_git_utfconv_h__
/* Maximum characters in a Windows path plus one for NUL byte */
#define GIT_WIN_PATH_UTF16 (260 + 1)
/* Maximum bytes necessary to convert a full-length UTF16 path to UTF8 */
#define GIT_WIN_PATH_UTF8 (260 * 4 + 1)
typedef
wchar_t
git_win32_path
[
GIT_WIN_PATH_UTF16
];
/
/ dest_size is the size of dest in wchar_t's
/
* dest_size is the size of dest in wchar_t's */
int
git__utf8_to_16
(
wchar_t
*
dest
,
size_t
dest_size
,
const
char
*
src
);
/
/ dest_size is the size of dest in char's
/
* dest_size is the size of dest in char's */
int
git__utf16_to_8
(
char
*
dest
,
size_t
dest_size
,
const
wchar_t
*
src
);
GIT_INLINE
(
int
)
git_
_
win32_path_from_c
(
git_win32_path
dest
,
const
char
*
src
)
GIT_INLINE
(
int
)
git_win32_path_from_c
(
git_win32_path
dest
,
const
char
*
src
)
{
return
git__utf8_to_16
(
dest
,
GIT_WIN_PATH_UTF16
,
src
);
}
GIT_INLINE
(
int
)
git_
_
win32_path_to_c
(
char
*
dest
,
const
git_win32_path
src
)
GIT_INLINE
(
int
)
git_win32_path_to_c
(
char
*
dest
,
const
git_win32_path
src
)
{
return
git__utf16_to_8
(
dest
,
GIT_WIN_PATH_UTF8
,
src
);
}
...
...
tests-clar/clar_libgit2.c
View file @
d4cff0cb
...
...
@@ -61,7 +61,7 @@ char *cl_getenv(const char *name)
wchar_t
*
value_utf16
;
char
*
value_utf8
;
git_
_
win32_path_from_c
(
name_utf16
,
name
);
git_win32_path_from_c
(
name_utf16
,
name
);
alloc_len
=
GetEnvironmentVariableW
(
name_utf16
,
NULL
,
0
);
if
(
alloc_len
<=
0
)
return
NULL
;
...
...
@@ -84,10 +84,10 @@ int cl_setenv(const char *name, const char *value)
git_win32_path
name_utf16
;
git_win32_path
value_utf16
;
git_
_
win32_path_from_c
(
name_utf16
,
name
);
git_win32_path_from_c
(
name_utf16
,
name
);
if
(
value
)
{
git_
_
win32_path_from_c
(
value_utf16
,
value
);
git_win32_path_from_c
(
value_utf16
,
value
);
cl_assert
(
SetEnvironmentVariableW
(
name_utf16
,
value_utf16
));
}
else
{
/* Windows XP returns 0 (failed) when passing NULL for lpValue when
...
...
@@ -111,8 +111,8 @@ int cl_rename(const char *source, const char *dest)
git_win32_path
dest_utf16
;
unsigned
retries
=
1
;
git_
_
win32_path_from_c
(
source_utf16
,
source
);
git_
_
win32_path_from_c
(
dest_utf16
,
dest
);
git_win32_path_from_c
(
source_utf16
,
source
);
git_win32_path_from_c
(
dest_utf16
,
dest
);
while
(
!
MoveFileW
(
source_utf16
,
dest_utf16
))
{
/* Only retry if the error is ERROR_ACCESS_DENIED;
...
...
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