Skip to content

Commit

Permalink
Update windows_evb_config_generator.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
sun-jiao committed Mar 4, 2024
1 parent bde913f commit 20be080
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dev/windows_evb_config_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -82,12 +85,12 @@ void buildDir(XmlBuilder builder, String name, List<FileSystemEntity> 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);

}
}
});
Expand All @@ -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);
}
}

0 comments on commit 20be080

Please sign in to comment.