Example usage for android.os FileUtils isValidExtFilename

List of usage examples for android.os FileUtils isValidExtFilename

Introduction

In this page you can find the example usage for android.os FileUtils isValidExtFilename.

Prototype

public static boolean isValidExtFilename(String name) 

Source Link

Document

Check if given filename is valid for an ext4 filesystem.

Usage

From source file:android.content.pm.PackageParser.java

private static String validateName(String name, boolean requireSeparator, boolean requireFilename) {
    final int N = name.length();
    boolean hasSep = false;
    boolean front = true;
    for (int i = 0; i < N; i++) {
        final char c = name.charAt(i);
        if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
            front = false;//  ww w  . ja v a2 s.com
            continue;
        }
        if (!front) {
            if ((c >= '0' && c <= '9') || c == '_') {
                continue;
            }
        }
        if (c == '.') {
            hasSep = true;
            front = true;
            continue;
        }
        return "bad character '" + c + "'";
    }
    if (requireFilename && !FileUtils.isValidExtFilename(name)) {
        return "Invalid filename";
    }
    return hasSep || !requireSeparator ? null : "must have at least one '.' separator";
}