OSDN Git Service

scene2d.ui Disableable interface.
[mikumikustudio/libgdx-mikumikustudio.git] / backends / gdx-backend-iosmonotouch / src / com / badlogic / gdx / backends / ios / IOSFileHandle.java
index 73d468e..a56fccd 100644 (file)
@@ -19,14 +19,22 @@ import java.io.File;
 \r
 import com.badlogic.gdx.Files.FileType;\r
 import com.badlogic.gdx.files.FileHandle;\r
+import com.badlogic.gdx.utils.GdxRuntimeException;\r
 \r
+// FIXME see if we can get classpath files to work\r
 public class IOSFileHandle extends FileHandle {\r
        public IOSFileHandle (String fileName, FileType type) {\r
                super(fileName, type);\r
+               if(type == FileType.Classpath) {\r
+                       throw new GdxRuntimeException("Classpath files are not supported on iOS, this likely happened because you used the default constructor of BitmapFont.");\r
+               }\r
        }\r
 \r
        public IOSFileHandle (File file, FileType type) {\r
                super(file, type);\r
+               if(type == FileType.Classpath) {\r
+                       throw new GdxRuntimeException("Classpath files are not supported on iOS, this likely happened because you used the default constructor of BitmapFont.");\r
+               }\r
        }\r
 \r
        public FileHandle child (String name) {\r
@@ -45,6 +53,18 @@ public class IOSFileHandle extends FileHandle {
                return new IOSFileHandle(parent, type);\r
        }\r
 \r
+       /**\r
+        * This overrides the original method in FileHandle to prevent crashes on iOS. The original method\r
+        * has a fallback to FileType.Classpath when FileType.Internal is used. FileType.Classpath is not\r
+        * supported on iOS.\r
+        * \r
+        * @return  True if the file exists.\r
+        */\r
+       @Override\r
+       public boolean exists () {\r
+               return file().exists();\r
+       }\r
+\r
        public File file () {\r
                if (type == FileType.External) return new File(IOSFiles.externalPath, file.getPath());\r
                if (type == FileType.Local) return new File(IOSFiles.localPath, file.getPath());\r