-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use GetTempPath2 API instead of GetTempPath #21
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -321,6 +321,26 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country, | |
return TRUE; | ||
} | ||
|
||
// For dynamic lookup of GetTempPath2 API | ||
typedef DWORD (WINAPI *GetTempPath2WFnPtr)(DWORD, LPWSTR); | ||
static GetTempPath2WFnPtr _GetTempPath2W = NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the code should use "nullptr" instead of NULL? I'm OK with it being "NULL" if other places in the file also uses NULL. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why all these leading "_" ? Is that a coding guideline for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using NULL as it is C code and others are C++. |
||
static BOOL _GetTempPath2WInitialized = FALSE; | ||
|
||
DWORD _GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) | ||
{ | ||
if (!_GetTempPath2WInitialized) { | ||
HINSTANCE _kernelbase = LoadLibrary(TEXT("kernelbase.dll")); | ||
if (_kernelbase != NULL) { | ||
_GetTempPath2W = (GetTempPath2WFnPtr)GetProcAddress(_kernelbase, "GetTempPath2W"); | ||
} | ||
_GetTempPath2WInitialized = TRUE; | ||
} | ||
if (_GetTempPath2W != NULL) { | ||
return _GetTempPath2W(nBufferLength, lpBuffer); | ||
} | ||
return GetTempPathW(nBufferLength, lpBuffer); | ||
} | ||
|
||
// GetVersionEx is deprecated; disable the warning until a replacement is found | ||
#pragma warning(disable : 4996) | ||
java_props_t * | ||
|
@@ -339,7 +359,7 @@ GetJavaProperties(JNIEnv* env) | |
{ | ||
WCHAR tmpdir[MAX_PATH + 1]; | ||
/* we might want to check that this succeed */ | ||
GetTempPathW(MAX_PATH + 1, tmpdir); | ||
_GetTempPathW(MAX_PATH + 1, tmpdir); | ||
sprops.tmp_dir = _wcsdup(tmpdir); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the code indentation here is not correct. Is it?