diff --git a/termux-shared/src/main/java/com/termux/shared/file/FileUtils.java b/termux-shared/src/main/java/com/termux/shared/file/FileUtils.java index 0860c9ae..ee9bf9b3 100644 --- a/termux-shared/src/main/java/com/termux/shared/file/FileUtils.java +++ b/termux-shared/src/main/java/com/termux/shared/file/FileUtils.java @@ -220,6 +220,20 @@ public class FileUtils { return getFileType(filePath, false) == FileType.SYMLINK; } + /** + * Checks whether a regular or directory file exists at {@code filePath}. + * + * @param filePath The {@code path} for regular file to check. + * @param followLinks The {@code boolean} that decides if symlinks will be followed while + * finding if file exists. Check {@link #getFileType(String, boolean)} + * for details. + * @return Returns {@code true} if regular or directory file exists, otherwise {@code false}. + */ + public static boolean regularOrDirectoryFileExists(final String filePath, final boolean followLinks) { + FileType fileType = getFileType(filePath, followLinks); + return fileType == FileType.REGULAR || fileType == FileType.DIRECTORY; + } + /** * Checks whether any file exists at {@code filePath}. *