Rewrote DeleteFolder
Rewrote the helper class DeleteFolder. It was leaving behind empty directories when pockets were deleted.
This commit is contained in:
parent
c1e58c25cc
commit
f64768ed16
1 changed files with 15 additions and 13 deletions
|
@ -2,31 +2,33 @@ package StevenDimDoors.mod_pocketDim.helpers;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class DeleteFolder
|
||||
{
|
||||
public static boolean deleteFolder(File file)
|
||||
public static boolean deleteFolder(File directory)
|
||||
{
|
||||
try
|
||||
{
|
||||
File[] files = file.listFiles();
|
||||
|
||||
if(files==null)
|
||||
File[] contents = directory.listFiles();
|
||||
if (contents != null)
|
||||
{
|
||||
file.delete();
|
||||
return true;
|
||||
for (File entry : contents)
|
||||
{
|
||||
if (entry.isDirectory())
|
||||
{
|
||||
deleteFolder(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
for(File inFile : files)
|
||||
{
|
||||
DeleteFolder.deleteFolder(inFile);
|
||||
}
|
||||
|
||||
return directory.delete();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue