ファイル作成/削除を追加 WIP

This commit is contained in:
r-ca 2024-01-08 11:12:51 +09:00
parent eb6a13baba
commit 67350639c7
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 23 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package one.nem.lacerta.source.file;
import android.graphics.Bitmap;
import java.io.File;
import java.nio.file.Path;
import java.util.List;
@ -16,6 +17,9 @@ public interface FileManager {
void createDir(String dirName);
void removeDir(String dirName);
File createFile(String fileName);
void removeFile(String fileName);
void saveBitmapAtCurrent(Bitmap bitmap, String fileName);
Bitmap loadBitmap(Path path);
void removeBitmap(Path path);

View File

@ -14,6 +14,8 @@ import dagger.assisted.Assisted;
import dagger.assisted.AssistedInject;
import one.nem.lacerta.source.file.FileManager;
import one.nem.lacerta.utils.LacertaLogger;
public class FileManagerImpl implements FileManager {
// RootDir
@ -32,8 +34,12 @@ public class FileManagerImpl implements FileManager {
}
}
// Injection
private LacertaLogger logger;
@AssistedInject
public FileManagerImpl(@Assisted Path rootDir) {
public FileManagerImpl(LacertaLogger logger, @Assisted Path rootDir) {
this.logger = logger;
this.rootDir = rootDir;
this.currentDir = rootDir;
}
@ -73,6 +79,7 @@ public class FileManagerImpl implements FileManager {
@Override
public void createDir(String dirName) {
//ディレクトリ作成
currentDir.resolve(dirName).toFile().mkdir(); // TODO-rca: エラーハンドリング
}
@ -81,6 +88,17 @@ public class FileManagerImpl implements FileManager {
currentDir.resolve(dirName).toFile().delete(); // TODO-rca: エラーハンドリング
}
@Override
public File createFile(String fileName) {
return currentDir.resolve(fileName).toFile();
}
@Override
public void removeFile(String fileName) {
currentDir.resolve(fileName).toFile().delete(); // TODO-rca: エラーハンドリング
}
@Override
public void saveBitmapAtCurrent(Bitmap bitmap, String fileName) { // TODO-rca: ファイル形式を変更できるようにする
try {