1 11 package org.eclipse.core.internal.filesystem; 12 13 import java.io.*; 14 import java.net.URI ; 15 import java.net.URISyntaxException ; 16 import org.eclipse.core.filesystem.*; 17 import org.eclipse.core.filesystem.provider.FileInfo; 18 import org.eclipse.core.filesystem.provider.FileStore; 19 import org.eclipse.core.runtime.*; 20 21 27 public class NullFileStore extends FileStore { 28 private IPath path; 29 30 34 public NullFileStore(IPath path) { 35 this.path = path; 36 } 37 38 public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException { 39 return EMPTY_FILE_INFO_ARRAY; 40 } 41 42 public String [] childNames(int options, IProgressMonitor monitor) { 43 return EMPTY_STRING_ARRAY; 44 } 45 46 public void delete(int options, IProgressMonitor monitor) throws CoreException { 47 super.delete(options, monitor); 49 } 50 51 public IFileInfo fetchInfo(int options, IProgressMonitor monitor) { 52 FileInfo result = new FileInfo(getName()); 53 result.setExists(false); 54 return result; 55 } 56 57 public IFileStore getChild(String name) { 58 return new NullFileStore(path.append(name)); 59 } 60 61 public IFileSystem getFileSystem() { 62 return NullFileSystem.getInstance(); 63 } 64 65 public String getName() { 66 return String.valueOf(path.lastSegment()); 67 } 68 69 public IFileStore getParent() { 70 return path.segmentCount() == 0 ? null : new NullFileStore(path.removeLastSegments(1)); 71 } 72 73 public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException { 74 return super.mkdir(options, monitor); 76 } 77 78 public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException { 79 return new ByteArrayInputStream(new byte[0]); 80 } 81 82 public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException { 83 return new OutputStream() { 84 public void write(int b) throws IOException { 85 } 87 }; 88 } 89 90 public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException { 91 super.putInfo(info, options, monitor); 93 } 94 95 public String toString() { 96 return path.toString(); 97 } 98 99 public URI toURI() { 100 try { 101 return new URI (EFS.SCHEME_NULL, null, path.toString(), null); 102 } catch (URISyntaxException e) { 103 throw new Error (e); 105 } 106 } 107 } 108 | Popular Tags |