mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-23 09:16:19 +01:00
27 lines
818 B
Dart
27 lines
818 B
Dart
import 'package:nc_photos/account.dart';
|
|
import 'package:nc_photos/entity/file.dart';
|
|
import 'package:nc_photos/string_extension.dart';
|
|
|
|
class Ls {
|
|
Ls(this.fileRepo);
|
|
|
|
/// List all files under a dir
|
|
///
|
|
/// The resulting list would normally also include the [root] dir. If
|
|
/// [shouldExcludeRootDir] == true, such entry will be removed
|
|
Future<List<File>> call(Account account, File root,
|
|
{bool shouldExcludeRootDir = true}) async {
|
|
final products = await fileRepo.list(account, root);
|
|
if (shouldExcludeRootDir) {
|
|
// filter out root file
|
|
final trimmedRootPath = root.path.trimAny("/");
|
|
return products
|
|
.where((element) => element.path.trimAny("/") != trimmedRootPath)
|
|
.toList();
|
|
} else {
|
|
return products;
|
|
}
|
|
}
|
|
|
|
final FileRepo fileRepo;
|
|
}
|