public void Write(byte[] src, int offset, int size) { int i, need_size; bool realloc_flag; i = this.size; this.size += size; need_size = this.pos + this.size; realloc_flag = false; int memsize = p.Length; while (need_size > memsize) { memsize = Math.Max(memsize, FifoInitMemSize) * 3; realloc_flag = true; } if (realloc_flag) { byte[] new_p = new byte[memsize]; Util.CopyByte(new_p, 0, this.p, 0, this.p.Length); this.p = new_p; } if (src != null) { Util.CopyByte(this.p, this.pos + i, src, offset, size); } totalWriteSize += size; }
public TarHeader(bool dummy) { this.Name = new byte[100]; this.Mode = new byte[8]; this.UID = new byte[8]; this.GID = new byte[8]; this.Size = new byte[12]; this.MTime = new byte[12]; this.CheckSum = new byte[8]; this.LinkName = new byte[100]; this.Magic = new byte[6]; this.Version = new byte[2]; this.UName = new byte[32]; this.GName = new byte[32]; this.DevMajor = new byte[8]; this.DevMinor = new byte[8]; this.Prefix = new byte[155]; this.Padding = new byte[12]; this.TypeFlag = 0; this.Version[0] = 0x20; this.Version[1] = 0x00; byte[] data = Str.ShiftJisEncoding.GetBytes("ustar "); Util.CopyByte(this.Magic, 0, data, 0, 6); }
public static byte[] CloneByteArray(byte[] src) { byte[] ret = new byte[src.Length]; Util.CopyByte(ret, src, 0, src.Length); return(ret); }
public static byte[] ExtractByteArray(byte[] data, int pos, int len) { byte[] ret = new byte[len]; Util.CopyByte(ret, 0, data, pos, len); return(ret); }
public static void StrToByteArray(byte[] dst, string str) { Encoding e = Str.ShiftJisEncoding; byte[] d = e.GetBytes(str); Array.Clear(dst, 0, dst.Length); Util.CopyByte(dst, 0, d, 0, Math.Min(d.Length, dst.Length - 1)); }
public static byte[] RemoveStartByteArray(byte[] src, int numBytes) { if (numBytes == 0) { return(src); } int num = src.Length - numBytes; byte[] ret = new byte[num]; Util.CopyByte(ret, 0, src, numBytes, num); return(ret); }
public void SetName(string name, Encoding encoding) { byte[] data = encoding.GetBytes(name); if (data.Length <= 100) { Util.CopyByte(this.Name, 0, data, 0, data.Length); } else { Util.CopyByte(this.Name, 0, data, 0, 100); Util.CopyByte(this.Prefix, 0, data, 100, data.Length - 100); } }
public bool Read(byte[] buf, int offset, int size) { if (size == 0) { return(true); } lock (lockObj) { if (this.HamMode) { byte[] ret = hamBuf.Read((uint)size); if (ret.Length != size) { return(false); } Util.CopyByte(buf, offset, ret, 0, size); return(true); } if (p != null) { try { int ret = p.Read(buf, offset, size); if (ret == size) { return(true); } else { return(false); } } catch { return(false); } } else { return(false); } } }
public int Read(byte[] dst, int offset, int size) { int read_size; read_size = Math.Min(size, this.size); if (read_size == 0) { return(0); } if (dst != null) { Util.CopyByte(dst, offset, this.p, this.pos, size); } this.pos += read_size; this.size -= read_size; if (this.size == 0) { this.pos = 0; } if (this.pos >= FifoInitMemSize && this.p.Length >= this.reallocMemSize && (this.p.Length / 2) > this.size) { byte[] new_p; int new_size; new_size = Math.Max(this.p.Length / 2, FifoInitMemSize); new_p = new byte[new_size]; Util.CopyByte(new_p, 0, this.p, this.pos, this.size); this.p = new_p; this.pos = 0; } totalReadSize += read_size; return(read_size); }