Fix FS_Win32 if a non-directory is listed

FS.list() is supposed to return an empty array if the File given is not
a directory.

Bug: 550111
Change-Id: I245da5f1f2bdafd9dfb38fb8d7eff27d900cd5a8
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
Thomas Wolf 2022-01-31 09:39:12 +01:00 committed by Matthias Sohn
parent 0588dd0a9f
commit 8dcb86b602
1 changed files with 4 additions and 0 deletions

View File

@ -16,6 +16,7 @@
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
@ -96,6 +97,9 @@ public boolean retryFailedLockFileCommit() {
/** {@inheritDoc} */
@Override
public Entry[] list(File directory, FileModeStrategy fileModeStrategy) {
if (!Files.isDirectory(directory.toPath(), LinkOption.NOFOLLOW_LINKS)) {
return NO_ENTRIES;
}
List<Entry> result = new ArrayList<>();
FS fs = this;
boolean checkExecutable = fs.supportsExecute();