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
ec56af08
Commit
ec56af08
authored
Jan 31, 2013
by
Sven Strickroth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored: Move msysgit registry detection to it's own function
Signed-off-by: Sven Strickroth <email@cs-ware.de>
parent
aa3bf89d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
17 deletions
+25
-17
src/win32/findfile.c
+24
-17
src/win32/findfile.h
+1
-0
No files found.
src/win32/findfile.c
View file @
ec56af08
...
...
@@ -113,14 +113,32 @@ int win32_find_system_file_using_registry(git_buf *path, const char *filename)
{
struct
win32_path
root
;
if
(
win32_find_msysgit_in_registry
(
&
root
,
HKEY_LOCAL_MACHINE
,
REG_MSYSGIT_INSTALL
))
{
giterr_set
(
GITERR_OS
,
"Cannot locate the system's msysgit directory"
);
return
-
1
;
}
if
(
win32_find_file
(
path
,
&
root
,
filename
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"The system file '%s' doesn't exist"
,
filename
);
git_buf_clear
(
path
);
return
GIT_ENOTFOUND
;
}
return
0
;
}
int
win32_find_msysgit_in_registry
(
struct
win32_path
*
root
,
const
HKEY
hieve
,
const
wchar_t
*
key
)
{
HKEY
hKey
;
DWORD
dwType
=
REG_SZ
;
DWORD
dwSize
=
MAX_PATH
;
root
.
len
=
0
;
if
(
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
REG_MSYSGIT_INSTALL
,
0
,
KEY_ALL_ACCESS
,
&
hKey
)
==
ERROR_SUCCESS
)
assert
(
root
);
root
->
len
=
0
;
if
(
RegOpenKeyExW
(
hieve
,
key
,
0
,
KEY_ALL_ACCESS
,
&
hKey
)
==
ERROR_SUCCESS
)
{
if
(
RegQueryValueExW
(
hKey
,
L"InstallLocation"
,
NULL
,
&
dwType
,
(
LPBYTE
)
&
root
.
path
,
&
dwSize
)
==
ERROR_SUCCESS
)
if
(
RegQueryValueExW
(
hKey
,
L"InstallLocation"
,
NULL
,
&
dwType
,
(
LPBYTE
)
&
root
->
path
,
&
dwSize
)
==
ERROR_SUCCESS
)
{
// InstallLocation points to the root of the msysgit directory
if
(
dwSize
+
4
>
MAX_PATH
)
// 4 = wcslen(L"etc\\")
...
...
@@ -128,22 +146,11 @@ int win32_find_system_file_using_registry(git_buf *path, const char *filename)
giterr_set
(
GITERR_OS
,
"Cannot locate the system's msysgit directory - path too long"
);
return
-
1
;
}
wcscat
(
root
.
path
,
L"etc
\\
"
);
root
.
len
=
(
DWORD
)
wcslen
(
root
.
path
)
+
1
;
wcscat
(
root
->
path
,
L"etc
\\
"
);
root
->
len
=
(
DWORD
)
wcslen
(
root
->
path
)
+
1
;
}
}
RegCloseKey
(
hKey
);
if
(
!
root
.
len
)
{
giterr_set
(
GITERR_OS
,
"Cannot locate the system's msysgit directory"
);
return
-
1
;
}
if
(
win32_find_file
(
path
,
&
root
,
filename
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"The system file '%s' doesn't exist"
,
filename
);
git_buf_clear
(
path
);
return
GIT_ENOTFOUND
;
}
return
0
;
return
root
->
len
?
0
:
GIT_ENOTFOUND
;
}
src/win32/findfile.h
View file @
ec56af08
...
...
@@ -18,6 +18,7 @@ int win32_expand_path(struct win32_path *s_root, const wchar_t *templ);
int
win32_find_file
(
git_buf
*
path
,
const
struct
win32_path
*
root
,
const
char
*
filename
);
int
win32_find_system_file_using_path
(
git_buf
*
path
,
const
char
*
filename
);
int
win32_find_system_file_using_registry
(
git_buf
*
path
,
const
char
*
filename
);
int
win32_find_msysgit_in_registry
(
struct
win32_path
*
root
,
const
HKEY
hieve
,
const
wchar_t
*
key
);
#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