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
544139f5
Commit
544139f5
authored
Apr 28, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
win32: keep full path for realpath usage
parent
c074d7a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
8 deletions
+34
-8
src/win32/path_w32.c
+34
-8
No files found.
src/win32/path_w32.c
View file @
544139f5
...
...
@@ -362,6 +362,30 @@ GIT_INLINE(int) path_with_stat_alloc(
return
0
;
}
GIT_INLINE
(
int
)
path_add_base
(
git_win32_path
out
,
size_t
dir_len
,
wchar_t
*
base
,
size_t
base_len
)
{
size_t
out_len
;
if
(
GIT_ADD_SIZET_OVERFLOW
(
&
out_len
,
dir_len
,
base_len
)
<
0
||
GIT_ADD_SIZET_OVERFLOW
(
&
out_len
,
out_len
,
2
)
<
0
)
return
-
1
;
if
(
out_len
>
GIT_WIN_PATH_UTF16
)
{
giterr_set
(
GITERR_FILESYSTEM
,
"invalid path '%.*ls
\\
%.*ls' (path too long)"
,
dir_len
,
out
,
base_len
,
base
);
return
-
1
;
}
out
[
dir_len
]
=
'\\'
;
memcpy
(
&
out
[
dir_len
+
1
],
base
,
base_len
*
sizeof
(
wchar_t
));
out
[
out_len
-
1
]
=
'\0'
;
return
0
;
}
#if !defined(__MINGW32__)
int
git_win32_path_dirload_with_stat
(
const
char
*
path
,
...
...
@@ -373,16 +397,17 @@ int git_win32_path_dirload_with_stat(
{
int
error
=
0
;
git_path_with_stat
*
ps
;
git_win32_path
path
w
;
git_win32_path
path
_filter
,
file_path
;
DIR
dir
=
{
0
};
int
(
*
strncomp
)(
const
char
*
a
,
const
char
*
b
,
size_t
sz
);
size_t
cmp_len
;
size_t
start_len
=
start_stat
?
strlen
(
start_stat
)
:
0
;
size_t
end_len
=
end_stat
?
strlen
(
end_stat
)
:
0
;
size_t
path_len
,
suffix_len
,
cmp_len
;
const
char
*
suffix
;
size_t
path_len
,
suffix
_len
;
int
root
_len
;
if
(
!
git_win32__findfirstfile_filter
(
pathw
,
path
))
{
if
((
root_len
=
git_win32_path_from_utf8
(
file_path
,
path
))
<
0
||
!
git_win32__findfirstfile_filter
(
path_filter
,
path
))
{
giterr_set
(
GITERR_OS
,
"Could not parse the path '%s'"
,
path
);
return
-
1
;
}
...
...
@@ -399,7 +424,7 @@ int git_win32_path_dirload_with_stat(
* flag should be ignored on previous version of Windows.
*/
dir
.
h
=
FindFirstFileExW
(
path
w
,
path
_filter
,
FindExInfoBasic
,
&
dir
.
f
,
FindExSearchNameMatch
,
...
...
@@ -416,7 +441,8 @@ int git_win32_path_dirload_with_stat(
if
(
git_path_is_dot_or_dotdotW
(
dir
.
f
.
cFileName
))
continue
;
if
((
error
=
path_with_stat_alloc
(
&
ps
,
if
((
error
=
path_add_base
(
file_path
,
root_len
,
dir
.
f
.
cFileName
,
wcslen
(
dir
.
f
.
cFileName
)))
<
0
||
(
error
=
path_with_stat_alloc
(
&
ps
,
suffix
,
suffix_len
,
dir
.
f
.
cFileName
,
(
dir
.
f
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
!=
0
))
<
0
)
goto
clean_up_and_exit
;
...
...
@@ -433,9 +459,9 @@ int git_win32_path_dirload_with_stat(
continue
;
if
((
error
=
git_win32__file_attribute_to_stat
(
&
ps
->
st
,
(
WIN32_FILE_ATTRIBUTE_DATA
*
)
&
dir
.
f
,
NULL
))
<
0
)
(
WIN32_FILE_ATTRIBUTE_DATA
*
)
&
dir
.
f
,
file_path
))
<
0
)
{
goto
clean_up_and_exit
;
}
}
while
(
FindNextFileW
(
dir
.
h
,
&
dir
.
f
));
if
(
GetLastError
()
!=
ERROR_NO_MORE_FILES
)
{
...
...
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