List of usage examples for com.badlogic.gdx.files FileHandle deleteDirectory
public boolean deleteDirectory()
From source file:com.forerunnergames.peril.client.assets.LocalAssetUpdater.java
License:Open Source License
@Override public void updateAssets() { if (!AssetSettings.UPDATE_ASSETS) { log.warn("Assets are not being updated.\nTo change this behavior, change {} in {} from false to true.\n" + "Make sure to back up any customizations you made to any assets first, as your changes " + "will be overwritten.", ClientApplicationProperties.UPDATE_ASSETS_KEY, ClientApplicationProperties.PROPERTIES_FILE_PATH_AND_NAME); return;/*from ww w . j a v a 2s .c o m*/ } assetUpdatingFuture = executorService.submit(new Runnable() { @Override public void run() { final FileHandle destAssetsDir = Gdx.files .external(AssetSettings.RELATIVE_EXTERNAL_ASSETS_DIRECTORY); try { final FileHandle sourceAssetsDir = Gdx.files .absolute(AssetSettings.ABSOLUTE_UPDATED_ASSETS_LOCATION); log.info("Attempting to update assets in [{}] from [{}]...", destAssetsDir.file(), sourceAssetsDir); if (Thread.currentThread().isInterrupted()) { log.warn("Asset updating was cancelled before beginning."); return; } log.info("Removing old assets..."); destAssetsDir.deleteDirectory(); if (Thread.currentThread().isInterrupted()) { log.warn( "Asset updating was cancelled after removing old assets, but before copying new assets."); return; } log.info("Copying new assets..."); sourceAssetsDir.copyTo(destAssetsDir); log.info("Successfully updated assets."); } catch (final Exception e) { final String errorMessage = "Failed to update assets from: [" + AssetSettings.ABSOLUTE_UPDATED_ASSETS_LOCATION + "].\n" + "Make sure that " + ClientApplicationProperties.UPDATED_ASSETS_LOCATION_KEY + " is properly set in [" + ClientApplicationProperties.PROPERTIES_FILE_PATH_AND_NAME + "].\n" + "Also, " + ClientApplicationProperties.UPDATE_ASSETS_KEY + " must be set to true (in the same file) the first time you run the game.\n" + "If you already tried all of that, you can set " + ClientApplicationProperties.UPDATE_ASSETS_KEY + " to false.\nIn that case, you still need to make sure that you have a copy of all assets in " + destAssetsDir.file() + ".\n\n" + "Nerdy developer details:\n"; log.error(errorMessage, e); throw new RuntimeException(errorMessage, e); } } }); }
From source file:com.forerunnergames.peril.client.assets.S3AssetUpdater.java
License:Open Source License
@Override public void updateAssets() { if (!AssetSettings.UPDATE_ASSETS) { log.warn("Assets are not being updated.\nTo change this behavior, change {} in {} from false to true.\n" + "Make sure to back up any customizations you made to any assets first, as your changes " + "will be overwritten.", ClientApplicationProperties.UPDATE_ASSETS_KEY, ClientApplicationProperties.PROPERTIES_FILE_PATH_AND_NAME); return;/*from w w w .j av a 2s .co m*/ } assetUpdatingFuture = executorService.submit(new Runnable() { @Override public void run() { final FileHandle destAssetsDir = Gdx.files .external(AssetSettings.RELATIVE_EXTERNAL_ASSETS_DIRECTORY); try { log.info("Attempting to update assets in [{}] from [{}]...", destAssetsDir.file(), AssetSettings.ABSOLUTE_UPDATED_ASSETS_LOCATION); if (Thread.currentThread().isInterrupted()) { log.warn("Asset updating was cancelled before beginning."); return; } log.info("Removing old assets..."); destAssetsDir.deleteDirectory(); if (Thread.currentThread().isInterrupted()) { log.warn( "Asset updating was cancelled after removing old assets, but before downloading new assets."); return; } final File destinationDirectory = destAssetsDir.file(); log.info("Downloading new assets to [{}]...", destinationDirectory); downloadInProgress = transferManager.downloadDirectory(bucketName, AssetSettings.INITIAL_S3_ASSETS_DOWNLOAD_SUBDIRECTORY, destinationDirectory); log.info("Successfully updated assets."); } catch (final Exception e) { final String errorMessage = "Failed to update assets from: [" + bucketName + "].\n" + "Make sure that " + ClientApplicationProperties.UPDATED_ASSETS_LOCATION_KEY + " is properly set in [" + ClientApplicationProperties.PROPERTIES_FILE_PATH_AND_NAME + "].\n" + "Also, " + ClientApplicationProperties.UPDATE_ASSETS_KEY + " must be set to true (in the same file) the first time you run the game.\n" + "If you already tried all of that, you can set " + ClientApplicationProperties.UPDATE_ASSETS_KEY + " to false.\nIn that case, you still need to make sure that you have a copy of all assets in " + destAssetsDir.file() + ".\n\n" + "Nerdy developer details:\n"; log.error(errorMessage, e); throw new RuntimeException(errorMessage, e); } } }); }
From source file:com.kotcrab.vis.editor.module.project.AssetsAnalyzerModule.java
License:Apache License
@Override public void dispose() { for (FileHandle file : transactionBackupRoot.list()) { file.deleteDirectory(); } }
From source file:com.kotcrab.vis.editor.util.FileUtils.java
License:Apache License
/** * Trashes file if possible, if not the file is just deleted * @return if success, false otherwise/*from www.ja va 2 s.c o m*/ * @see #hasTrash */ public static boolean delete(FileHandle file) { try { if (hasTrash()) jnaFileUtils.moveToTrash(new File[] { file.file() }); else file.deleteDirectory(); return true; } catch (IOException e) { Log.exception(e); return false; } }
From source file:com.mbrlabs.mundus.core.registry.Registry.java
License:Apache License
public void purgeTempDirectory() { for (FileHandle f : Gdx.files.absolute(TEMP_DIR).list()) { f.deleteDirectory(); } }
From source file:com.ray3k.skincomposer.data.AtlasData.java
License:Open Source License
public void clearTempData() { FileHandle tempFolder = Gdx.files.local("temp/"); tempFolder.deleteDirectory(); }
From source file:com.strategames.engine.storage.GameWriter.java
License:Open Source License
/** * Deletes the complete game/*w w w . j a v a2s.c o m*/ * @param gameMetaData * @return */ static public boolean deleteInprogress(GameMetaData gameMetaData) { FileHandle file = Gdx.files.local(Files.getInProgressGameDirectory(gameMetaData)); if (file.isDirectory()) { try { return file.deleteDirectory(); } catch (Exception e) { Gdx.app.log("GameWriter", "deleteInprogress: failed to delete " + file.name()); } } return false; }
From source file:com.strategames.engine.storage.GameWriter.java
License:Open Source License
/** * Deletes the complete game/*from ww w. j a v a 2 s . c om*/ * @param gameMetaData * @return */ static public boolean deleteOriginal(GameMetaData gameMetaData) { FileHandle file = Gdx.files.local(Files.getOriginalGameDirectory(gameMetaData)); if (file.isDirectory()) { try { return file.deleteDirectory(); } catch (Exception e) { Gdx.app.log("GameWriter", "deleteOriginal: failed to delete " + file.name()); } } return false; }
From source file:com.strategames.engine.storage.GameWriter.java
License:Open Source License
static public boolean deleteAllOriginalGames() { FileHandle file = Gdx.files.local(Files.getOriginalGamesDirectory()); if (file.isDirectory()) { try {/*from w ww . ja v a 2 s .c om*/ return file.deleteDirectory(); } catch (Exception e) { Gdx.app.log("GameWriter", "deleteAllOriginalGames: failed to delete " + file.name()); } } return false; }
From source file:de.longri.cachebox3.develop.tools.skin_editor.SkinEditorGame.java
License:Apache License
@Override public void dispose() { super.dispose(); //delete temp folder FileHandle tmp = Gdx.files.local("null"); if (tmp.exists()) { Gdx.app.log("FINISH", "Delete tmp folder"); tmp.deleteDirectory(); }/*from w w w . j a va2s. c om*/ }