JJ_MKVMaker/lib/app/local_fs.dart

30 lines
1.2 KiB
Dart

/// 약속 (M2): 폴더 목록 · 저장 장치 · 드라이브를 열 수 있는지 - 파일 탐색기가 기기에서 읽는 것.
/// - [list]: 폴더 → 항목들. 하나도 읽지 못하면 그 오류를 던진다 (빈 목록으로 숨기지 않음 - file_listing 의 listEntries 약속 그대로)
/// - [volumes]: 저장 장치 (경로, 이름) 목록
/// - [probe]: 그 경로를 열 수 있는지 (화면을 멈추지 않는 비동기)
/// 앱은 [RealLocalFs] (이 기기 그대로) 를 쓰고, 시험은 생성자로 다른 것을 넘긴다 (예: 느린 목록 - 빈 목록 경합 시험)
library;
import 'dart:io';
import '../core/file_ops.dart' show FileEntry, listEntries;
import 'volumes.dart';
abstract interface class LocalFs {
Future<List<FileEntry>> list(String dir, {bool showHidden = false});
Future<List<(String, String)>> volumes();
Future<bool> probe(String path);
}
/// 이 기기 그대로
class RealLocalFs implements LocalFs {
const RealLocalFs();
@override
Future<List<FileEntry>> list(String dir, {bool showHidden = false}) => listEntries(dir, showHidden: showHidden);
@override
Future<List<(String, String)>> volumes() => localVolumes();
@override
Future<bool> probe(String path) => Directory(path).exists();
}