From 231ce28f7414a351a4d6e1730369311c4e9fc404 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 10 Nov 2019 23:01:19 -0500 Subject: [PATCH] apple why --- ios/src/io/anuke/mindustry/IOSLauncher.java | 30 +++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ios/src/io/anuke/mindustry/IOSLauncher.java b/ios/src/io/anuke/mindustry/IOSLauncher.java index 43e62a851f..fed895ff17 100644 --- a/ios/src/io/anuke/mindustry/IOSLauncher.java +++ b/ios/src/io/anuke/mindustry/IOSLauncher.java @@ -65,11 +65,37 @@ public class IOSLauncher extends IOSApplication.Delegate{ coord.coordinateReadingItem(documentURLs.get(0), NSFileCoordinatorReadingOptions.None, url -> { if(url.startAccessingSecurityScopedResource()){ try{ - cons.get(new FileHandle(url.getAbsoluteString())); + int[] tread = {0}; + + cons.get(new FileHandle(url.getPath()){ + @Override + public InputStream read(){ + NSInputStream stream = new NSInputStream(url); + + return new InputStream(){ + byte[] tmp = {0}; + + @Override + public int read() throws IOException{ + read(tmp); + return tmp[0]; + } + + @Override + public int read(byte[] bytes, int offset, int length){ + int read = (int)stream.read(bytes, offset, length); + tread[0] += read; + return read; + } + }; + } + }); + Core.app.post(() -> Core.app.post(() -> Core.app.post(() -> ui.showInfo("Read " + tread[0])))); + //cons.get(new FileHandle(url.getAbsoluteString())); }catch(Throwable t){ ui.showException(t); }finally{ - url.stopAccessingSecurityScopedResource(); + //url.stopAccessingSecurityScopedResource(); } }else{ ui.showErrorMessage("Failed to access file.");