Skip to content

Commit

Permalink
Merge pull request #12 from os97673/jb-patch
Browse files Browse the repository at this point in the history
Provide system property to not unpack dlls' into parent dir
  • Loading branch information
kohsuke committed Jan 21, 2015
2 parents e4dfa10 + 6a1f11e commit 3102951
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/org/jvnet/winp/Native.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Native {
private static final Logger LOGGER = Logger.getLogger(Native.class.getName());
// system property holding the preferred folder for copying the dll file to.
private static final String DLL_TARGET = "winp.folder.preferred";
private static final String UNPACK_DLL_TO_PARENT_DIR = "winp.unpack.dll.to.parent.dir";

static {
load();
Expand Down Expand Up @@ -85,7 +86,12 @@ private static void load() {
final URL res = Native.class.getClassLoader().getResource(dllName+".dll");
if(res!=null) {
String url = res.toExternalForm();
if(url.startsWith("jar:") || url.startsWith("wsjar:")) {

//patched by JetBrains: do not try to unpack the dll file to the directory containing the jar file by default.
// It can fail because the process has no rights to write to that directory and also pollutes the project directories if the jar is used in development mode.
boolean unpackToParentDir = Boolean.parseBoolean(System.getProperty(UNPACK_DLL_TO_PARENT_DIR, "true"));

if(unpackToParentDir && (url.startsWith("jar:") || url.startsWith("wsjar:"))) {
int idx = url.lastIndexOf('!');
String filePortion = url.substring(url.indexOf(':')+1,idx);
while(filePortion.startsWith("/"))
Expand Down

0 comments on commit 3102951

Please sign in to comment.