Return -1 when applicable

This commit is contained in:
Anuken
2019-11-10 22:12:25 -05:00
parent 001294a94c
commit 2cf628305a

View File

@@ -65,6 +65,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
try{ try{
NSInputStream stream = new NSInputStream(url); NSInputStream stream = new NSInputStream(url);
int[] tread = {0};
cons.get(new FileHandle(url.getPath()){ cons.get(new FileHandle(url.getPath()){
@Override @Override
@@ -80,14 +81,15 @@ public class IOSLauncher extends IOSApplication.Delegate{
@Override @Override
public int read(byte[] bytes, int offset, int length){ public int read(byte[] bytes, int offset, int length){
if(!stream.hasBytesAvailable()){ int read = (int)stream.read(bytes, offset, length);
return -1; tread[0] += read;
} if(read == 0) return -1;
return (int)stream.read(bytes, offset, length); return read;
} }
}; };
} }
}); });
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);
} }