Skip to content

Commit

Permalink
fix: For failure in path to URI conversion on windows (#5779)
Browse files Browse the repository at this point in the history
  • Loading branch information
malhotrashivam authored Jul 17, 2024
1 parent 8f54141 commit 1c00bd2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Base/src/main/java/io/deephaven/base/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ public static URI convertToURI(final File file, final boolean isDirectory) {
if (isDirectory && absPath.charAt(absPath.length() - 1) != URI_SEPARATOR_CHAR) {
absPath = absPath + URI_SEPARATOR_CHAR;
}
if (absPath.charAt(0) != URI_SEPARATOR_CHAR) {
absPath = URI_SEPARATOR_CHAR + absPath;
// ^This is especially useful for Windows where the absolute path does not start with a slash.
// For example, for absolute path "C:\path\to\file", the URI would be "file:/C:/path/to/file".
}
try {
return new URI(FILE_URI_SCHEME, null, absPath, null);
} catch (final URISyntaxException e) {
Expand Down

0 comments on commit 1c00bd2

Please sign in to comment.