void InitFileByteData() { _bytePartList = new BytePartList(); _bytePartList.AddFirst(new FileBytePart(0, _fileDataStream.Length)); Length = _fileDataStream.Length; _undoList = new UndoList(); }
public override void RemoveBytes(long index, long length, BytePartList bytePartList) { byte[] newBytes = new byte[_bytes.LongLength - length]; if (index > 0) { Array.Copy(_bytes, 0, newBytes, 0, index); } if (index + length < _bytes.LongLength) { Array.Copy(_bytes, index + length, newBytes, index, newBytes.LongLength - index); } _bytes = newBytes; }
public override void RemoveBytes(long index, long length, BytePartList bytePartList) { if (bytePartList == null) { throw new ArgumentNullException("bytePartList", "FileBytePart.RemoveBytes: The parameter cannot be NULL."); } if (index > _filePartLength) { throw new ArgumentOutOfRangeException("index", "FileBytePart.RemoveBytes: The index cannot be greater than the length."); } if (index + length > _filePartLength) { throw new ArgumentOutOfRangeException("length", "FileBytePart.RemoveBytes: No more elements can be removed than are present."); } long startIndex = _filePartIndex; long startLength = index; long endIndex = _filePartIndex + index + length; long endLength = _filePartLength - length - startLength; if (startLength > 0 && endLength > 0) { _filePartIndex = startIndex; _filePartLength = startLength; LinkedListNode <BytePart> bp = bytePartList.Find(this); bytePartList.AddAfter(bp, new FileBytePart(endIndex, endLength)); } else { if (startLength > 0) { _filePartIndex = startIndex; _filePartLength = startLength; } else { _filePartIndex = endIndex; _filePartLength = endLength; } } }
public abstract void RemoveBytes(long index, long length, BytePartList bytePartList);