/// <summary> /// Writes the tags contained in the current instance to the /// beginning of the file that created it, overwriting the /// existing tags. /// </summary> /// <returns> /// A <see cref="long" /> value indicating the seek position /// in the file at which the written tags end. This also /// marks the seek position at which the media begins. /// </returns> public long Write() { ByteVector data = Render(); file.Insert(data, 0, TotalSize); return(data.Count); }
/// <summary> /// Writes the tags contained in the current instance to the /// end of the file that created it, overwriting the existing /// tags. /// </summary> /// <returns> /// A <see cref="long" /> value indicating the seek position /// in the file at which the written tags begin. This also /// marks the seek position at which the media ends. /// </returns> public long Write() { long total_size = TotalSize; ByteVector data = Render(); file.Insert(data, file.Length - total_size, total_size); return(file.Length - data.Count); }
/// <summary> /// Overwrites the header on disk, updating it to include a /// change in the size of the box. /// </summary> /// <param name="file"> /// A <see cref="TagLibSharp.File" /> object containing the file /// from which the box originates. /// </param> /// <param name="sizeChange"> /// A <see cref="long" /> value indicating the change in the /// size of the box described by the current instance. /// </param> /// <returns> /// The size change encountered by the box that parents the /// box described the the current instance, equal to the /// size change of the box plus any size change that should /// happen in the header. /// </returns> public long Overwrite(TagLibSharp.File file, long sizeChange) { if (file == null) { throw new ArgumentNullException("file"); } if (!from_disk) { throw new InvalidOperationException( "Cannot overwrite headers not on disk."); } long old_header_size = HeaderSize; DataSize += sizeChange; file.Insert(Render(), position, old_header_size); return(sizeChange + HeaderSize - old_header_size); }