package org.eclipse.packagedrone.repo.adapter.p2.internal.aspect;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import org.eclipse.packagedrone.repo.utils.IOConsumer;

public class FileSpoolOutHandler implements SpoolOutHandler
{
    private final File base;

    public FileSpoolOutHandler ( final File base )
    {
        this.base = base;
    }

    @Override
    public void spoolOut ( final String id, final String name, final String mimeType, final IOConsumer<OutputStream> stream ) throws IOException
    {
        final File file = new File ( this.base, name );
        file.getParentFile ().mkdirs ();

        try ( OutputStream out = new BufferedOutputStream ( new FileOutputStream ( file ) ) )
        {
            stream.accept ( null );
        }
    }

}

@@ -1,12 +1,538 @@
+/*******************************************************************************%0A * Copyright (c) 2015 IBH SYSTEMS GmbH.%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A *%0A * Contributors:%0A *     IBH SYSTEMS GmbH - initial API and implementation%0A *******************************************************************************/%0A
 package org.

fix missing license header