1 21 22 package org.apache.derby.impl.io; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 26 import org.apache.derby.io.StorageFactory; 27 import org.apache.derby.io.StorageFile; 28 29 import java.io.File ; 30 import java.io.FileNotFoundException ; 31 import java.io.InputStream ; 32 import java.io.OutputStream ; 33 import java.io.IOException ; 34 35 import java.util.Properties ; 36 import java.util.zip.ZipEntry ; 37 import java.util.zip.ZipFile ; 38 39 43 44 public class JarStorageFactory extends BaseStorageFactory 45 { 46 ZipFile zipData; 47 48 55 StorageFile newPersistentFile( String path) 56 { 57 return new JarDBFile( this, path); 58 } 59 60 68 StorageFile newPersistentFile( String directoryName, String fileName) 69 { 70 if( directoryName == null || directoryName.length() == 0) 71 return newPersistentFile( fileName); 72 return new JarDBFile( this, directoryName, fileName); 73 } 74 75 83 StorageFile newPersistentFile( StorageFile directoryName, String fileName) 84 { 85 if( directoryName == null) 86 return newPersistentFile( fileName); 87 return new JarDBFile( (JarDBFile) directoryName, fileName); 88 } 89 90 void doInit() throws IOException 91 { 92 if( dataDirectory == null) 93 return; 94 int offset = 0; 96 while( offset < dataDirectory.length() & Character.isSpaceChar( dataDirectory.charAt( offset))) 97 offset ++; 98 int leftParen = -1; 99 int rightParen = -1; 100 if( offset < dataDirectory.length()) 101 { 102 leftParen = dataDirectory.indexOf( '(', offset); 103 if( leftParen >= 0) 104 rightParen = dataDirectory.indexOf( ')', leftParen + 1); 105 } 106 File jarFile = null; 107 if( rightParen > 0) 108 { 109 jarFile = getJarFile( dataDirectory.substring( leftParen + 1, rightParen)); 110 offset = rightParen + 1; 111 while( offset < dataDirectory.length() & Character.isSpaceChar( dataDirectory.charAt( offset))) 112 offset ++; 113 dataDirectory = dataDirectory.substring( offset, dataDirectory.length()); 114 } 115 else 116 { 117 jarFile = getJarFile( dataDirectory); 118 dataDirectory = ""; 119 } 120 zipData = new ZipFile ( jarFile); 121 canonicalName = "(" + jarFile.getCanonicalPath() + ")" + dataDirectory; 122 separatedDataDirectory = dataDirectory + '/'; createTempDir(); 124 } 126 private File getJarFile( String name) 127 { 128 File jarFile = new File( name); 129 if( home != null && !jarFile.isAbsolute()) 130 jarFile = new File( home, name); 131 return jarFile; 132 } } 134 | Popular Tags |