1 16 package org.apache.commons.vfs.provider.compressed; 17 18 import org.apache.commons.vfs.Capability; 19 import org.apache.commons.vfs.FileName; 20 import org.apache.commons.vfs.FileObject; 21 import org.apache.commons.vfs.FileSystemException; 22 import org.apache.commons.vfs.FileType; 23 import org.apache.commons.vfs.provider.AbstractFileObject; 24 25 31 public abstract class CompressedFileFileObject 32 extends AbstractFileObject 33 implements FileObject 34 { 35 private final FileObject container; 36 private String [] children; 37 38 protected CompressedFileFileObject(FileName name, FileObject container, CompressedFileFileSystem fs) 39 { 40 super(name, fs); 41 this.container = container; 42 43 String basename = container.getName().getBaseName(); 45 int pos = basename.lastIndexOf('.'); 46 basename = basename.substring(0, pos); 47 48 children = new String [] 49 { 50 basename 51 }; 52 } 53 54 57 public boolean isWriteable() 58 { 59 return getFileSystem().hasCapability(Capability.WRITE_CONTENT); 60 } 61 62 65 protected FileType doGetType() throws FileSystemException 66 { 67 if (getName().getPath().endsWith("/")) 68 { 69 return FileType.FOLDER; 70 } 71 else 72 { 73 return FileType.FILE; 74 } 75 } 76 77 80 protected String [] doListChildren() 81 { 82 return children; 83 } 84 85 89 protected long doGetContentSize() 90 { 91 return -1; 92 } 93 94 97 protected long doGetLastModifiedTime() throws Exception 98 { 99 return container.getContent().getLastModifiedTime(); 100 } 101 102 protected FileObject getContainer() 103 { 104 return container; 105 } 106 107 public void createFile() throws FileSystemException 108 { 109 container.createFile(); 110 injectType(FileType.FILE); 111 } 112 } 113 | Popular Tags |