getList修正

This commit is contained in:
ろむねこ 2023-12-21 15:05:56 +09:00 committed by r-ca
parent d203b1b76e
commit 2f21ecd6bd
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 17 additions and 10 deletions

View File

@ -11,8 +11,7 @@ public interface FileManager {
void changeDir(String dirName); //cd
void backDir(); //cd ..
void backRootDir(); //cd /
List<String> getDirList(); //ls
List<String> getFileList(); //ls
List<Path> getList();
void createDir();
void removeDir();

View File

@ -2,7 +2,11 @@ package one.nem.lacerta.source.file.impl;
import android.graphics.Bitmap;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -54,14 +58,18 @@ public class FileManagerImpl implements FileManager {
}
@Override
public List<String> getDirList() {
// currentDirにあるディレクトリの一覧を返す
return Arrays.asList(currentDir.toFile().list());
}
@Override
public List<String> getFileList() {
return null;
public List<Path> getList() {
List<Path> list = new ArrayList<>();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(currentDir)) {
for (Path entry : stream) {
if (Files.isDirectory(entry)) {
list.add(entry);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return list;
}
@Override