1package dev.advo.fs.net.ondemand;
4import org.jboss.netty.buffer.ChannelBuffer;
5import org.jboss.netty.buffer.ChannelBuffers;
6import org.jboss.netty.channel.Channel;
7import org.jboss.netty.channel.ChannelHandlerContext;
8import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
10import dev.advo.fs.fs.FileDescriptor;
15 protected Object
encode(ChannelHandlerContext ctx, Channel c, Object msg)
throws Exception {
23 ChannelBuffer buf = ChannelBuffers.buffer(7 + chunkData.readableBytes());
25 buf.writeInt(fileSize);
26 buf.writeBytes(chunkData);
33 public static int create(
int index,
int file) {
34 if ((index & 0xFFFFFFE0) != 0)
35 throw new IllegalArgumentException(
"invalid index " + index +
":" + file);
36 if ((file & 0xFFF80000) != 0)
37 throw new IllegalArgumentException(
"invalid file " + index +
":" + file);
38 return index & 0x1F | (file & 0x7FFFF) << 5;
A class which points to a file in the cache.
int getFile()
Gets the file id.
int getType()
Gets the file type.
static int create(int index, int file)
Object encode(ChannelHandlerContext ctx, Channel c, Object msg)
FileDescriptor getFileDescriptor()
ChannelBuffer getChunkData()