1 21 22 package org.apache.derbyTesting.functionTests.util.corruptio; 23 import org.apache.derby.io.StorageFile; 24 import org.apache.derby.io.StorageRandomAccessFile; 25 import java.io.File ; 26 import java.io.InputStream ; 27 import java.io.OutputStream ; 28 import java.io.FileOutputStream ; 29 import java.io.FileInputStream ; 30 import java.io.IOException ; 31 import java.io.FileNotFoundException ; 32 import java.io.RandomAccessFile ; 33 import java.net.MalformedURLException ; 34 import java.net.URL ; 35 36 43 class CorruptFile implements StorageFile { 44 45 private StorageFile realFile = null; 46 47 CorruptFile(StorageFile realFile) 48 { 49 this.realFile = realFile; 50 } 51 52 53 65 public String [] list() 66 { 67 return realFile.list(); 68 } 69 70 75 public boolean canWrite() 76 { 77 return realFile.canWrite(); 78 } 79 80 85 public boolean exists() 86 { 87 return realFile.exists(); 88 } 89 90 98 public boolean isDirectory() 99 { 100 return realFile.isDirectory(); 101 } 102 103 110 public boolean delete() 111 { 112 return realFile.delete(); 113 } 114 115 122 public boolean deleteAll() 123 { 124 return realFile.deleteAll(); 125 } 126 140 public String getPath() 141 { 142 return realFile.getPath(); 143 } 144 153 public String getCanonicalPath() throws IOException 154 { 155 return realFile.getCanonicalPath(); 156 } 157 158 162 public String getName() 163 { 164 return realFile.getName(); 165 } 166 167 184 public boolean createNewFile() throws IOException 185 { 186 return realFile.createNewFile(); 187 } 188 189 205 public boolean renameTo( StorageFile newName) 206 { 207 return realFile.renameTo(newName); 208 } 209 210 215 public boolean mkdir() 216 { 217 return realFile.mkdir(); 218 } 219 224 public boolean mkdirs() 225 { 226 return realFile.mkdirs(); 227 } 228 229 230 239 public long length() 240 { 241 return realFile.length(); 242 } 243 244 253 public boolean setReadOnly() 254 { 255 return realFile.setReadOnly(); 256 } 257 258 264 public StorageFile getParentDir() 265 { 266 return realFile.getParentDir(); 267 } 268 269 280 public OutputStream getOutputStream( ) throws FileNotFoundException 281 { 282 return realFile.getOutputStream(); 283 } 284 285 300 public OutputStream getOutputStream( final boolean append) throws FileNotFoundException 301 { 302 return realFile.getOutputStream(append); 303 } 304 305 314 public InputStream getInputStream( ) throws FileNotFoundException 315 { 316 return realFile.getInputStream(); 317 } 318 319 334 public synchronized int getExclusiveFileLock() 335 { 336 return realFile.getExclusiveFileLock(); 337 338 } 340 347 public synchronized void releaseExclusiveFileLock() 348 { 349 realFile.releaseExclusiveFileLock(); 350 351 } 353 354 380 public StorageRandomAccessFile getRandomAccessFile( String mode) throws FileNotFoundException 381 { 382 return new CorruptRandomAccessFile(realFile.getRandomAccessFile(mode), (File) realFile); 383 } 384 385 388 protected StorageFile getRealFileInstance() 389 { 390 return realFile; 391 } 392 395 public URL getURL() throws MalformedURLException { 396 throw new MalformedURLException (toString()); 397 } 398 } 399 | Popular Tags |