<commit_before>/*
    Copyright (C) 2008  <NAME>.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package pigeon.report;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;

public final class DefaultStreamProvider implements StreamProvider
{
    private final Collection<File> files = new LinkedList<File>();
    private final Collection<OutputStream> streams = new LinkedList<OutputStream>();
    
    public void closeAllStreams() throws IOException
    {
        for (OutputStream stream: streams) {
            stream.close();
        }
    }
    
    public Collection<File> getFiles()
    {
        return Collections.unmodifiableCollection(files);
    }
    
    @Override
    public OutputStream createNewStream(String name) throws IOException
    {
        OutputStream result;
        File outputFile = File.createTempFile(name, "");
        FileOutputStream fileOut = new FileOutputStream(outputFile);
        files.add(outputFile);
        result = new BufferedOutputStream(fileOut);
        streams.add(result);
        return result;
    }
}
<commit_msg>Reports are now guaranteed to be written to the exact filename requested by the reporter.  This is required by the XML + XSLT style reporters which need to reference the ".xsl" file by name.<commit_after>/*
    Copyright (C) 2008  <NAME>.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package pigeon.report;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;

public final class DefaultStreamProvider implements StreamProvider
{
    private final File outputDirectory;; 
    private final Collection<File> files = new LinkedList<File>();
    private final Collection<OutputStream> streams = new LinkedList<OutputStream>();

    public DefaultStreamProvider() throws IOException
    {
        outputDirectory = Utilities.createTemporaryDirectory("RacePoint");
    }
    
    public void closeAllStreams() throws IOException
    {
        for (OutputStream stream: streams) {
            stream.close();
        }
    }
    
    public Collection<File> getFiles()
    {
        return Collections.unmodifiableCollection(files);
    }

    @Override
    public OutputStream createNewStream(String name) throws IOException
    {
        OutputStream result;
        File outputFile = new File(outputDirectory, name);
        if (outputFile.createNewFile() != true) {
            throw new IOException("Unable to create new file: " + outputFile.toString());
        }

        FileOutputStream fileOut = new FileOutputStream(outputFile);
        files.add(outputFile);
        result = new BufferedOutputStream(fileOut);
        streams.add(result);
        return result;
    }
}

{'fraction_non_alphanumeric': 0.0710576015108593, 'fraction_numerical': 0.002360717658168083, 'mean_word_length': 3.2327672327672325, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4261235', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1027, 'n_words': 411}