OSDN Git Service

Fix files for RoboVM
authorJustin Shapcott <support@mobidevelop.com>
Thu, 12 Sep 2013 14:13:08 +0000 (07:13 -0700)
committerJustin Shapcott <support@mobidevelop.com>
Thu, 12 Sep 2013 14:13:52 +0000 (07:13 -0700)
backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSFileHandle.java
backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSFiles.java
gdx/src/com/badlogic/gdx/files/FileHandle.java

index 0cf0072..cfa90e4 100644 (file)
@@ -1,6 +1,8 @@
 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;
@@ -31,9 +33,21 @@ public class IOSFileHandle extends 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
index e517b92..c67f957 100644 (file)
@@ -23,7 +23,6 @@ public class IOSFiles implements Files {
        
        @Override
        public FileHandle getFileHandle (String fileName, FileType type) {
-               if (type == FileType.Internal) return internal(fileName);
                return new IOSFileHandle(fileName, type);
        }
 
@@ -34,7 +33,7 @@ public class IOSFiles implements Files {
 
        @Override
        public FileHandle internal (String path) {
-               return new IOSFileHandle(new File(internalPath, path), FileType.Internal);
+               return new IOSFileHandle(path, FileType.Internal);
        }
 
        @Override
index 3ddac64..aa144f0 100644 (file)
@@ -126,8 +126,8 @@ public class FileHandle {
        /** 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