49 lines
2.0 KiB
Dart
49 lines
2.0 KiB
Dart
import 'package:jj_mkvmaker/app/explorer_device.dart';
|
|
import 'package:jj_mkvmaker/app/local_fs.dart';
|
|
import 'package:jj_mkvmaker/core/file_ops.dart' show FileEntry;
|
|
|
|
/// 시험용 [ExplorerDevice]: 정한 것만 바꾸고 나머지는 이 기기 그대로.
|
|
/// [android] · [trash] · [nomediaOn] 은 Windows 에서 Android 의 갈래를 지나게 할 뿐이다 - 논리만 확인, Android 실제 확인은 노트 10+
|
|
class TestExplorerDevice implements ExplorerDevice {
|
|
static const _real = RealExplorerDevice();
|
|
static const _fs = RealLocalFs();
|
|
|
|
/// 저장 장치 목록 (null 이면 이 기기)
|
|
List<(String, String)> Function()? volumes;
|
|
|
|
/// 드라이브를 열 수 있는지 (null 이면 이 기기)
|
|
Future<bool> Function(String path)? probe;
|
|
|
|
/// 폴더 목록 (null 이면 이 기기) - 느린 목록 등
|
|
Future<List<FileEntry>> Function(String dir, {bool showHidden})? list;
|
|
|
|
/// 남은 공간 · 전체 (null 이면 이 기기) - 캡처가 실행마다 같게 정한다
|
|
(int, int)? Function(String path)? space;
|
|
|
|
/// 경로 입력 SMB 안내 · 앱 휴지통 · .nomedia 메뉴 (null 이면 이 기기)
|
|
bool? android, trash, nomediaOn;
|
|
|
|
@override
|
|
LocalFs get fs => _TestFs(this);
|
|
@override
|
|
Future<(int, int)?> diskSpace(String path) async => space != null ? space!(path) : await _real.diskSpace(path);
|
|
@override
|
|
bool get androidPaths => android ?? _real.androidPaths;
|
|
@override
|
|
bool get androidTrash => trash ?? _real.androidTrash;
|
|
@override
|
|
bool get nomedia => nomediaOn ?? _real.nomedia;
|
|
}
|
|
|
|
class _TestFs implements LocalFs {
|
|
final TestExplorerDevice d;
|
|
_TestFs(this.d);
|
|
@override
|
|
Future<List<FileEntry>> list(String dir, {bool showHidden = false}) =>
|
|
(d.list ?? TestExplorerDevice._fs.list)(dir, showHidden: showHidden);
|
|
@override
|
|
Future<List<(String, String)>> volumes() async => d.volumes?.call() ?? await TestExplorerDevice._fs.volumes();
|
|
@override
|
|
Future<bool> probe(String path) => (d.probe ?? TestExplorerDevice._fs.probe)(path);
|
|
}
|