More attempts

This commit is contained in:
Anuken
2019-11-10 22:41:06 -05:00
parent 2cf628305a
commit 0e8abca5d9

View File

@@ -60,16 +60,30 @@ public class IOSLauncher extends IOSApplication.Delegate{
cont.dismissViewController(true, () -> {}); cont.dismissViewController(true, () -> {});
NSFileCoordinator coord = new NSFileCoordinator(null); NSFileCoordinator coord = new NSFileCoordinator(null);
try{
coord.coordinateReadingItem(documentURLs.get(0), NSFileCoordinatorReadingOptions.None, url -> {
try{ try{
NSInputStream stream = new NSInputStream(url); coord.coordinateReadingItem(documentURLs.get(0), NSFileCoordinatorReadingOptions.None, url -> {
if(url.startAccessingSecurityScopedResource()){
try{
cons.get(new FileHandle(url.getAbsoluteString()));
}catch(Throwable t){
ui.showException(t);
}finally{
url.stopAccessingSecurityScopedResource();
}
}else{
ui.showErrorMessage("Failed to access file.");
}
/*
try{
int[] tread = {0}; int[] tread = {0};
cons.get(new FileHandle(url.getPath()){ cons.get(new FileHandle(url.getPath()){
@Override @Override
public InputStream read(){ public InputStream read(){
NSInputStream stream = new NSInputStream(url);
return new InputStream(){ return new InputStream(){
byte[] tmp = {0}; byte[] tmp = {0};
@@ -83,7 +97,6 @@ public class IOSLauncher extends IOSApplication.Delegate{
public int read(byte[] bytes, int offset, int length){ public int read(byte[] bytes, int offset, int length){
int read = (int)stream.read(bytes, offset, length); int read = (int)stream.read(bytes, offset, length);
tread[0] += read; tread[0] += read;
if(read == 0) return -1;
return read; return read;
} }
}; };
@@ -92,7 +105,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
Core.app.post(() -> Core.app.post(() -> Core.app.post(() -> ui.showInfo("Read " + tread[0])))); Core.app.post(() -> Core.app.post(() -> Core.app.post(() -> ui.showInfo("Read " + tread[0]))));
}catch(Throwable t){ }catch(Throwable t){
ui.showException(t); ui.showException(t);
} }*/
}); });
}catch(Throwable t){ }catch(Throwable t){
ui.showException(t); ui.showException(t);
@@ -123,7 +136,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
@Override @Override
public void didImportDocument(UIDocumentBrowserViewController controller, NSURL sourceURL, NSURL destinationURL){ public void didImportDocument(UIDocumentBrowserViewController controller, NSURL sourceURL, NSURL destinationURL){
cons.get(Core.files.absolute(destinationURL.getAbsoluteString())); //cons.get(Core.files.absolute(destinationURL.getAbsoluteString()));
} }
@Override @Override