<commit_before>/*
 * Licensed 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.google.devtools.j2objc.util;

import com.google.common.collect.Lists;
import com.google.common.io.CharStreams;
import com.google.devtools.j2objc.J2ObjC;
import com.google.devtools.j2objc.ast.CompilationUnit;
import com.google.devtools.j2objc.ast.PackageDeclaration;
import com.google.devtools.j2objc.file.InputFile;
import com.google.devtools.j2objc.file.JarredInputFile;
import com.google.devtools.j2objc.file.RegularInputFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Properties;
import javax.annotation.Nullable;
import javax.tools.JavaFileObject;

/**
 * Utilities for reading {@link com.google.devtools.j2objc.file.InputFile}s.
 *
 * @author <NAME>, <NAME>, <NAME>, <NAME>
 */
public class FileUtil {

  private List<String> sourcePathEntries = Lists.newArrayList(".");
  private List<String> classPathEntries = Lists.newArrayList(".");
  private File outputDirectory = new File(".");
  private String fileEncoding = System.getProperty("file.encoding", "UTF-8");
  private Charset charset = Charset.forName(fileEncoding);

  public void setSourcePathEntries(List<String> sourcePathEntries) {
    this.sourcePathEntries = sourcePathEntries;
  }

  public List<String> getSourcePathEntries() {
    return sourcePathEntries;
  }

  public void appendSourcePath(String entry) {
    sourcePathEntries.add(entry);
  }

  public void insertSourcePath(int index, String entry) {
    sourcePathEntries.add(index, entry);
  }

  public List<String> getClassPathEntries() {
    return classPathEntries;
  }

  public void setOutputDirectory(File outputDirectory) {
    this.outputDirectory = outputDirectory;
  }

  public File getOutputDirectory() {
    return outputDirectory;
  }

  public void setFileEncoding(String fileEncoding) {
    this.fileEncoding = fileEncoding;
    charset = Charset.forName(fileEncoding);
  }

  public String getFileEncoding() {<commit_msg>Create output directory if it doesn't exist.<commit_after>/*
 * Licensed 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.google.devtools.j2objc.util;

import com.google.common.collect.Lists;
import com.google.common.io.CharStreams;
import com.google.devtools.j2objc.J2ObjC;
import com.google.devtools.j2objc.ast.CompilationUnit;
import com.google.devtools.j2objc.ast.PackageDeclaration;
import com.google.devtools.j2objc.file.InputFile;
import com.google.devtools.j2objc.file.JarredInputFile;
import com.google.devtools.j2objc.file.RegularInputFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Properties;
import javax.annotation.Nullable;
import javax.tools.JavaFileObject;

/**
 * Utilities for reading {@link com.google.devtools.j2objc.file.InputFile}s.
 *
 * @author <NAME>, <NAME>, <NAME>, <NAME>
 */
public class FileUtil {

  private List<String> sourcePathEntries = Lists.newArrayList(".");
  private List<String> classPathEntries = Lists.newArrayList(".");
  private File outputDirectory = new File(".");
  private String fileEncoding = System.getProperty("file.encoding", "UTF-8");
  private Charset charset = Charset.forName(fileEncoding);

  public void setSourcePathEntries(List<String> sourcePathEntries) {
    this.sourcePathEntries = sourcePathEntries;
  }

  public List<String> getSourcePathEntries() {
    return sourcePathEntries;
  }

  public void appendSourcePath(String entry) {
    sourcePathEntries.add(entry);
  }

  public void insertSourcePath(int index, String entry) {
    sourcePathEntries.add(index, entry);
  }

  public List<String> getClassPathEntries() {
    return classPathEntries;
  }

  public void setOutputDirectory(File outputDirectory) {
    this.outputDirectory = outputDirectory;
  }

  public File getOutputDirectory() {
    if (!outputDirectory.exists()) {
      outputDirectory.mkdirs();
    }
    return outputDirectory;
  }

  public void setFileEncoding(String fileEncoding) {
    this.fileEncoding = fileEncoding;
    charset = Charset.forName(fileEncoding);
  }

  public String getFileEncoding() {
{'fraction_non_alphanumeric': 0.1013790532985464, 'fraction_numerical': 0.005218039508013418, 'mean_word_length': 4.740106951871658, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1117282', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1544, 'n_words': 415}