Skip to content

Commit

Permalink
Rewording comments
Browse files Browse the repository at this point in the history
  • Loading branch information
malhotrashivam committed Mar 13, 2024
1 parent a6b7339 commit 7188aa3
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ static URI convertToURI(final String source, final boolean isDirectory) {
}

/**
* Takes a file and convert it to a URI object. We should use this method instead of {@link File#toURI()} because
* {@link File#toURI()} internally calls {@link File#isDirectory()}, which can lead to disk access.
* Takes a file and convert it to a URI object. This method is preferred instead of {@link File#toURI()} because
* {@link File#toURI()} internally calls {@link File#isDirectory()}, which typically invokes the {@code stat} system
* call, resulting in filesystem metadata access.
*
* @param file The file
* @param isDirectory Whether the source file is a directory
* @return The URI object
*/
static URI convertToURI(final File file, final boolean isDirectory) {
String absPath = file.getAbsolutePath();
if (absPath.isEmpty()) {
throw new IllegalArgumentException("Cannot convert file with empty path to URI: " + file);
}
if (File.separatorChar != '/') {
absPath = absPath.replace(File.separatorChar, '/');
}
Expand All @@ -75,9 +73,8 @@ static URI convertToURI(final File file, final boolean isDirectory) {
}

/**
* Takes a path and convert it to a URI object. We should use this method instead of {@link Path#toUri()} because
* {@link Path#toUri()} internally does a {@code stat} system call to extract information whether file is a
* directory.
* Takes a path and convert it to a URI object. This method is preferred instead of {@link Path#toUri()} because
* {@link Path#toUri()} internally invokes the {@code stat} system call, resulting in filesystem metadata access.
*
* @param path The path
* @param isDirectory Whether the file is a directory
Expand Down

0 comments on commit 7188aa3

Please sign in to comment.