From 20be0807015b7d8305c60d0d10efcfa894455c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=A8=87?= Date: Mon, 4 Mar 2024 23:09:10 +0800 Subject: [PATCH] Update windows_evb_config_generator.dart --- dev/windows_evb_config_generator.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dev/windows_evb_config_generator.dart b/dev/windows_evb_config_generator.dart index 5c2e6ec..3123bea 100644 --- a/dev/windows_evb_config_generator.dart +++ b/dev/windows_evb_config_generator.dart @@ -7,7 +7,8 @@ void main() { builder.processing('xml', 'version="1.0" encoding="windows-1252"'); // evb needs absolute dir, in fact the relative dir works in wine, but not work on // Windows runner of Github Actions. I cannot test it on a physical Windows machine. - final windowsBuildDir = Directory(r"build\windows\x64\runner\Release").absolute; // use this for test: "build/linux/x64/release/bundle" + final windowsBuildDir = Directory(r"build/linux/x64/release/bundle") + .absolute; // use this for test: "build/linux/x64/release/bundle" final entities = windowsBuildDir.listSync(); final input = entities.firstWhere((e) => e is File && e.path.endsWith('.exe')); final output = File(input.name).absolute; @@ -55,7 +56,9 @@ void main() { }); final document = builder.buildDocument(); - File('renamer.evb').writeAsStringSync(document.toXmlString(pretty: true)); + File('renamer.evb') + ..writeAsStringSync(String.fromCharCode(0xFEFF)) + ..writeAsStringSync(document.toXmlString(pretty: true)); } void buildFile(XmlBuilder builder, String name, String path) { @@ -82,12 +85,12 @@ void buildDir(XmlBuilder builder, String name, List entities) builder.element('OverwriteAttributes', nest: 'False'); builder.element('HideFromDialogs', nest: 0); builder.element('Files', nest: () { - for (final entity in entities) { + for (final entity in entities + ..sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()))) { if (entity is Directory) { buildDir(builder, entity.name, entity.listSync()); } else if (entity is File) { buildFile(builder, entity.name, entity.absolute.path); - } } }); @@ -108,4 +111,4 @@ void buildRegistry(XmlBuilder builder, String name) { extension on FileSystemEntity { // get file name String get name => path.substring(path.lastIndexOf(Platform.pathSeparator) + 1); -} \ No newline at end of file +}