Skip to content

Commit

Permalink
Return back
Browse files Browse the repository at this point in the history
  • Loading branch information
mikir committed Dec 6, 2024
1 parent 68fbb85 commit 542bb71
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions compiler/core/src/zserio/tools/ExtensionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,23 @@ private File getWorkingDirectory()
{
try
{
final URL execUrl = getClass().getProtectionDomain().getCodeSource().getLocation();
System.out.println("execUrl = " + execUrl);
final String decodedExecUrlPath = URLDecoder.decode(execUrl.getPath(), "UTF-8");
final File decodedExecFile = new File(new URI(decodedExecUrlPath));
final String execUrlPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
final String decodedExecUrlPath = URLDecoder.decode(execUrlPath, "UTF-8");
// check if decodedExecUrlPath is really URL, newer Java versions 11 or 17 returns normal path
System.out.println("decodedExecUrlPath = " + decodedExecUrlPath);
File decodedExecFile = null;
try
{
decodedExecFile = new File(new URI(decodedExecUrlPath));
}
catch (URISyntaxException | IllegalArgumentException excpt)
{
decodedExecFile = new File(decodedExecUrlPath);
}
if (decodedExecFile.getPath().startsWith("file:"))
{
decodedExecFile = new File(decodedExecFile.getPath().replaceFirst("^file:", ""));
}

System.out.println("decodedExecFile = " + decodedExecFile);
System.out.println("decodedExecFile.getParentFile() = " + decodedExecFile.getParentFile());
Expand All @@ -156,7 +169,7 @@ private File getWorkingDirectory()

return decodedExecFile.getParentFile();
}
catch (SecurityException | URISyntaxException | UnsupportedEncodingException excpt)
catch (SecurityException | UnsupportedEncodingException excpt)
{
return null;
}
Expand Down

0 comments on commit 542bb71

Please sign in to comment.