static private void emptyDirectory (File file, boolean preserveTree) { if (file.exists()) { File[] files = file.listFiles(); if (files != null) { for (int i = 0, n = files.length; i < n; i++) { if (!files[i].isDirectory()) files[i].delete(); else if (preserveTree) emptyDirectory(files[i], true); else deleteDirectory(files[i]); } } } }
static private void emptyDirectory (File file, boolean preserveTree) { if (file.exists()) { File[] files = file.listFiles(); if (files != null) { for (int i = 0, n = files.length; i < n; i++) { if (!files[i].isDirectory()) files[i].delete(); else if (preserveTree) emptyDirectory(files[i], true); else deleteDirectory(files[i]); } } } }
/** Deletes this file or directory and all children, recursively. * @throws GdxRuntimeException if this file handle is a {@link FileType#Classpath} or {@link FileType#Internal} file. */ public boolean deleteDirectory () { if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot delete a classpath file: " + file); if (type == FileType.Internal) throw new GdxRuntimeException("Cannot delete an internal file: " + file); return deleteDirectory(file()); }
/** Deletes this file or directory and all children, recursively. * @throws GdxRuntimeException if this file handle is a {@link FileType#Classpath} or {@link FileType#Internal} file. */ public boolean deleteDirectory () { if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot delete a classpath file: " + file); if (type == FileType.Internal) throw new GdxRuntimeException("Cannot delete an internal file: " + file); return deleteDirectory(file()); }
/** 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(); }
if (!child.name().equals("meow")) fail(); if (!child.parent().exists()) fail(); if (!handle.deleteDirectory()) fail(); if (handle.exists()) fail(); OutputStream output = handle.write(false); if (!move.exists()) fail(); if (move.length() != 3) fail(); move.deleteDirectory(); if (move.exists()) fail(); InputStream input = handle.read(); if (!handle.nameWithoutExtension().equals("meow")) fail(); if (!handle.extension().equals("")) fail(); handle.deleteDirectory(); if (handle.exists()) fail(); if (handle.isDirectory()) fail(); handle.delete(); handle.deleteDirectory();
if (!child.name().equals("meow")) fail(); if (!child.parent().exists()) fail(); if (!handle.deleteDirectory()) fail(); if (handle.exists()) fail(); OutputStream output = handle.write(false); if (!move.exists()) fail(); if (move.length() != 3) fail(); move.deleteDirectory(); if (move.exists()) fail(); InputStream input = handle.read(); if (!handle.nameWithoutExtension().equals("meow")) fail(); if (!handle.extension().equals("")) fail(); handle.deleteDirectory(); if (handle.exists()) fail(); if (handle.isDirectory()) fail(); handle.delete(); handle.deleteDirectory();
if (!child.name().equals("meow")) fail(); if (!child.parent().exists()) fail(); if (!handle.deleteDirectory()) fail(); if (handle.exists()) fail(); OutputStream output = handle.write(false); if (!move.exists()) fail(); if (move.length() != 3) fail(); move.deleteDirectory(); if (move.exists()) fail(); InputStream input = handle.read(); if (!handle.nameWithoutExtension().equals("meow")) fail(); if (!handle.extension().equals("")) fail(); handle.deleteDirectory(); if (handle.exists()) fail(); if (handle.isDirectory()) fail(); handle.delete(); handle.deleteDirectory();
@Override public boolean delete (FileHandle file) { return file.deleteDirectory(); } }
static private void emptyDirectory (File file, boolean preserveTree) { if (file.exists()) { File[] files = file.listFiles(); if (files != null) { for (int i = 0, n = files.length; i < n; i++) { if (!files[i].isDirectory()) files[i].delete(); else if (preserveTree) emptyDirectory(files[i], true); else deleteDirectory(files[i]); } } } }
@Override protected void doInBackground() throws Exception { FileHandle moduleDir = getModuleDir(); if (moduleDir.exists()) { moduleDir.deleteDirectory(); } } });
public void purgeTempDirectory() { for (FileHandle f : Gdx.files.absolute(TEMP_DIR).list()) { f.deleteDirectory(); } }
/** Deletes this file or directory and all children, recursively. * @throws GdxRuntimeException if this file handle is a {@link FileType#Classpath} or {@link FileType#Internal} file. */ public boolean deleteDirectory () { if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot delete a classpath file: " + file); if (type == FileType.Internal) throw new GdxRuntimeException("Cannot delete an internal file: " + file); return deleteDirectory(file()); }
@Override public void wipe() throws PlayerDataException { FileHandle directory = Gdx.files.absolute(saveDirectory); if (!directory.exists()) { return; } directory.emptyDirectory(); directory.deleteDirectory(); }
@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(); }
/** 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(); }