@Override public void dispose () { // delete the copy on the external storage Gdx.files.external("8.12.mp3").delete(); } }
/** Moves this file to the specified file, overwriting the file if it already exists. * @throws GdxRuntimeException if the source or destination file handle is a {@link FileType#Classpath} or * {@link FileType#Internal} file. */ public void moveTo (FileHandle dest) { switch (type) { case Classpath: throw new GdxRuntimeException("Cannot move a classpath file: " + file); case Internal: throw new GdxRuntimeException("Cannot move an internal file: " + file); case Absolute: case External: // Try rename for efficiency and to change case on case-insensitive file systems. if (file().renameTo(dest.file())) return; } copyTo(dest); delete(); if (exists() && isDirectory()) deleteDirectory(); }
/** Moves this file to the specified file, overwriting the file if it already exists. * @throws GdxRuntimeException if the source or destination file handle is a {@link FileType#Classpath} or * {@link FileType#Internal} file. */ public void moveTo (FileHandle dest) { switch (type) { case Classpath: throw new GdxRuntimeException("Cannot move a classpath file: " + file); case Internal: throw new GdxRuntimeException("Cannot move an internal file: " + file); case Absolute: case External: // Try rename for efficiency and to change case on case-insensitive file systems. if (file().renameTo(dest.file())) return; } copyTo(dest); delete(); if (exists() && isDirectory()) deleteDirectory(); }
private void testAbsolute () throws IOException { String path = new File(Gdx.files.getExternalStoragePath(), "meow").getAbsolutePath(); FileHandle handle = Gdx.files.absolute(path); handle.delete(); if (handle.exists()) fail(); if (handle.isDirectory()) fail(); if (handle.delete()) fail(); if (handle.list().length != 0) fail(); if (handle.child("meow").exists()) fail(); if (handle.length() != 3) fail(); FileHandle copy = Gdx.files.absolute(path + "-copy"); copy.delete(); if (copy.exists()) fail(); handle.copyTo(copy); if (copy.length() != 3) fail(); FileHandle move = Gdx.files.absolute(path + "-move"); move.delete(); if (move.exists()) fail(); copy.moveTo(move); if (handle.exists()) fail(); if (handle.isDirectory()) fail(); handle.delete(); handle.deleteDirectory();
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(); }
private void testExternal () throws IOException { String path = "meow"; FileHandle handle = Gdx.files.external(path); handle.delete(); if (handle.exists()) fail(); if (handle.isDirectory()) fail(); if (handle.delete()) fail(); if (handle.list().length != 0) fail(); if (handle.child("meow").exists()) fail(); if (handle.length() != 3) fail(); FileHandle copy = Gdx.files.external(path + "-copy"); copy.delete(); if (copy.exists()) fail(); handle.copyTo(copy); if (copy.length() != 3) fail(); FileHandle move = Gdx.files.external(path + "-move"); move.delete(); if (move.exists()) fail(); copy.moveTo(move); if (handle.exists()) fail(); if (handle.isDirectory()) fail(); handle.delete(); handle.deleteDirectory();
if (handle.isDirectory()) fail("Internal file shouldn't be a directory"); try { handle.delete(); fail("Shouldn't be able to delete internal file"); } catch (Exception expected) { copy.delete(); if (copy.exists()) fail(); handle.copyTo(copy); if (!copy.exists()) fail(); if (copy.length() != 68465) fail(); copy.delete(); if (copy.exists()) fail(); handle.read().close();
private void testLocal () throws IOException { String path = "meow"; FileHandle handle = Gdx.files.local(path); handle.delete(); if (handle.exists()) fail(); if (handle.isDirectory()) fail(); if (handle.delete()) fail(); if (handle.list().length != 0) fail(); if (handle.child("meow").exists()) fail(); if (handle.length() != 3) fail(); FileHandle copy = Gdx.files.local(path + "-copy"); copy.delete(); if (copy.exists()) fail(); handle.copyTo(copy); if (copy.length() != 3) fail(); FileHandle move = Gdx.files.local(path + "-move"); move.delete(); if (move.exists()) fail(); copy.moveTo(move); if (handle.exists()) fail(); if (handle.isDirectory()) fail(); handle.delete(); handle.deleteDirectory();
public static void clean() { if(tempSaveTimer != null) tempSaveTimer.cancel(); getTempSaveFile().delete(); } }
@Override public boolean delete(String... path) throws PlayerDataException { if (path.length == 0) { throw new PlayerDataException("No file path specified"); } FileHandle file = resolve(path); if(file.isDirectory()) { return file.deleteDirectory(); } return file.delete(); }
FileHandle external=Gdx.files.external("data/com.package.name/music/"+file.name()); file.copyTo(external); VorbisDecoder decoder = new VorbisDecoder(external); FileHandle extreactedDataFile=Gdx.files.external("data/com.package.name/music/"+file.nameWithoutExtension()+".mdata"); if(extreactedDataFile.exists())extreactedDataFile.delete(); ShortBuffer sbuffer=ByteBuffer.wrap(shortBytes).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); while(true){ if(LogoScreen.shouldBreakMusicLoad)break; int num=decoder.readSamples(samples, 0,samples.length); sbuffer.put(samples,0,num); sbuffer.position(0); extreactedDataFile.writeBytes(shortBytes,0,num*2, true); if(num<=0)break; } external.delete();
/** Moves this file to the specified file, overwriting the file if it already exists. * @throws GdxRuntimeException if the source or destination file handle is a {@link FileType#Classpath} or * {@link FileType#Internal} file. */ public void moveTo (FileHandle dest) { switch (type) { case Classpath: throw new GdxRuntimeException("Cannot move a classpath file: " + file); case Internal: throw new GdxRuntimeException("Cannot move an internal file: " + file); case Absolute: case External: // Try rename for efficiency and to change case on case-insensitive file systems. if (file().renameTo(dest.file())) return; } copyTo(dest); delete(); if (exists() && isDirectory()) deleteDirectory(); }
private void deleteSave() { final FileHandle handle = Gdx.files.local(SAVE_DAT_FILENAME); if (handle.exists()) handle.delete(); }
public boolean deleteFile(String fileName) { final FileHandle fh = Gdx.files.external(basePath != null ? basePath + fileName : fileName); return fh.exists() && fh.delete(); }
@Override public void saveToFile(TexturePacker.Settings settings, BufferedImage image, File file) throws IOException { FileHandle tmpPngFile = new FileHandle(File.createTempFile(file.getName(), null)); FileHandle output = new FileHandle(file); super.saveToFile(settings, image, tmpPngFile.file()); KtxEtc2Processor.process(tmpPngFile, output, pixelFormat); tmpPngFile.delete(); if (zipping) { FileUtils.packGzip(output); } } }
@Override public void saveToFile(TexturePacker.Settings settings, BufferedImage image, File file) throws IOException { FileHandle tmpPngFile = new FileHandle(File.createTempFile(file.getName(), null)); FileHandle output = new FileHandle(file); super.saveToFile(settings, image, tmpPngFile.file()); KtxEtc1Processor.process(tmpPngFile, output, alphaChannel); tmpPngFile.delete(); if (zipping) { FileUtils.packGzip(output); } } }
@Override protected void doInBackground() throws Exception { FileHandle tmpFile = FileUtils.createTempFile("CjkFontPackage"); try { FileUtils.downloadFile(tmpFile, fileUrl); if (checkCanceled()) return; FileUtils.unpackZip(tmpFile, getModuleDir()); } finally { if (tmpFile != null) { tmpFile.delete(); } } } });
public void endGame() { dispose(); // DELETE SAVEGAME if (EngineAssetManager.getInstance().getUserFile(GAMESTATE_FILENAME).exists()) { EngineAssetManager.getInstance().getUserFile(GAMESTATE_FILENAME).delete(); } }