package com.avg.zaap.crashlibrary.publish.externalstorage;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * This interface defines the common behavior for the external storage publisher dependency
 * factories.
 * <p/>
 * Created by marek.osvald on 29.4.2016.
 */
public interface IExternalStorageCrashPublisherFactory {

    /**
     * Opens file for given file path.
     *
     * @param filePath file path to open the file for
     * @return file for given file path
     */
    File openFile(String filePath);

    /**
     * Opens file for given file directory and file name.
     *
     * @param directory directory to open the file for
     * @param fileName  file name to open the file for
     * @return file for given directory and file name
     */
    File openFile(File directory, String fileName);

    /**
     * Opens a file input stream.
     *
     * @param file to open the input stream for
     * @return file input stream
     * @throws FileNotFoundException when the file does not exist
     */
    InputStream openFileInputStream(File file) throws FileNotFoundException;

    /**
     * Opens a file output stream.
     *
     * @param file to open the output stream for
     * @return file output stream
     * @throws FileNotFoundException when the file does not exist
     */
    OutputStream openFileOutputStream(File file) throws FileNotFoundException;

    /**
     * Returns a new instance of byte array buffer.
     *
     * @param size size of the buffer in bytes
     * @return new instance of byte array buffer
     */
    @SuppressWarnings("SameParameterValue")
    byte[] getBuffer(int size);

}
