ファイル名から検索するメソッドを追加

This commit is contained in:
r-ca 2024-01-08 11:35:09 +09:00
parent 656482e968
commit 1ee0a1b8ea
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 18 additions and 0 deletions

View File

@ -22,6 +22,7 @@ public interface FileManager {
void removeFile(String fileName); void removeFile(String fileName);
boolean isExist(Path path); boolean isExist(Path path);
boolean isExist(String fileName);
void autoCreateDir(Path path); void autoCreateDir(Path path);

View File

@ -54,6 +54,17 @@ public class FileManagerImpl implements FileManager {
this.currentDir = rootDir.resolve(dirName); this.currentDir = rootDir.resolve(dirName);
} }
@Override
public void changeDir(Path path) {
if (path.startsWith(rootDir)) {
this.currentDir = path;
}
else {
logger.debug("changeDir", "invalid path: " + path);
// TODO-rca: 例外を投げる
}
}
@Override @Override
public void backDir() { public void backDir() {
this.currentDir = currentDir.getParent(); this.currentDir = currentDir.getParent();
@ -115,6 +126,12 @@ public class FileManagerImpl implements FileManager {
return Files.exists(path); return Files.exists(path);
} }
@Override
public boolean isExist(String fileName) {
logger.debug("isExist", "called");
return Files.exists(currentDir.resolve(fileName));
}
@Override @Override
public void autoCreateDir(Path path) { public void autoCreateDir(Path path) {
logger.debug("autoCreateDir", "called"); logger.debug("autoCreateDir", "called");