• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 package com.badlogic.gdx.backends.iosmoe;
18 
19 import com.badlogic.gdx.Files;
20 import com.badlogic.gdx.files.FileHandle;
21 import ios.foundation.NSBundle;
22 
23 public class IOSFiles implements Files {
24 	// TODO: Use NSSearchPathForDirectoriesInDomains instead?
25 	// $HOME should point to the app root dir.
26 	static final String appDir = System.getenv("HOME");
27 	static final String externalPath = appDir + "/Documents/";
28 	static final String localPath = appDir + "/Library/local/";
29 	static final String internalPath = NSBundle.mainBundle().bundlePath() + "/assets/";
30 
IOSFiles()31 	public IOSFiles () {
32 		new FileHandle(externalPath).mkdirs();
33 		new FileHandle(localPath).mkdirs();
34 	}
35 
36 	@Override
getFileHandle(String fileName, FileType type)37 	public FileHandle getFileHandle (String fileName, FileType type) {
38 		return new IOSFileHandle(fileName, type);
39 	}
40 
41 	@Override
classpath(String path)42 	public FileHandle classpath (String path) {
43 		return new IOSFileHandle(path, FileType.Classpath);
44 	}
45 
46 	@Override
internal(String path)47 	public FileHandle internal (String path) {
48 		return new IOSFileHandle(path, FileType.Internal);
49 	}
50 
51 	@Override
external(String path)52 	public FileHandle external (String path) {
53 		return new IOSFileHandle(path, FileType.External);
54 	}
55 
56 	@Override
absolute(String path)57 	public FileHandle absolute (String path) {
58 		return new IOSFileHandle(path, FileType.Absolute);
59 	}
60 
61 	@Override
local(String path)62 	public FileHandle local (String path) {
63 		return new IOSFileHandle(path, FileType.Local);
64 	}
65 
66 	@Override
getExternalStoragePath()67 	public String getExternalStoragePath () {
68 		return externalPath;
69 	}
70 
71 	@Override
isExternalStorageAvailable()72 	public boolean isExternalStorageAvailable () {
73 		return true;
74 	}
75 
76 	@Override
getLocalStoragePath()77 	public String getLocalStoragePath () {
78 		return localPath;
79 	}
80 
81 	@Override
isLocalStorageAvailable()82 	public boolean isLocalStorageAvailable () {
83 		return true;
84 	}
85 }
86