Java Code Examples for com.hippo.yorozuya.FileUtils#ensureDirectory()

The following examples show how to use com.hippo.yorozuya.FileUtils#ensureDirectory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppConfig.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Nullable
public static File getExternalAppDir() {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        File dir = new File(Environment.getExternalStorageDirectory(), APP_DIRNAME);
        return FileUtils.ensureDirectory(dir) ? dir : null;
    }
    return null;
}
 
Example 2
Source File: AppConfig.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
/**
 * mkdirs and get
 */
@Nullable
public static File getDirInExternalAppDir(String filename) {
    File appFolder = getExternalAppDir();
    if (appFolder != null) {
        File dir = new File(appFolder, filename);
        return FileUtils.ensureDirectory(dir) ? dir : null;
    }
    return null;
}
 
Example 3
Source File: AppConfig.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Nullable
public static File getTempDir() {
    File dir = sContext.getCacheDir();
    File file;
    if (null != dir && FileUtils.ensureDirectory(file = new File(dir, TEMP))) {
        return file;
    } else {
        return null;
    }
}
 
Example 4
Source File: NMBAppConfig.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
public static @Nullable File getExternalAppDir() {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        File file = new File(Environment.getExternalStorageDirectory(), APP_DIRNAME);
        if (FileUtils.ensureDirectory(file)) {
            return file;
        } else {
            return null;
        }
    } else {
        return null;
    }
}
 
Example 5
Source File: NMBAppConfig.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
/**
 * mkdirs and get
 */
public static @Nullable File getDirInAppDir(String filename) {
    File appFolder = getExternalAppDir();
    if (appFolder != null) {
        File dir = new File(appFolder, filename);
        if (FileUtils.ensureDirectory(dir)) {
            return dir;
        }
    }

    return null;
}
 
Example 6
Source File: NMBAppConfig.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
public static @Nullable File getTempDir() {
    File temp = new File(sContext.getCacheDir(), "temp");
    if (FileUtils.ensureDirectory(temp)) {
        return temp;
    } else {
        return null;
    }
}
 
Example 7
Source File: NMBAppConfig.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
private static @Nullable File getRecordImageDir() {
    File temp = sContext.getDir("record", 0);
    if (FileUtils.ensureDirectory(temp)) {
        return temp;
    } else {
        return null;
    }
}
 
Example 8
Source File: AppConfig.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Nullable
public static File getExternalAppDir() {
    if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        File dir = new File(Environment.getExternalStorageDirectory(), APP_DIRNAME);
        return FileUtils.ensureDirectory(dir) ? dir : null;
    }
    return null;
}
 
Example 9
Source File: AppConfig.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
/**
 * mkdirs and get
 */
@Nullable
public static File getDirInExternalAppDir(String filename) {
    File appFolder = getExternalAppDir();
    if (appFolder != null) {
        File dir = new File(appFolder, filename);
        return FileUtils.ensureDirectory(dir) ? dir : null;
    }
    return null;
}
 
Example 10
Source File: AppConfig.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Nullable
public static File getTempDir() {
    File dir = sContext.getCacheDir();
    File file;
    if (null != dir && FileUtils.ensureDirectory(file = new File(dir, TEMP))) {
        return file;
    } else {
        return null;
    }
}