package com.badlogic.gdx.backends.iosrobovm;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.files.FileHandle;
return new IOSFileHandle(parent, type);
}
+ public FileHandle sibling (String name) {
+ if (file.getPath().length() == 0) throw new GdxRuntimeException("Cannot get the sibling of the root.");
+ return new IOSFileHandle(new File(file.getParent(), name), type);
+ }
+
public File file () {
+ if (type == FileType.Internal) return new File(IOSFiles.internalPath, file.getPath());
if (type == FileType.External) return new File(IOSFiles.externalPath, file.getPath());
if (type == FileType.Local) return new File(IOSFiles.localPath, file.getPath());
return file;
}
+
+ @Override
+ public boolean exists() {
+ return file().exists();
+ }
+
}
\ No newline at end of file
@Override
public FileHandle getFileHandle (String fileName, FileType type) {
- if (type == FileType.Internal) return internal(fileName);
return new IOSFileHandle(fileName, type);
}
@Override
public FileHandle internal (String path) {
- return new IOSFileHandle(new File(internalPath, path), FileType.Internal);
+ return new IOSFileHandle(path, FileType.Internal);
}
@Override
/** Returns a stream for reading this file as bytes.\r
* @throws GdxRuntimeException if the file handle represents a directory, doesn't exist, or could not be read. */\r
public InputStream read () {\r
- if (type == FileType.Classpath || (type == FileType.Internal && !file.exists())\r
- || (type == FileType.Local && !file.exists())) {\r
+ if (type == FileType.Classpath || (type == FileType.Internal && !file().exists())\r
+ || (type == FileType.Local && !file().exists())) {\r
InputStream input = FileHandle.class.getResourceAsStream("/" + file.getPath().replace('\\', '/'));\r
if (input == null) throw new GdxRuntimeException("File not found: " + file + " (" + type + ")");\r
return input;\r