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
6d0ef974
Commit
6d0ef974
authored
Sep 19, 2011
by
Paul Betts
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix opendir/readdir and friends on Win32 to use Unicode
parent
7998ae5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
src/dir.h
+1
-1
src/win32/dir.c
+14
-5
No files found.
src/dir.h
View file @
6d0ef974
...
...
@@ -22,7 +22,7 @@ struct git__dirent {
typedef
struct
{
HANDLE
h
;
WIN32_FIND_DATA
f
;
WIN32_FIND_DATA
W
f
;
struct
git__dirent
entry
;
char
*
dir
;
int
first
;
...
...
src/win32/dir.c
View file @
6d0ef974
...
...
@@ -26,6 +26,7 @@ static int init_filter(char *filter, size_t n, const char *dir)
git__DIR
*
git__opendir
(
const
char
*
dir
)
{
char
filter
[
4096
];
wchar_t
*
filter_w
;
git__DIR
*
new
;
if
(
!
dir
||
!
init_filter
(
filter
,
sizeof
(
filter
),
dir
))
...
...
@@ -42,7 +43,10 @@ git__DIR *git__opendir(const char *dir)
}
strcpy
(
new
->
dir
,
dir
);
new
->
h
=
FindFirstFile
(
filter
,
&
new
->
f
);
filter_w
=
conv_utf8_to_utf16
(
filter
);
new
->
h
=
FindFirstFileW
(
filter_w
,
&
new
->
f
);
free
(
filter_w
);
if
(
new
->
h
==
INVALID_HANDLE_VALUE
)
{
free
(
new
->
dir
);
free
(
new
);
...
...
@@ -61,15 +65,15 @@ struct git__dirent *git__readdir(git__DIR *d)
if
(
d
->
first
)
d
->
first
=
0
;
else
{
if
(
!
FindNextFile
(
d
->
h
,
&
d
->
f
))
if
(
!
FindNextFile
W
(
d
->
h
,
&
d
->
f
))
return
NULL
;
}
if
(
str
len
(
d
->
f
.
cFileName
)
>=
sizeof
(
d
->
entry
.
d_name
))
if
(
wcs
len
(
d
->
f
.
cFileName
)
>=
sizeof
(
d
->
entry
.
d_name
))
return
NULL
;
d
->
entry
.
d_ino
=
0
;
strcpy
(
d
->
entry
.
d_name
,
d
->
f
.
cFileName
);
WideCharToMultiByte
(
CP_UTF8
,
0
,
d
->
f
.
cFileName
,
-
1
,
d
->
entry
.
d_name
,
GIT_PATH_MAX
,
NULL
,
NULL
);
return
&
d
->
entry
;
}
...
...
@@ -77,14 +81,19 @@ struct git__dirent *git__readdir(git__DIR *d)
void
git__rewinddir
(
git__DIR
*
d
)
{
char
filter
[
4096
];
wchar_t
*
filter_w
;
if
(
d
)
{
if
(
d
->
h
!=
INVALID_HANDLE_VALUE
)
FindClose
(
d
->
h
);
d
->
h
=
INVALID_HANDLE_VALUE
;
d
->
first
=
0
;
if
(
init_filter
(
filter
,
sizeof
(
filter
),
d
->
dir
))
{
d
->
h
=
FindFirstFile
(
filter
,
&
d
->
f
);
filter_w
=
conv_utf8_to_utf16
(
filter
);
d
->
h
=
FindFirstFileW
(
filter_w
,
&
d
->
f
);
free
(
filter_w
);
if
(
d
->
h
!=
INVALID_HANDLE_VALUE
)
d
->
first
=
1
;
}
...
...
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