|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| DirectoryBaseFileStreamFactory.java | - | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* Joey and its relative products are published under the terms
|
|
| 3 |
* of the Apache Software License.
|
|
| 4 |
*/
|
|
| 5 |
package org.asyrinx.brownie.core.io.sf;
|
|
| 6 |
|
|
| 7 |
import java.io.FileInputStream;
|
|
| 8 |
import java.io.FileOutputStream;
|
|
| 9 |
import java.io.IOException;
|
|
| 10 |
import java.io.InputStream;
|
|
| 11 |
import java.io.OutputStream;
|
|
| 12 |
|
|
| 13 |
import org.asyrinx.brownie.core.io.FileNameUtils;
|
|
| 14 |
|
|
| 15 |
/**
|
|
| 16 |
* @author Akima
|
|
| 17 |
*/
|
|
| 18 |
public class DirectoryBaseFileStreamFactory extends AbstractFileStreamFactory { |
|
| 19 |
|
|
| 20 |
/**
|
|
| 21 |
* Constructor for DirectoryBaseFileStreamFactory.
|
|
| 22 |
*/
|
|
| 23 | 0 |
public DirectoryBaseFileStreamFactory(String baseDirectory) {
|
| 24 | 0 |
super();
|
| 25 | 0 |
this.baseDirectory = baseDirectory;
|
| 26 |
} |
|
| 27 |
|
|
| 28 |
private final String baseDirectory;
|
|
| 29 |
|
|
| 30 |
/**
|
|
| 31 |
* @see org.asyrinx.brownie.core.io.sf.AbstractFileStreamFactory#toFilePath(java.lang.String)
|
|
| 32 |
*/
|
|
| 33 | 0 |
public String toFilePath(String virtualFileName) {
|
| 34 | 0 |
virtualFileName = FileNameUtils.replaceSeparatorSlash(virtualFileName); |
| 35 | 0 |
return FileNameUtils.toAbsolutePath(baseDirectory, virtualFileName);
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
/**
|
|
| 39 |
*/
|
|
| 40 | 0 |
public InputStream newInput(String fileName) throws IOException { |
| 41 | 0 |
return new FileInputStream(toFilePath(fileName)); |
| 42 |
} |
|
| 43 |
|
|
| 44 |
/**
|
|
| 45 |
*/
|
|
| 46 | 0 |
public OutputStream newOutput(String fileName) throws IOException { |
| 47 | 0 |
return new FileOutputStream(toFilePath(fileName)); |
| 48 |
} |
|
| 49 |
|
|
| 50 |
/**
|
|
| 51 |
* Returns the baseDirectory.
|
|
| 52 |
*
|
|
| 53 |
* @return String
|
|
| 54 |
*/
|
|
| 55 | 0 |
public String getBaseDirectory() {
|
| 56 | 0 |
return baseDirectory;
|
| 57 |
} |
|
| 58 |
|
|
| 59 |
} |
|
||||||||||