mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Fix invalid image order when exporting comic as pdf.
This commit is contained in:
@@ -35,19 +35,9 @@ class FilePath {
|
||||
}
|
||||
|
||||
extension FileSystemEntityExt on FileSystemEntity {
|
||||
/// Get the base name of the file or directory.
|
||||
String get name {
|
||||
var path = this.path;
|
||||
if (path.endsWith('/') || path.endsWith('\\')) {
|
||||
path = path.substring(0, path.length - 1);
|
||||
}
|
||||
|
||||
int i = path.length - 1;
|
||||
|
||||
while (i >= 0 && path[i] != '\\' && path[i] != '/') {
|
||||
i--;
|
||||
}
|
||||
|
||||
return path.substring(i + 1);
|
||||
return p.basename(path);
|
||||
}
|
||||
|
||||
Future<void> deleteIgnoreError({bool recursive = false}) async {
|
||||
@@ -83,6 +73,10 @@ extension FileExtension on File {
|
||||
// Stream is not usable since [AndroidFile] does not support [openRead].
|
||||
await newFile.writeAsBytes(await readAsBytes());
|
||||
}
|
||||
|
||||
String get basenameWithoutExt {
|
||||
return p.basenameWithoutExtension(path);
|
||||
}
|
||||
}
|
||||
|
||||
extension DirectoryExtension on Directory {
|
||||
|
@@ -30,14 +30,14 @@ Future<void> _createPdfFromComic({
|
||||
files.removeWhere(
|
||||
(element) => element is! File || element.path.startsWith('cover'));
|
||||
files.sort((a, b) {
|
||||
var aName = (a as File).name;
|
||||
var bName = (b as File).name;
|
||||
var aName = (a as File).basenameWithoutExt;
|
||||
var bName = (b as File).basenameWithoutExt;
|
||||
var aNumber = int.tryParse(aName);
|
||||
var bNumber = int.tryParse(bName);
|
||||
if (aNumber != null && bNumber != null) {
|
||||
return aNumber.compareTo(bNumber);
|
||||
}
|
||||
return aName.compareTo(bName);
|
||||
return a.name.compareTo(b.name);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user