1 5 package org.h2.store; 6 7 import java.sql.SQLException ; 8 9 import org.h2.util.FileUtils; 10 import org.h2.util.MemoryFile; 11 12 public class MemoryFileStore extends FileStore { 13 14 private MemoryFile memFile; 15 16 public MemoryFileStore(DataHandler handler, String name, byte[] magic) throws SQLException { 17 super(handler, magic); 18 this.name = name; 19 memFile = FileUtils.getMemoryFile(name); 20 memFile.setMagic(magic); 21 } 22 23 public void close() { 24 } 26 27 public long getFilePointer() { 28 return memFile.getFilePointer(); 29 } 30 31 public long length() { 32 return memFile.length(); 33 } 34 35 public void readFully(byte[] b, int off, int len) throws SQLException { 36 checkPowerOff(); 37 memFile.readFully(b, off, len); 38 } 39 40 public void seek(long pos) { 41 memFile.seek(pos); 42 } 43 44 public void setLength(long newLength) throws SQLException { 45 checkPowerOff(); 46 memFile.setLength(newLength); 47 } 48 49 public void write(byte[] b, int off, int len) throws SQLException { 50 checkPowerOff(); 51 memFile.write(b, off, len); 52 } 53 54 } 55 | Popular Tags |