Cleanup (formatting; typos)

GitOrigin-RevId: a4c670b18cd362e44326f8cd616c2b14f42259f7
This commit is contained in:
Roman Shevchenko
2024-10-14 15:23:09 +00:00
committed by intellij-monorepo-bot
parent 2592a1e828
commit cabd5fea91
@@ -518,17 +518,12 @@ public abstract class LocalFileSystemBase extends LocalFileSystem {
if (SystemInfo.isWindows) {
return nioFile.toRealPath(LinkOption.NOFOLLOW_LINKS).getFileName().toString();
}
else {
// Handle one common case as quickly as possible: compute the file's realpath, resolving links
// (to avoid quadratic behaviour from directory listing). In general this is not a suitable canonical name for the
// file, because links have been resolved, but if the result compares with case-insensitive equality with the given
// file's path, then the return value is suitable for use as a canonical name.
var resolvedRealPath = nioFile.toRealPath();
if (resolvedRealPath.toString().equalsIgnoreCase(file.getPath())) {
return resolvedRealPath.getFileName().toString();
}
// `toRealPath(NOFOLLOW_LINKS)` is too slow on Unix; `toRealPath()` works when there are no symlinks
var realPath = nioFile.toRealPath();
if (realPath.toString().equalsIgnoreCase(file.getPath())) {
return realPath.getFileName().toString();
}
// `Path#toRealPath` resolves the whole path starting from the root, but only the last component is necessary
// last resort: listing files in the parent directory
try (var stream = Files.newDirectoryStream(convertToNioFileAndCheck(parent, false))) {
for (var path : stream) {
var name = path.getFileName().toString();