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 changeDir(String dirName); //cd
void backDir(); //cd .. void backDir(); //cd ..
void backRootDir(); //cd / void backRootDir(); //cd /
List<String> getDirList(); //ls List<Path> getList();
List<String> getFileList(); //ls
void createDir(); void createDir();
void removeDir(); void removeDir();

View File

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