Skip to content

Commit 2c69267

Browse files
committed
Fix file icon processing
Signed-off-by: Hans Kokx <[email protected]>
1 parent e58b73f commit 2c69267

File tree

4 files changed

+12
-23
lines changed

4 files changed

+12
-23
lines changed

bin/dexa.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ part 'features/headers.dart';
2121
part 'features/modification_date.dart';
2222
part 'features/permissions.dart';
2323
part 'functions/gather_file_sizes.dart';
24-
part 'functions/get_mime_type.dart';
2524
part 'functions/handle_error.dart';
2625
part 'functions/list_directory_contents.dart';
2726

@@ -84,6 +83,7 @@ void main(List<String> arguments) async {
8483
if (args.showFileTypeIcon) {
8584
final String fileToProcess = directory.path + currentFile;
8685
final FileSystemEntityType type = fileStat.type;
86+
8787
output += showFileIcon(
8888
fileToProcess,
8989
type,

bin/features/file_icon.dart

+8-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ String showFileIcon(
66
bool showHeaders = false,
77
}) {
88
String output = '';
9-
String? mimeType;
109
String? icon;
1110
String? color;
1211

@@ -18,17 +17,15 @@ String showFileIcon(
1817
// TODO: Handle this case.
1918
break;
2019
default:
21-
mimeType = getMimeType(file);
22-
if (mimeType != null) {
23-
// We have a mime type, so let's check if it's in the list of known file types.
24-
mimeType = mimeType.split('/')[1];
25-
final Map? data = iconSet[mimeType];
20+
final String mimeType =
21+
lookupMimeType(file)?.split('/')[1] ?? file.split('.').last;
2622

27-
// The file type has been found in the list of known file types.
28-
if (data != null) {
29-
icon = data['icon'] as String?;
30-
color = data['color'] as String?;
31-
}
23+
final Map<String, String>? data = iconSet[mimeType];
24+
25+
// The file type has been found in the list of known file types.
26+
if (data != null) {
27+
icon = data['icon'];
28+
color = data['color'];
3229
}
3330
break;
3431
}

bin/functions/get_mime_type.dart

-8
This file was deleted.

pubspec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ environment:
1010
dev_dependencies:
1111
flutter_lints: ^2.0.0
1212
dependencies:
13-
args: ^2.2.0
14-
intl: ^0.18.1
15-
mime: ^1.0.1
13+
args: ^2.4.0
14+
intl: ^0.18.0
15+
mime: ^1.0.0
1616
path: ^1.8.0

0 commit comments

Comments
 (0)