Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
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
liuqiang
skiko
Commits
2b43feb1
Unverified
Commit
2b43feb1
authored
Apr 14, 2021
by
Nikolay Igotti
Committed by
GitHub
Apr 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Windows loading from non-ASCII paths (#91)
parent
9f17aba6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
jawt.cc
skiko/src/jvmMain/cpp/common/jawt.cc
+17
-6
No files found.
skiko/src/jvmMain/cpp/common/jawt.cc
View file @
2b43feb1
...
...
@@ -4,6 +4,7 @@
#if SK_BUILD_FOR_WIN
#include <windows.h>
#include <strsafe.h>
#else
#include <dlfcn.h>
#endif
...
...
@@ -28,7 +29,11 @@ bool check(JNIEnv* env, const char* msg) {
}
#endif
#if SK_BUILD_FOR_WIN
void
findJdkHome
(
JNIEnv
*
env
,
wchar_t
*
path
,
int
pathLength
)
{
#else
void
findJdkHome
(
JNIEnv
*
env
,
char
*
path
,
int
pathLength
)
{
#endif
jclass
systemClass
=
env
->
FindClass
(
"java/lang/System"
);
jmethodID
getPropertyMethod
=
env
->
GetStaticMethodID
(
systemClass
,
...
...
@@ -36,27 +41,33 @@ void findJdkHome(JNIEnv* env, char* path, int pathLength) {
"(Ljava/lang/String;)Ljava/lang/String;"
);
jstring
javaHomeString
=
env
->
NewStringUTF
(
"java.home"
);
jstring
propertyString
=
(
jstring
)
env
->
CallStaticObjectMethod
(
systemClass
,
getPropertyMethod
,
javaHomeString
);
#if SK_BUILD_FOR_WIN
const
jchar
*
propertyChars
=
env
->
GetStringChars
(
propertyString
,
0
);
StringCchPrintfW
(
path
,
pathLength
,
L"%ls"
,
propertyChars
);
env
->
ReleaseStringChars
(
propertyString
,
propertyChars
);
#else
const
char
*
propertyChars
=
env
->
GetStringUTFChars
(
propertyString
,
0
);
snprintf
(
path
,
pathLength
,
"%s"
,
propertyChars
);
env
->
ReleaseStringUTFChars
(
propertyString
,
propertyChars
);
#endif
}
extern
"C"
jboolean
Skiko_GetAWT
(
JNIEnv
*
env
,
JAWT
*
awt
)
{
static
JAWT_GetAWT_t
func
=
nullptr
;
#if SK_BUILD_FOR_WIN
if
(
!
func
)
{
char
jdkHome
[
FILENAME_MAX
];
wchar_t
jdkHome
[
FILENAME_MAX
];
findJdkHome
(
env
,
jdkHome
,
sizeof
(
jdkHome
));
char
path
[
FILENAME_MAX
];
snprintf
(
path
,
sizeof
(
path
),
"%
s
\\
bin
\\
jawt.dll"
,
jdkHome
);
HMODULE
lib
=
LoadLibrary
(
path
);
wchar_t
path
[
FILENAME_MAX
];
StringCchPrintfW
(
path
,
sizeof
(
path
),
L"%l
s
\\
bin
\\
jawt.dll"
,
jdkHome
);
HMODULE
lib
=
LoadLibrary
W
(
path
);
if
(
!
lib
)
{
fprintf
(
stderr
,
"Cannot open %s
\n
"
,
path
);
fprintf
(
stderr
,
"Cannot open %
l
s
\n
"
,
path
);
abort
();
}
func
=
reinterpret_cast
<
JAWT_GetAWT_t
>
(
GetProcAddress
(
lib
,
"JAWT_GetAWT"
));
if
(
!
func
)
{
fprintf
(
stderr
,
"Cannot find JAWT_GetAWT in %s
\n
"
,
path
);
fprintf
(
stderr
,
"Cannot find JAWT_GetAWT in %
l
s
\n
"
,
path
);
abort
();
}
}
...
...
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