Messaging: Remove unused code
Change-Id: I8093bb3e305ae323f7069bf42f9e83f8c8647cc7
This commit is contained in:
@@ -25,7 +25,6 @@ import android.text.TextUtils;
|
||||
|
||||
import com.android.messaging.Factory;
|
||||
import com.android.messaging.R;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -71,55 +70,6 @@ public class FileUtil {
|
||||
return getNewFile(directory, fileExtension, fileNameFormat);
|
||||
}
|
||||
|
||||
/** Delete everything below and including root */
|
||||
public static void removeFileOrDirectory(File root) {
|
||||
removeFileOrDirectoryExcept(root, null);
|
||||
}
|
||||
|
||||
/** Delete everything below and including root except for the given file */
|
||||
public static void removeFileOrDirectoryExcept(File root, File exclude) {
|
||||
if (root.exists()) {
|
||||
if (root.isDirectory()) {
|
||||
for (File file : root.listFiles()) {
|
||||
if (exclude == null || !file.equals(exclude)) {
|
||||
removeFileOrDirectoryExcept(file, exclude);
|
||||
}
|
||||
}
|
||||
root.delete();
|
||||
} else if (root.isFile()) {
|
||||
root.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move all files and folders under a directory into the target.
|
||||
*/
|
||||
public static void moveAllContentUnderDirectory(File sourceDir, File targetDir) {
|
||||
if (sourceDir.isDirectory() && targetDir.isDirectory()) {
|
||||
if (isSameOrSubDirectory(sourceDir, targetDir)) {
|
||||
LogUtil.e(LogUtil.BUGLE_TAG, "Can't move directory content since the source " +
|
||||
"directory is a parent of the target");
|
||||
return;
|
||||
}
|
||||
for (File file : sourceDir.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
final File dirTarget = new File(targetDir, file.getName());
|
||||
dirTarget.mkdirs();
|
||||
moveAllContentUnderDirectory(file, dirTarget);
|
||||
} else {
|
||||
try {
|
||||
final File fileTarget = new File(targetDir, file.getName());
|
||||
Files.move(file, fileTarget);
|
||||
} catch (IOException e) {
|
||||
LogUtil.e(LogUtil.BUGLE_TAG, "Failed to move files", e);
|
||||
// Try proceed with the next file.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Checks if the file is in /data, and don't allow any app to send personal information.
|
||||
// We're told it's possible to create world readable hardlinks to other apps private data
|
||||
// so we ban all /data file uris.
|
||||
|
||||
Reference in New Issue
Block a user