From a255c6d82a990352326524dc92bb16c1c9eb0bbd Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 25 May 2015 18:15:22 +0000 Subject: [PATCH] * yet another try to fix Unicode/Accent MediaInfo.open() issues on Mac ... --- source/net/filebot/mediainfo/MediaInfo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/net/filebot/mediainfo/MediaInfo.java b/source/net/filebot/mediainfo/MediaInfo.java index e93a933b..59f4ee19 100644 --- a/source/net/filebot/mediainfo/MediaInfo.java +++ b/source/net/filebot/mediainfo/MediaInfo.java @@ -4,6 +4,7 @@ import java.io.Closeable; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; +import java.nio.charset.StandardCharsets; import java.text.Normalizer; import java.text.Normalizer.Form; import java.util.ArrayList; @@ -45,14 +46,14 @@ public class MediaInfo implements Closeable { } public synchronized boolean open(File file) { - if (!file.isFile()) { + if (!file.isFile() || file.length() < 64 * 1024) { return false; } String path = file.getAbsolutePath(); // on Mac files that contain accents cannot be opened via JNA WString file paths due to encoding differences so we use the buffer interface instead for these files - if (Platform.isMac() && path.length() != Normalizer.normalize(path, Form.NFD).length()) { + if (Platform.isMac() && !StandardCharsets.US_ASCII.newEncoder().canEncode(path)) { try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { return openViaBuffer(raf); } catch (IOException e) {