<commit_before>package com.mauriciotogneri.fileexplorer.models;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;

import com.mauriciotogneri.fileexplorer.utils.SpaceFormatter;

import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ref.SoftReference;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;

public class FileInfo
{
    private final File file;

    private String cachedName = null;
    private String cachedPath = null;
    private String cachedMimeType = null;
    private String cachedExtension = null;
    private String cachedSize = null;
    private Boolean cachedIsImage = null;
    private Boolean cachedIsPdf = null;
    private Boolean cachedIsAudio = null;
    private Boolean cachedIsVideo = null;
    private Boolean cachedIsDirectory = null;
    private Integer cachedNumberOfChildren = null;
    private SoftReference<Bitmap> cachedBitmap = null;
    private Uri cachedUri = null;
    private boolean isSelected = false;

    public FileInfo(File file)
    {
        this.file = file;
        this.cachedBitmap = new SoftReference<>(null);
    }

    public List<FileInfo> files()
    {
        List<FileInfo> result = new ArrayList<>();

        if (isDirectory())
        {
            for (File currentFile : children())
            {
                if (currentFile != null)
                {
                    FileInfo fileInfo = new FileInfo(currentFile);
                    result.addAll(fileInfo.files());
                }
            }
        }
        else
        {
            result.add(this);
        }

        return result;
    }

    public boolean rename(String newName)
    {
        File newFile = new File(file.getParentFile(), newName);

        return !newFile.exists() && file.renameTo(newFile);
    }

    public boolean copy(FileInfo target, boolean delete)
    {
        if (isDirectory())
        {
            boolean allCopied = true;

            for (File currentFile : children())
            {
                if (currentFile != null)
                {
                    FileInfo fileInfo = new FileInfo(currentFile);<commit_msg>Fixed bug copying empty folders<commit_after>package com.mauriciotogneri.fileexplorer.models;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;

import com.mauriciotogneri.fileexplorer.utils.SpaceFormatter;

import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ref.SoftReference;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;

public class FileInfo
{
    private final File file;

    private String cachedName = null;
    private String cachedPath = null;
    private String cachedMimeType = null;
    private String cachedExtension = null;
    private String cachedSize = null;
    private Boolean cachedIsImage = null;
    private Boolean cachedIsPdf = null;
    private Boolean cachedIsAudio = null;
    private Boolean cachedIsVideo = null;
    private Boolean cachedIsDirectory = null;
    private Integer cachedNumberOfChildren = null;
    private SoftReference<Bitmap> cachedBitmap = null;
    private Uri cachedUri = null;
    private boolean isSelected = false;

    public FileInfo(File file)
    {
        this.file = file;
        this.cachedBitmap = new SoftReference<>(null);
    }

    public List<FileInfo> files()
    {
        List<FileInfo> result = new ArrayList<>();

        if (isDirectory())
        {
            for (File currentFile : children())
            {
                if (currentFile != null)
                {
                    FileInfo fileInfo = new FileInfo(currentFile);
                    result.addAll(fileInfo.files());
                }
            }
        }
        else
        {
            result.add(this);
        }

        return result;
    }

    public boolean rename(String newName)
    {
        File newFile = new File(file.getParentFile(), newName);

        return !newFile.exists() && file.renameTo(newFile);
    }

    public boolean copy(FileInfo target, boolean delete)
    {
        if (isDirectory())
        {
            File newTargetFolder = new File(target.file, file.getName());
            boolean allCopied = (newTargetFolder.exists() || newTargetFolder.mkdirs());

            for (File currentFile : children())
            {
                if (currentFile != null)
                {
                    FileInfo fileInfo = new FileInfo(currentFile);
{'fraction_non_alphanumeric': 0.0868376787216148, 'fraction_numerical': 0.0, 'mean_word_length': 2.3335669236159777, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1374486', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1231, 'n_words': 329}