<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package com.doplgangr.secrecy.FileSystem;

import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;

import com.doplgangr.secrecy.Config;
import com.doplgangr.secrecy.CustomApp;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class storage {

    public static void DeleteRecursive(java.io.File fileOrDirectory) {
        if (fileOrDirectory.isDirectory())
            for (java.io.File child : fileOrDirectory.listFiles())
                DeleteRecursive(child);
        fileOrDirectory.delete();
    }

    public static java.io.File getTempFolder() {
        java.io.File tempDir = CustomApp.context.getExternalCacheDir();
        if (tempDir == null)
            tempDir = CustomApp.context.getFilesDir();
        tempDir.mkdirs();
        return tempDir;
    }

    private static String getAbsTempFolder() {
        return getTempFolder().getAbsolutePath() + "/";
    }

    private static String ROOT() {
        SharedPreferences settings = CustomApp.context.getSharedPreferences(Config.settingsStore, 0);
        return settings.getString(Config.root, Environment.getExternalStorageDirectory()
                .getAbsoluteFile()
                + "/SECRECYFILES");
    }

    public static java.io.File getRoot() {
        java.io.File tempDir = new java.io.File(ROOT());
        tempDir.mkdirs();
        return tempDir;
    }<commit_msg>Use FileUtils functions to prevent delete problems<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package com.doplgangr.secrecy.FileSystem;

import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;

import com.doplgangr.secrecy.Config;
import com.doplgangr.secrecy.CustomApp;
import com.doplgangr.secrecy.Util;

import org.apache.commons.io.FileUtils;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class storage {

    public static void DeleteRecursive(java.io.File directory) {
        try {
            FileUtils.cleanDirectory(directory);
        } catch (IOException e) {
            Util.log(e);
        }
    }

    public static java.io.File getTempFolder() {
        java.io.File tempDir = CustomApp.context.getExternalCacheDir();
        if (tempDir == null)                                                // when all else fails
            tempDir = CustomApp.context.getFilesDir();
        try {
            FileUtils.forceMkdir(tempDir);
        } catch (IOException e) {
            Util.log(e);
        }
        return tempDir;
    }

    private static String getAbsTempFolder() {
        return getTempFolder().getAbsolutePath() + "/";
    }

    private static String ROOT() {
        SharedPreferences settings = CustomApp.context.getSharedPreferences(Config.settingsStore, 0);
        return settings.getString(Config.root, Environment.getExternalStorageDirectory()
                .getAbsoluteFile()
                + "/SECRECYFILES");
    }

    public static java.io.File getRoot() {
        java.io.File tempDir = new java.io.File(ROOT());
        try {
            FileUtils.forceMkdir(tempDir);
        } catch (IOException e) {
            Util.log(e);
        }
        return tempDir;
    }
{'fraction_non_alphanumeric': 0.0878645343367827, 'fraction_numerical': 0.0018814675446848542, 'mean_word_length': 3.061115355233002, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5628008', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1386, 'n_words': 434}