public OpenALSound newSound (FileHandle file) { if (file == null) throw new IllegalArgumentException("file cannot be null."); Class<? extends OpenALSound> soundClass = extensionToSoundClass.get(file.extension().toLowerCase()); if (soundClass == null) throw new GdxRuntimeException("Unknown file extension for sound: " + file); try { return soundClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file); } catch (Exception ex) { throw new GdxRuntimeException("Error creating sound " + soundClass.getName() + " for file: " + file, ex); } }
public OpenALMusic newMusic (FileHandle file) { if (file == null) throw new IllegalArgumentException("file cannot be null."); Class<? extends OpenALMusic> musicClass = extensionToMusicClass.get(file.extension().toLowerCase()); if (musicClass == null) throw new GdxRuntimeException("Unknown file extension for music: " + file); try { return musicClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file); } catch (Exception ex) { throw new GdxRuntimeException("Error creating music " + musicClass.getName() + " for file: " + file, ex); } }
public OpenALMusic newMusic (FileHandle file) { if (file == null) throw new IllegalArgumentException("file cannot be null."); Class<? extends OpenALMusic> musicClass = extensionToMusicClass.get(file.extension().toLowerCase()); if (musicClass == null) throw new GdxRuntimeException("Unknown file extension for music: " + file); try { return musicClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file); } catch (Exception ex) { throw new GdxRuntimeException("Error creating music " + musicClass.getName() + " for file: " + file, ex); } }
public OpenALMusic newMusic (FileHandle file) { if (file == null) throw new IllegalArgumentException("file cannot be null."); Class<? extends OpenALMusic> musicClass = extensionToMusicClass.get(file.extension().toLowerCase()); if (musicClass == null) throw new GdxRuntimeException("Unknown file extension for music: " + file); try { return musicClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file); } catch (Exception ex) { throw new GdxRuntimeException("Error creating music " + musicClass.getName() + " for file: " + file, ex); } }
public OpenALSound newSound (FileHandle file) { if (file == null) throw new IllegalArgumentException("file cannot be null."); Class<? extends OpenALSound> soundClass = extensionToSoundClass.get(file.extension().toLowerCase()); if (soundClass == null) throw new GdxRuntimeException("Unknown file extension for sound: " + file); try { return soundClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file); } catch (Exception ex) { throw new GdxRuntimeException("Error creating sound " + soundClass.getName() + " for file: " + file, ex); } }
public OpenALSound newSound (FileHandle file) { if (file == null) throw new IllegalArgumentException("file cannot be null."); Class<? extends OpenALSound> soundClass = extensionToSoundClass.get(file.extension().toLowerCase()); if (soundClass == null) throw new GdxRuntimeException("Unknown file extension for sound: " + file); try { return soundClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file); } catch (Exception ex) { throw new GdxRuntimeException("Error creating sound " + soundClass.getName() + " for file: " + file, ex); } }
public OpenALMusic newMusic (FileHandle file) { if (file == null) throw new IllegalArgumentException("file cannot be null."); Class<? extends OpenALMusic> musicClass = extensionToMusicClass.get(file.extension().toLowerCase()); if (musicClass == null) throw new GdxRuntimeException("Unknown file extension for music: " + file); try { return musicClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file); } catch (Exception ex) { throw new GdxRuntimeException("Error creating music " + musicClass.getName() + " for file: " + file, ex); } }
public OpenALSound newSound (FileHandle file) { if (file == null) throw new IllegalArgumentException("file cannot be null."); Class<? extends OpenALSound> soundClass = extensionToSoundClass.get(file.extension().toLowerCase()); if (soundClass == null) throw new GdxRuntimeException("Unknown file extension for sound: " + file); try { return soundClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file); } catch (Exception ex) { throw new GdxRuntimeException("Error creating sound " + soundClass.getName() + " for file: " + file, ex); } }
private static final void traverse (FileHandle directory, String base, StringBuffer list) { if (directory.name().equals(".svn")) return; String dirName = directory.toString().replace("\\", "/").replace(base, "") + "/"; System.out.println(dirName); for (FileHandle file : directory.list()) { if (file.isDirectory()) { traverse(file, base, list); } else { String fileName = file.toString().replace("\\", "/").replace(base, ""); if (fileName.endsWith(".png") || fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) { list.append("i:" + fileName + "\n"); System.out.println(fileName); } else if (fileName.endsWith(".glsl") || fileName.endsWith(".fnt") || fileName.endsWith(".pack") || fileName.endsWith(".obj") || file.extension().equals("") || fileName.endsWith("txt")) { list.append("t:" + fileName + "\n"); System.out.println(fileName); } else { if (fileName.endsWith(".mp3") || fileName.endsWith(".ogg") || fileName.endsWith(".wav")) continue; list.append("b:" + fileName + "\n"); System.out.println(fileName); } } } } }
@Override public FreeTypeFontGenerator load (AssetManager assetManager, String fileName, FileHandle file, FreeTypeFontGeneratorParameters parameter) { FreeTypeFontGenerator generator = null; if (file.extension().equals("gen")) { generator = new FreeTypeFontGenerator(file.sibling(file.nameWithoutExtension())); } else { generator = new FreeTypeFontGenerator(file); } return generator; }
@Override public FreeTypeFontGenerator load (AssetManager assetManager, String fileName, FileHandle file, FreeTypeFontGeneratorParameters parameter) { FreeTypeFontGenerator generator = null; if (file.extension().equals("gen")) { generator = new FreeTypeFontGenerator(file.sibling(file.nameWithoutExtension())); } else { generator = new FreeTypeFontGenerator(file); } return generator; }
@Override public void prepare () { if (isPrepared) throw new GdxRuntimeException("Already prepared"); if (pixmap == null) { if (file.extension().equals("cim")) pixmap = PixmapIO.readCIM(file); else pixmap = new Pixmap(file); width = pixmap.getWidth(); height = pixmap.getHeight(); if (format == null) format = pixmap.getFormat(); } isPrepared = true; }
@Override public void prepare () { if (isPrepared) throw new GdxRuntimeException("Already prepared"); if (pixmap == null) { if (file.extension().equals("cim")) pixmap = PixmapIO.readCIM(file); else pixmap = new Pixmap(file); width = pixmap.getWidth(); height = pixmap.getHeight(); if (format == null) format = pixmap.getFormat(); } isPrepared = true; }
private void testClasspath () throws IOException { // no classpath support on ios if (Gdx.app.getType() == ApplicationType.iOS) return; FileHandle handle = Gdx.files.classpath("com/badlogic/gdx/utils/arial-15.png"); if (!handle.exists()) fail(); if (handle.isDirectory()) fail(); try { handle.delete(); fail(); } catch (Exception expected) { } try { handle.list(); fail(); } catch (Exception expected) { } try { handle.read().close(); fail(); } catch (Exception ignored) { } FileHandle dir = Gdx.files.classpath("com/badlogic/gdx/utils"); if (dir.isDirectory()) fail(); FileHandle child = dir.child("arial-15.fnt"); if (!child.name().equals("arial-15.fnt")) fail(); if (!child.nameWithoutExtension().equals("arial-15")) fail(); if (!child.extension().equals("fnt")) fail(); handle.read().close(); if (handle.readBytes().length != handle.length()) fail(); }
if (!handle.name().equals("meow")) fail(); if (!handle.nameWithoutExtension().equals("meow")) fail(); if (!handle.extension().equals("")) fail(); handle.deleteDirectory(); if (handle.exists()) fail();
if (!handle.name().equals("meow")) fail(); if (!handle.nameWithoutExtension().equals("meow")) fail(); if (!handle.extension().equals("")) fail(); handle.deleteDirectory(); if (handle.exists()) fail();
if (!handle.name().equals("meow")) fail(); if (!handle.nameWithoutExtension().equals("meow")) fail(); if (!handle.extension().equals("")) fail(); handle.deleteDirectory(); if (handle.exists()) fail();
if (!child.name().equals("badlogic.jpg")) fail(); if (!child.nameWithoutExtension().equals("badlogic")) fail(); if (!child.extension().equals("jpg")) fail(); if (Gdx.app.getType() != ApplicationType.Android) { if (!child.parent().exists()) fail();
public InputFile(FileHandle fileHandle, Type type) { this.fileHandle = fileHandle; this.type = type; // Determine if the file is a directory. // We cannot use just `fileHandle.isDirectory()`, // because in case the file doesn't exist it always returns `false`. if (fileHandle.exists()) { this.directory = fileHandle.isDirectory(); } else { this.directory = fileHandle.extension().length() == 0; } }
@Override public void selected (Array<FileHandle> file) { FileHandle chosenFile = file.first(); fileChooserHistory.putLastDir(FileChooserHistory.Type.PROJECT, chosenFile.parent()); if (chosenFile.extension().length() == 0) { chosenFile = Gdx.files.getFileHandle(chosenFile.path()+"."+AppConstants.PROJECT_FILE_EXT, chosenFile.type()); } getProject().setProjectFile(chosenFile); projectSerializer.saveProject(project, chosenFile); } });