Move ContentSettingsFragment.isValidPath to helpers and add unit test for it.

This commit is contained in:
Alireza Tofighi 2021-05-21 20:21:58 +04:30
parent 01f05e2f46
commit 15873d53c4
3 changed files with 57 additions and 10 deletions

View file

@ -0,0 +1,22 @@
package org.schabi.newpipe.util;
import java.io.File;
public final class FilePathUtils {
private FilePathUtils() { }
/**
* Check that the path is a valid directory path and it exists.
*
* @param path full path of directory,
* @return is path valid or not
*/
public static boolean isValidDirectoryPath(final String path) {
if (path == null || path.isEmpty()) {
return false;
}
final File file = new File(path);
return file.exists() && file.isDirectory();
}
}