You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by tc...@apache.org on 2005/08/18 10:31:23 UTC
svn commit: r233300 -
/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/FileResourceStore.java
Author: tcurdt
Date: Thu Aug 18 01:31:18 2005
New Revision: 233300
URL: http://svn.apache.org/viewcvs?rev=233300&view=rev
Log:
proper dir structure (thanks to Joerg)
Modified:
jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/FileResourceStore.java
Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/FileResourceStore.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/FileResourceStore.java?rev=233300&r1=233299&r2=233300&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/FileResourceStore.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/stores/FileResourceStore.java Thu Aug 18 01:31:18 2005
@@ -32,14 +32,14 @@
public final class FileResourceStore implements ResourceStore {
private final File root;
-
+
public FileResourceStore(final File pFile) {
root = pFile;
}
public byte[] read( final String resourceName ) {
InputStream is = null;
try {
- is = new FileInputStream(new File(root, resourceName));
+ is = new FileInputStream(getFile(resourceName));
final byte[] data = IOUtils.toByteArray(is);
return data;
} catch (FileNotFoundException e) {
@@ -52,14 +52,20 @@
}
}
}
-
+
return null;
}
-
public void write( final String resourceName, final byte[] clazzData ) {
OutputStream os = null;
try {
- os = new FileOutputStream(new File(root, resourceName));
+ final File file = getFile(resourceName);
+ final File parent = file.getParentFile();
+ if (!parent.exists()) {
+ if (!parent.mkdirs()) {
+ throw new IOException("could not create" + parent);
+ }
+ }
+ os = new FileOutputStream(file);
os.write(clazzData);
} catch (FileNotFoundException e) {
} catch (IOException e) {
@@ -71,10 +77,15 @@
}
}
}
- }
+ }
+
+ public void remove( final String pResourceName ) {
+ getFile(pResourceName).delete();
+ }
- public void remove( final String resourceName ) {
- final File file = new File(root, resourceName);
- file.delete();
+ private File getFile(final String pResourceName) {
+ final String fileName = pResourceName.replace('.', File.separatorChar) + ".class";
+ return new File(root, fileName);
}
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org