diff --git a/source/src/main/java/one/nem/lacerta/source/file/FileManager.java b/source/src/main/java/one/nem/lacerta/source/file/FileManager.java index 56b50791..0fa4062b 100644 --- a/source/src/main/java/one/nem/lacerta/source/file/FileManager.java +++ b/source/src/main/java/one/nem/lacerta/source/file/FileManager.java @@ -11,8 +11,7 @@ public interface FileManager { void changeDir(String dirName); //cd void backDir(); //cd .. void backRootDir(); //cd / - List getDirList(); //ls - List getFileList(); //ls + List getList(); void createDir(); void removeDir(); diff --git a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java index 43e19657..758737b1 100644 --- a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java +++ b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java @@ -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 getDirList() { - // currentDirにあるディレクトリの一覧を返す - return Arrays.asList(currentDir.toFile().list()); - } - - @Override - public List getFileList() { - return null; + public List getList() { + List list = new ArrayList<>(); + try (DirectoryStream stream = Files.newDirectoryStream(currentDir)) { + for (Path entry : stream) { + if (Files.isDirectory(entry)) { + list.add(entry); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + return list; } @Override