Possible IOS read fix

This commit is contained in:
Anuken 2019-11-10 20:59:23 -05:00
parent 4c0607aba8
commit d6822c9c7d
2 changed files with 36 additions and 2 deletions

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=60e1edbc61f05c329019d0c5479672a298a9706c
archash=22534a12fc0d39eee77e1369c043444999a4e725

View File

@ -58,6 +58,40 @@ public class IOSLauncher extends IOSApplication.Delegate{
if(documentURLs.size() < 1) return;
cont.dismissViewController(true, () -> {});
NSFileCoordinator coord = new NSFileCoordinator(null);
try{
coord.coordinateReadingItem(documentURLs.get(0), NSFileCoordinatorReadingOptions.None, url -> {
NSInputStream stream = new NSInputStream(NSData.read(url));
cons.get(new FileHandle(url.getPath()){
@Override
public InputStream read(){
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){
return (int)stream.read(bytes, offset, length);
}
@Override
public void close() throws IOException{
stream.close();
}
};
}
});
});
}catch(Throwable t){
ui.showException(t);
}
/*
try{
controller.importDocument(documentURLs.get(0), new NSURL(getDocumentsDirectory() + "/document"), UIDocumentBrowserImportMode.Copy, (url, error) -> {
@ -73,7 +107,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
});
}catch(Throwable t){
ui.showException(t);
}
}*/
}
@Override