@Override public FileHandle resolve (String fileName) { return Gdx.files.external(fileName); } }
@Override public FileHandle resolve (String fileName) { return Gdx.files.external(fileName); } }
@Override public void dispose () { // delete the copy on the external storage Gdx.files.external("8.12.mp3").delete(); } }
@Override public void create () { // copy an internal mp3 to the external storage FileHandle src = Gdx.files.internal("data/8.12.mp3"); FileHandle dst = Gdx.files.external("8.12.mp3"); src.copyTo(dst); // create a music instance and start playback Music music = Gdx.audio.newMusic(dst); music.play(); }
out = new BufferedWriter(new OutputStreamWriter(Gdx.files.external("test.txt").write(false))); out.write("test"); message += "Write external success\n"; InputStream in = Gdx.files.external("test.txt").read(); StreamUtils.closeQuietly(in); message += "Open external success\n"; in = new BufferedReader(new InputStreamReader(Gdx.files.external("test.txt").read())); if (!in.readLine().equals("test")) message += "Read result wrong\n"; if (!Gdx.files.external("test.txt").delete()) message += "Couldn't delete externalstorage/test.txt"; } else { message += "External storage not available";
private void performanceTest () throws Exception { Gdx.app.log("UBJsonTest", "--- performanceTest ---"); long start = System.currentTimeMillis(); UBJsonWriter uw = new UBJsonWriter(Gdx.files.external(fn).write(false, 8192)); uw.object(); uw.set("0floats", new float[] {}); Gdx.app.log("UBJsonTest", "File size is " + Gdx.files.external(fn).length()); UBJsonReader ur = new UBJsonReader(); ur.oldFormat = false; start = System.currentTimeMillis(); ur.parse(Gdx.files.external(fn)); Gdx.app.log("UBJsonTest", "Parsing the test file took " + (System.currentTimeMillis() - start) + "ms");
private void testExternal () throws IOException { String path = "meow"; FileHandle handle = Gdx.files.external(path); handle.delete(); if (handle.exists()) fail(); if (!handle.exists()) fail(); if (handle.length() != 3) fail(); FileHandle copy = Gdx.files.external(path + "-copy"); copy.delete(); if (copy.exists()) fail(); if (!copy.exists()) fail(); if (copy.length() != 3) fail(); FileHandle move = Gdx.files.external(path + "-move"); move.delete(); if (move.exists()) fail();
if (!child.parent().exists()) fail(); FileHandle copy = Gdx.files.external("badlogic.jpg-copy"); copy.delete(); if (copy.exists()) fail();
try { UBJsonWriter uw = new UBJsonWriter(Gdx.files.external(fn).write(false)); uw.object(); uw.set(longString, longString); UBJsonReader ur = new UBJsonReader(); ur.oldFormat = false; JsonValue v = ur.parse(Gdx.files.external(fn)); Gdx.app.log("UBJsonTest", "result = \n" + v.toString()); performanceTest();
@Override public FileHandle resolve (String fileName) { return Gdx.files.external(fileName); } }
public FileHandle getModuleDir() { return Gdx.files.external(AppConstants.MODULES_DIR + "/" + moduleId); }
public static void load () { try { FileHandle filehandle = Gdx.files.external(file); String[] strings = filehandle.readString().split("\n"); soundEnabled = Boolean.parseBoolean(strings[0]); for (int i = 0; i < 5; i++) { highscores[i] = Integer.parseInt(strings[i+1]); } } catch (Throwable e) { // :( It's ok we have defaults } }
public static void init () { // // determine user directories on UNIX-like OSes // String configBase = System.getenv("XDG_CONFIG_HOME"); // if (configBase == null || configBase.trim().equals("")) { // configBase = System.getProperty("user.home") + "/" + ".config"; // } Gdx.files.external(Storage.ConfigRoot).mkdirs(); Gdx.files.external(Storage.DataRoot).mkdirs(); Gdx.files.external(Storage.ReplaysRoot).mkdirs(); Gdx.app.log("Storage", "Config root at " + Gdx.files.external(Storage.ConfigRoot)); Gdx.app.log("Storage", "Data root at " + Gdx.files.external(Storage.DataRoot)); Gdx.app.log("Storage", "Replays root at " + Gdx.files.external(Storage.ReplaysRoot)); }
public OutputStream openFileOutput(String fileName) { final FileHandle fh = Gdx.files.external(basePath != null ? basePath + fileName : fileName); return fh.write(false); }
public static void save () { try { FileHandle filehandle = Gdx.files.external(file); filehandle.writeString(Boolean.toString(soundEnabled)+"\n", false); for (int i = 0; i < 5; i++) { filehandle.writeString(Integer.toString(highscores[i])+"\n", true); } } catch (Throwable e) { } }
public InputStream openFileInput(String fileName) throws IOException { final FileHandle fh = Gdx.files.external(basePath != null ? basePath + fileName : fileName); if (!fh.exists()) throw new IOException("File " + fileName + " doesn't exist"); return fh.read(); }
public boolean deleteFile(String fileName) { final FileHandle fh = Gdx.files.external(basePath != null ? basePath + fileName : fileName); return fh.exists() && fh.delete(); }
public FileHandle toFileHandle () { switch (type) { case Absolute: return Gdx.files.absolute(path); case Classpath: return Gdx.files.classpath(path); case External: return Gdx.files.external(path); case Internal: return Gdx.files.internal(path); case Local: return Gdx.files.local(path); default: throw new IllegalStateException("Unknown file type!"); } } }
@LmlAction("editCustomHotkeys") void editCustomHotkeys() { FileHandle userHotkeyFile = Gdx.files.external(AppConstants.EXTERNAL_DIR + "/hotkeys_user.txt"); if (!userHotkeyFile.exists()) { Gdx.files.internal("hotkeys_user.txt").copyTo(userHotkeyFile); } try { Desktop.getDesktop().open(userHotkeyFile.file()); } catch (IOException e) { Gdx.app.error(TAG, "Error opening " + userHotkeyFile, e); } } @LmlAction public void showMenuFile() {
@Initiate void initialize() { App.inst().getInput().addProcessor(this, 10); // Read shortcut files { parseShortcutFile(Gdx.files.internal("hotkeys_default.txt")); if (App.inst().getParams().debug) { parseShortcutFile(Gdx.files.internal("hotkeys_debug.txt")); } FileHandle userShortcutFile = Gdx.files.external(AppConstants.EXTERNAL_DIR + "/hotkeys_user.txt"); if (userShortcutFile.exists()) { parseShortcutFile(userShortcutFile); } } }