List of usage examples for com.badlogic.gdx.files FileHandle delete
public boolean delete()
From source file:Generator.java
License:Open Source License
private static void renamePrefixes(String path, String prefix, String newPrefix) { Files files = new LwjglFiles(); for (FileHandle fileHandle : files.local(path).list()) { if (fileHandle.name().startsWith(prefix)) { String newName = newPrefix + fileHandle.name().substring(prefix.length()); println(fileHandle.name() + " -> " + newName); fileHandle.sibling(newName).write(fileHandle.read(), false); fileHandle.delete(); }/* w ww . j a v a 2 s.c o m*/ } }
From source file:CB_Core.DAO.CacheListDAO.java
License:Open Source License
public void delCacheImagesByPath(String path, ArrayList<String> list) { for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) { final String GcCode = iterator.next().toLowerCase(); String directory = path + "/" + GcCode.substring(0, 4); if (!FileIO.DirectoryExists(directory)) continue; FileHandle dir = new FileHandle(directory); FileHandle[] files = dir.list(); for (int i = 0; i < files.length; i++) { // simplyfied for startswith gccode, thumbs_gccode + ooverwiewthumbs_gccode if (!files[i].name().toLowerCase().contains(GcCode)) continue; String filename = directory + "/" + files[i].name(); FileHandle file = new FileHandle(filename); if (file.exists()) { if (!file.delete()) Log.err(log, "Error deleting : " + filename); }/* w w w . j a va 2 s . c o m*/ } } }
From source file:com.intrepid.studio.animation.GenerateAnimationPackInfo.java
private void generateNewAnimationInfo(Json json) { rootContent.foreachFilesInContentDirectoriesExec(new FileExec() { @Override/*w ww . j a va 2s . c o m*/ public void runOver(FileHandle fHandle) { if (fHandle.extension().equals(NEW_EXTENSION)) { String line = null; try (BufferedReader br = new BufferedReader(new FileReader(fHandle.file()))) { line = br.readLine(); } catch (IOException e) { e.printStackTrace(); } String path = fHandle.path(); String[] split = path.split("/"); String dir = split[split.length - 2]; String name = split[split.length - 1]; String tagName = dir + "." + name; AnimationInfo animationInfo = AnimationInfoFactory.create(tagName, line); System.out.println(" new found: [ " + fHandle.path() + " ]"); String toWrite = json.prettyPrint(animationInfo); String output = fHandle.pathWithoutExtension() + "." + SAI_EXTENSION; files.local(output).writeString(toWrite, false); fHandle.delete(); } } }); }
From source file:com.kotcrab.vis.editor.util.vis.JNAFileDeleter.java
License:Apache License
@Override public boolean delete(FileHandle file) throws IOException { if (hasTrash()) { fileUtils.moveToTrash(new File[] { file.file() }); return true; } else {/*from w w w. ja v a 2 s .c om*/ return file.delete(); } }
From source file:com.kotcrab.vis.ui.widget.file.JNAFileDeleter.java
License:Apache License
@Override public boolean delete(FileHandle file) throws IOException { if (hasTrash()) { fileUtils.moveToTrash(new File[] { file.file() }); return true; } else {/* w w w . ja v a 2 s .c o m*/ return file.delete(); } }
From source file:com.ray3k.skincomposer.data.AtlasData.java
License:Open Source License
public void writeAtlas() throws Exception { FileHandle targetFile = Gdx.files.local("temp/" + main.getProjectData().getId() + ".atlas"); targetFile.parent().mkdirs();//from w w w . j a va 2s . com FileHandle[] oldFiles = targetFile.parent().list(new FilenameFilter() { @Override public boolean accept(File file, String string) { return string.matches(targetFile.nameWithoutExtension() + "\\d*\\.(?i)png"); } }); for (FileHandle fileHandle : oldFiles) { fileHandle.delete(); } targetFile.sibling(targetFile.nameWithoutExtension() + ".atlas").delete(); Array<FileHandle> files = new Array<>(); for (DrawableData drawable : drawables) { if (!files.contains(drawable.file, false)) { files.add(drawable.file); } } main.getDesktopWorker().texturePack(files, main.getProjectData().getSaveFile(), targetFile, main.getProjectData().getMaxTextureWidth(), main.getProjectData().getMaxTextureHeight(), main.getProjectData().getStripWhitespace()); }
From source file:com.ray3k.skincomposer.data.AtlasData.java
License:Open Source License
public void writeAtlas(FileHandle targetFile) throws Exception { targetFile.parent().mkdirs();/*w w w. ja v a 2 s. c om*/ FileHandle[] oldFiles = targetFile.parent().list(new FilenameFilter() { @Override public boolean accept(File file, String string) { return string.matches(targetFile.nameWithoutExtension() + "\\d*\\.(?i)png"); } }); for (FileHandle fileHandle : oldFiles) { fileHandle.delete(); } targetFile.sibling(targetFile.nameWithoutExtension() + ".atlas").delete(); Array<FileHandle> files = new Array<>(); for (DrawableData drawable : drawables) { if (!files.contains(drawable.file, false)) { files.add(drawable.file); } } main.getDesktopWorker().texturePack(files, main.getProjectData().getSaveFile(), targetFile, main.getProjectData().getMaxTextureWidth(), main.getProjectData().getMaxTextureHeight(), main.getProjectData().getStripWhitespace()); }
From source file:com.sidereal.dolphinoes.architecture.core.GameData.java
License:Apache License
/** Removes a file from the map if it the key can be found, and removes the file from the disk. * <p>//from ww w. ja v a2s. c o m * {@link #filePaths}, {@link #loadOnStartup} and {@link #data} will be updated to reflect the changes. * @param dataName * The key to the data */ public final void delete(String dataName) { if (storageType.equals(StorageType.None)) return; DolphinOES.debug.log("Removing file from disk at location: " + dataName); if (contains(dataName)) { FileHandle file = getFileHandle(rootDataPath + dataName + ".dd"); if (file.exists()) { file.delete(); } data.remove(dataName); filePaths.remove(dataName); loadOnStartup.remove(dataName); } }
From source file:com.strategames.engine.storage.LevelWriter.java
License:Open Source License
/** * Deletes the original level file which will be loaded when level is played the first time * during a game//from w w w.j av a 2 s . c o m * @param level * @return */ static public boolean deleteOriginal(Level level) { try { FileHandle file = Gdx.files.local(Files.getOriginalLevelFilename(level)); return file.delete(); } catch (Exception e) { return false; } }
From source file:com.strategames.engine.storage.LevelWriter.java
License:Open Source License
/** * Deletes the completed level file which will be loaded when level is played again * @param level//from w w w .j a v a 2 s . c o m * @return true if success, false otherwise */ static public boolean deleteCompleted(Level level) { try { FileHandle file = Gdx.files.local(Files.getCompletedLevelFilename(level)); return file.delete(); } catch (Exception e) { return false; } }