Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-fileview
Project
Project
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
jenkins
slm-fileview
Commits
a3081ef4
Commit
a3081ef4
authored
Aug 24, 2021
by
Yiding He
Committed by
kl
Aug 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复单元测试失败的问题
parent
43374e02
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
11 deletions
+33
-11
ConfigUtils.java
.../java/org/artofsolving/jodconverter/util/ConfigUtils.java
+33
-11
No files found.
office-plugin/src/main/java/org/artofsolving/jodconverter/util/ConfigUtils.java
View file @
a3081ef4
...
...
@@ -29,22 +29,44 @@ public class ConfigUtils {
return
userDir
;
}
// 获取环境变量,如果找不到则返回默认值
@SuppressWarnings
(
"SameParameterValue"
)
private
static
String
env
(
String
key
,
String
def
)
{
String
value
=
System
.
getenv
(
key
);
return
value
==
null
?
def
:
value
;
}
public
static
String
getOfficePluginPath
()
{
String
userDir
=
System
.
getenv
(
"KKFILEVIEW_BIN_FOLDER"
);
if
(
userDir
==
null
)
{
userDir
=
System
.
getProperty
(
"user.dir"
);
// 返回参数列表中第一个真实存在的路径,或者 null
private
static
String
firstExists
(
File
...
paths
)
{
for
(
File
path
:
paths
)
{
if
(
path
.
exists
())
{
return
path
.
getAbsolutePath
();
}
}
if
(
userDir
.
endsWith
(
"bin"
))
{
userDir
=
userDir
.
substring
(
0
,
userDir
.
length
()
-
4
);
return
null
;
}
public
static
String
getOfficePluginPath
()
{
String
userDir
=
System
.
getProperty
(
"user.dir"
);
String
binFolder
=
env
(
"KKFILEVIEW_BIN_FOLDER"
,
userDir
);
File
pluginPath
=
new
File
(
binFolder
);
// 如果指定了 bin 或其父目录,则返回父目录
// 否则在当前目录和父目录中寻找 office-plugin
if
(
new
File
(
pluginPath
,
"bin"
).
exists
())
{
return
pluginPath
.
getAbsolutePath
();
}
else
if
(
pluginPath
.
exists
()
&&
pluginPath
.
getName
().
equals
(
"bin"
))
{
return
pluginPath
.
getParentFile
().
getAbsolutePath
();
}
else
{
String
separator
=
File
.
separator
;
if
(!
userDir
.
contains
(
OFFICE_PLUGIN_NAME
))
{
userDir
=
userDir
+
separator
+
OFFICE_PLUGIN_NAME
;
return
firstExists
(
new
File
(
pluginPath
,
OFFICE_PLUGIN_NAME
),
new
File
(
pluginPath
.
getParentFile
(),
OFFICE_PLUGIN_NAME
)
);
}
}
return
userDir
;
}
public
static
String
getCustomizedConfigPath
()
{
String
homePath
=
getHomePath
();
...
...
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