@@ -0,0 +1,1344 @@
+/**%0A * %0A */%0Apackage cn.strong.fastdfs.client.protocol.request.storage;%0A%0Aimport static cn.strong.fastdfs.client.Consts.ERRNO_OK;%0Aimport static cn.strong.fastdfs.client.Consts.FDFS_PROTO_PKG_LEN_SIZE;%0Aimport static cn.strong.fastdfs.client.Consts.HEAD_LEN;%0Aimport static io.netty.util.CharsetUtil.UTF_8;%0Aimport io.netty.buffer.ByteBuf;%0Aimport io.netty.channel.ChannelHandlerContext;%0A%0Aimport java.util.List;%0A%0Aimport cn.strong.fastdfs.client.CommandCodes;%0Aimport cn.strong.fastdfs.client.protocol.request.Request;%0Aimport cn.strong.fastdfs.model.StoragePath;%0A%0A/**%0A * %E6%88%AA%E5%8F%96%E8%AF%B7%E6%B1%82%0A * %0A * @author liulongbiao%0A *%0A */%0Apublic class TruncateRequest implements Request %7B%0A%0A%09public final StoragePath spath;%0A%09public final int truncatedSize;%0A%0A%09public TruncateRequest(StoragePath spath, int truncatedSize) %7B%0A%09%09this.spath = spath;%0A%09%09this.truncatedSize = truncatedSize;%0A%09%7D%0A%0A%09@Override%0A%09public void encode(ChannelHandlerContext ctx, List%3CObject%3E out) %7B%0A%09%09byte%5B%5D pathBytes = spath.path.getBytes(UTF_8);%0A%09%09int length = 2 * FDFS_PROTO_PKG_LEN_SIZE + pathBytes.length;%0A%09%09byte cmd = CommandCodes.STORAGE_PROTO_CMD_TRUNCATE_FILE;%0A%09%09ByteBuf buf = ctx.alloc().buffer(length + HEAD_LEN);%0A%09%09buf.writeLong(length);%0A%09%09buf.writeByte(cmd);%0A%09%09buf.writeByte(ERRNO_OK);%0A%09%09buf.writeLong(pathBytes.length);%0A%09%09buf.writeLong(truncatedSize);%0A%09%09buf.writeBytes(pathBytes);%0A%0A%09%09out.add(buf);%0A%09%7D%0A%0A%7D%0A

add Truncate