OSDN Git Service

Merge branch 'master' of git://github.com/libgdx/libgdx
[mikumikustudio/libgdx-mikumikustudio.git] / backends / gdx-backend-iosmonotouch / src / com / badlogic / gdx / backends / ios / IOSFileHandle.java
1 /*******************************************************************************\r
2  * Copyright 2011 See AUTHORS file.\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  * \r
8  *   http://www.apache.org/licenses/LICENSE-2.0\r
9  * \r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  ******************************************************************************/\r
16 \r
17 package com.badlogic.gdx.backends.ios;\r
18 \r
19 import java.io.File;\r
20 \r
21 import com.badlogic.gdx.Files.FileType;\r
22 import com.badlogic.gdx.files.FileHandle;\r
23 \r
24 public class IOSFileHandle extends FileHandle {\r
25         public IOSFileHandle (String fileName, FileType type) {\r
26                 super(fileName, type);\r
27         }\r
28 \r
29         public IOSFileHandle (File file, FileType type) {\r
30                 super(file, type);\r
31         }\r
32 \r
33         public FileHandle child (String name) {\r
34                 if (file.getPath().length() == 0) return new IOSFileHandle(new File(name), type);\r
35                 return new IOSFileHandle(new File(file, name), type);\r
36         }\r
37 \r
38         public FileHandle parent () {\r
39                 File parent = file.getParentFile();\r
40                 if (parent == null) {\r
41                         if (type == FileType.Absolute)\r
42                                 parent = new File("/");\r
43                         else\r
44                                 parent = new File("");\r
45                 }\r
46                 return new IOSFileHandle(parent, type);\r
47         }\r
48 \r
49         public File file () {\r
50                 if (type == FileType.External) return new File(IOSFiles.externalPath, file.getPath());\r
51                 if (type == FileType.Local) return new File(IOSFiles.localPath, file.getPath());\r
52                 return file;\r
53         }\r
54 }\r