mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Allow null directories in directory deletion methods.
This commit is contained in:
parent
83db4e6a10
commit
79307923ad
1 changed files with 15 additions and 9 deletions
|
@ -129,15 +129,20 @@ public class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteDirectory(File directory) {
|
public static void deleteDirectory(File directory) {
|
||||||
|
if (directory != null) {
|
||||||
deleteInDirectory(directory);
|
deleteInDirectory(directory);
|
||||||
directory.delete();
|
directory.delete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void deleteInDirectory(File directory) {
|
public static void deleteInDirectory(File directory) {
|
||||||
|
if (directory != null) {
|
||||||
deleteInDirectoryApartFrom(directory);
|
deleteInDirectoryApartFrom(directory);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void deleteInDirectoryApartFrom(File directory, String... apartFrom) {
|
public static void deleteInDirectoryApartFrom(File directory, String... apartFrom) {
|
||||||
|
if (directory != null) {
|
||||||
Set<String> excluded = new HashSet<String>(Arrays.asList(apartFrom));
|
Set<String> excluded = new HashSet<String>(Arrays.asList(apartFrom));
|
||||||
for (File file : directory.listFiles()) {
|
for (File file : directory.listFiles()) {
|
||||||
if (!excluded.contains(file.getName())) {
|
if (!excluded.contains(file.getName())) {
|
||||||
|
@ -148,6 +153,7 @@ public class Util {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String fromStream(InputStream in) throws IOException
|
public static String fromStream(InputStream in) throws IOException
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue