<commit_before>package floobits.utilities;

import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import floobits.common.Constants;
import floobits.common.FloorcJson;
import floobits.common.RunLater;
import floobits.common.Settings;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;

import java.io.File;
import java.io.IOException;

public class SelectFolder {

    public static void build(String owner, String workspace, final RunLater<String> runLater) {
        FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false);
        descriptor.setTitle("Select Folder For Workspace");
        descriptor.setDescription("NOTE: Floobits will NOT make a new, root directory inside the folder you choose. If you have cloned the project already, select that folder.");
        FloorcJson floorcJson;
        try {
            floorcJson =  Settings.get();
        } catch (Exception e) {
            Flog.errorMessage("Your floorc.json has invalid json.", null);
            return;
        }
        File file = null;
        String shareDir = floorcJson.share_dir;
        if (shareDir != null) {
            Character c = shareDir.charAt(0);
            if (c == '/' || c == '~') {
                if (shareDir.substring(0, 2).equals("~/")) {
                    shareDir = shareDir.replaceFirst("~/", System.getProperty("user.home") + "/");
                }
                file = createDir(shareDir, owner, workspace);
                if (file == null) {
                    Flog.errorMessage(String.format("Your floorc.json share_dir setting %s did not work, using default ~/floobits",
                            floorcJson.share_dir), null);
                }
            } else {
                Flog.errorMessage(String.format("floorc.json share_dir paths must be absolute paths, you had %s", shareDir), null);
            }
        }
        if (file == null) {
            file = createDir(Constants.shareDir, owner, workspace);
        }
        if (file == null) {
            Flog.errorMessage(String.format("Could not create a directory for this workspace, tried %s", Constants.shareDir), null);
            return;
        }
        VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
        VirtualFile[] vFiles = FileChooser.chooseFiles(descriptor, null, virtualFile);
        if (vFiles.length == 0) {
            return;
        }
        if (vFiles.length > 1) {
            Flog.errorMessage("You can only select one directory!", null);
            return;
        }
        final String selectedPath = vFiles[0].getPath();
        runLater.run(selectedPath);
    }


    private static File createDir(String path, String owner, String workspace) {
        path = FilenameUtils.concat(path, owner);
        path = FilenameUtils.concat(path, workspace);
        File file = new File(path);
        try {
            FileUtils.forceMkdir(file);
        } catch (IOException e) {
            Flog.warn(e);
            return null;
        }
        return file;
    }
}
<commit_msg>Can't do this check because windows. #180<commit_after>package floobits.utilities;

import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import floobits.common.Constants;
import floobits.common.FloorcJson;
import floobits.common.RunLater;
import floobits.common.Settings;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;

import java.io.File;
import java.io.IOException;

public class SelectFolder {

    public static void build(String owner, String workspace, final RunLater<String> runLater) {
        FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false);
        descriptor.setTitle("Select Folder For Workspace");
        descriptor.setDescription("NOTE: Floobits will NOT make a new, root directory inside the folder you choose. If you have cloned the project already, select that folder.");
        FloorcJson floorcJson;
        try {
            floorcJson =  Settings.get();
        } catch (Exception e) {
            Flog.errorMessage("Your floorc.json has invalid json.", null);
            return;
        }
        File file = null;
        String shareDir = floorcJson.share_dir;
        if (shareDir != null) {
            if (shareDir.substring(0, 2).equals("~/")) {
                shareDir = shareDir.replaceFirst("~/", System.getProperty("user.home") + "/");
            }
            file = createDir(shareDir, owner, workspace);
            if (file == null) {
                Flog.errorMessage(String.format("Your floorc.json share_dir setting %s did not work, using default ~/floobits",
                        floorcJson.share_dir), null);
            }
        }
        if (file == null) {
            file = createDir(Constants.shareDir, owner, workspace);
        }
        if (file == null) {
            Flog.errorMessage(String.format("Could not create a directory for this workspace, tried %s", Constants.shareDir), null);
            return;
        }
        VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
        VirtualFile[] vFiles = FileChooser.chooseFiles(descriptor, null, virtualFile);
        if (vFiles.length == 0) {
            return;
        }
        if (vFiles.length > 1) {
            Flog.errorMessage("You can only select one directory!", null);
            return;
        }
        final String selectedPath = vFiles[0].getPath();
        runLater.run(selectedPath);
    }


    private static File createDir(String path, String owner, String workspace) {
        path = FilenameUtils.concat(path, owner);
        path = FilenameUtils.concat(path, workspace);
        File file = new File(path);
        try {
            FileUtils.forceMkdir(file);
        } catch (IOException e) {
            Flog.warn(e);
            return null;
        }
        return file;
    }
}

{'fraction_non_alphanumeric': 0.10466041037060601, 'fraction_numerical': 0.0022268172419277876, 'mean_word_length': 2.40997830802603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6258348', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1709, 'n_words': 437}