mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 07:10:36 +08:00
Merge pull request #443 from Microsoft/fix-not-empty-directory-warning
Fix ENOTEMPTY warning
This commit is contained in:
@@ -54,25 +54,11 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteDirectory(File directory) {
|
||||
if (directory.exists()) {
|
||||
File[] files = directory.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if(file.isDirectory()) {
|
||||
deleteDirectory(file);
|
||||
}
|
||||
else {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
directory.delete();
|
||||
}
|
||||
|
||||
public static void deleteDirectoryAtPath(String directoryPath) {
|
||||
deleteDirectory(new File(directoryPath));
|
||||
File file = new File(directoryPath);
|
||||
if (file.exists()) {
|
||||
deleteFileOrFolderSilently(file);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteFileAtPathSilently(String path) {
|
||||
@@ -86,9 +72,7 @@ public class FileUtils {
|
||||
if (fileEntry.isDirectory()) {
|
||||
deleteFileOrFolderSilently(fileEntry);
|
||||
} else {
|
||||
if (!file.delete()) {
|
||||
fileEntry.delete();
|
||||
}
|
||||
fileEntry.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +131,7 @@ public class FileUtils {
|
||||
|
||||
File destinationFolder = new File(destination);
|
||||
if (destinationFolder.exists()) {
|
||||
deleteDirectory(destinationFolder);
|
||||
deleteFileOrFolderSilently(destinationFolder);
|
||||
}
|
||||
|
||||
destinationFolder.mkdirs();
|
||||
|
||||
Reference in New Issue
Block a user