1 5 package org.h2.server.ftp; 6 7 import java.io.IOException ; 8 import java.io.InputStream ; 9 import java.io.OutputStream ; 10 11 public class FileObjectDatabase implements FileObject { 12 13 static FileObjectDatabase get(FileSystemDatabase db, String name) { 14 return new FileObjectDatabase(db, name); 15 } 16 17 private FileSystemDatabase db; 18 private String fullName; 19 20 private FileObjectDatabase(FileSystemDatabase db, String fullName) { 21 this.db = db; 22 this.fullName = fullName; 23 } 24 25 public boolean canRead() { 26 return true; 27 } 28 29 public boolean canWrite() { 30 return true; 31 } 32 33 public boolean delete() { 34 db.delete(fullName); 35 return true; 36 } 37 38 public boolean exists() { 39 return db.exists(fullName); 40 } 41 42 public void read(long skip, OutputStream out) throws IOException { 43 db.read(fullName, skip, out); 44 } 45 46 public String getName() { 47 return db.getName(fullName); 48 } 49 50 public void write(InputStream in) throws IOException { 51 db.write(fullName, in); 52 } 53 54 public boolean isDirectory() { 55 return db.isDirectory(fullName); 56 } 57 58 public boolean isFile() { 59 return !db.isDirectory(fullName); 60 } 61 62 public long lastModified() { 63 return db.lastModified(fullName); 64 } 65 66 public long length() { 67 return db.length(fullName); 68 } 69 70 public FileObject[] listFiles() { 71 return db.listFiles(fullName); 72 } 73 74 public boolean mkdirs() { 75 db.mkdirs(fullName); 76 return true; 77 } 78 79 public boolean renameTo(FileObject fileNew) { 80 return db.renameTo(fullName, ((FileObjectDatabase)fileNew).fullName); 81 } 82 83 } 84 | Popular Tags |