1 29 30 package com.caucho.vfs; 31 32 import java.io.IOException ; 33 import java.io.InputStream ; 34 import java.io.OutputStream ; 35 import java.util.logging.Logger ; 36 37 40 public class SpyRandomAccessStream extends RandomAccessStream { 41 private static final Logger log 42 = Logger.getLogger(SpyRandomAccessStream.class.getName()); 43 44 private RandomAccessStream _file; 45 46 public SpyRandomAccessStream(RandomAccessStream file) 47 { 48 _file = file; 49 } 50 51 54 public long getLength() 55 throws IOException 56 { 57 return _file.getLength(); 58 } 59 60 63 public int read(byte []buffer, int offset, int length) 64 throws IOException 65 { 66 log.info("random-read(0x" + Long.toHexString(getFilePointer()) + "," + 67 length + ")"); 68 69 return _file.read(buffer, offset, length); 70 } 71 72 75 public int read(long fileOffset, byte []buffer, int offset, int length) 76 throws IOException 77 { 78 log.info("random-read(0x" + Long.toHexString(fileOffset) + "," + 79 length + ")"); 80 81 return _file.read(fileOffset, buffer, offset, length); 82 } 83 84 public void write(byte []buffer, int offset, int length) 85 throws IOException 86 { 87 log.info("random-write(0x" + Long.toHexString(getFilePointer()) + "," + 88 length + ")"); 89 90 _file.write(buffer, offset, length); 91 } 92 93 96 public void write(long fileOffset, byte []buffer, int offset, int length) 97 throws IOException 98 { 99 log.info("random-write(0x" + Long.toHexString(fileOffset) + "," + 100 length + ")"); 101 102 _file.write(fileOffset, buffer, offset, length); 103 } 104 105 108 public boolean seek(long position) 109 { 110 log.info("random-seek(0x" + position + ")"); 111 112 return _file.seek(position); 113 } 114 115 118 public OutputStream getOutputStream() 119 throws IOException 120 { 121 return _file.getOutputStream(); 122 } 123 124 127 public InputStream getInputStream() 128 throws IOException 129 { 130 return _file.getInputStream(); 131 } 132 133 136 public int read() 137 throws IOException 138 { 139 log.info("random-read(0x" + Long.toHexString(getFilePointer()) + ",1)"); 140 141 return _file.read(); 142 } 143 144 147 public void write(int b) 148 throws IOException 149 { 150 log.info("random-write(0x" + Long.toHexString(getFilePointer()) + ",1)"); 151 152 _file.write(b); 153 } 154 155 158 public long getFilePointer() 159 throws IOException 160 { 161 return _file.getFilePointer(); 162 } 163 164 167 public void close() throws IOException 168 { 169 _file.close(); 170 } 171 } 172 | Popular Tags |