protected override void Read(ArArchiveFileReader reader) { var startPosition = reader.Stream.Position; var endPosition = startPosition + (long)Size; ElfObjectFile = ElfObjectFile.Read(new SliceStream(reader.Stream, reader.Stream.Position, (long)Size)); reader.Stream.Position = endPosition; }
/// <summary> /// Detects from the specified stream if there is an 'ar' archive file header. /// </summary> /// <param name="stream">The stream to detect the presence of an 'ar' archive file header.</param> /// <returns><c>true</c> if an 'ar' archive file header was detected. <c>false</c> otherwise.</returns> public static bool IsAr(Stream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } var startPosition = stream.Position; var result = ArArchiveFileReader.IsAr(stream, null); stream.Position = startPosition; return(result); }
/// <summary> /// Detects from the specified stream if there is an 'ar' archive file header. /// </summary> /// <param name="stream">The stream to detect the presence of an 'ar' archive file header.</param> /// <param name="diagnostics">The diagnostics</param> /// <returns><c>true</c> if an 'ar' archive file header was detected. <c>false</c> otherwise.</returns> public static bool IsAr(Stream stream, out DiagnosticBag diagnostics) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } var startPosition = stream.Position; diagnostics = new DiagnosticBag(); var result = ArArchiveFileReader.IsAr(stream, diagnostics); stream.Position = startPosition; return(result); }
/// <summary> /// Tries to reads an 'ar' archive file from the specified stream. /// </summary> /// <param name="stream">The stream to read 'ar' a archive file from.</param> /// <param name="options">The options used for reading this 'ar' file.</param> /// <param name="arArchiveFile">The output 'ar' archive file if the read was successful.</param> /// <param name="diagnostics">The output associated diagnostics after reading the archive.</param> /// <returns><c>true</c> An instance of <see cref="ArArchiveFile"/> if the read was successful.</returns> public static bool TryRead(Stream stream, ArArchiveFileReaderOptions options, out ArArchiveFile arArchiveFile, out DiagnosticBag diagnostics) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } arArchiveFile = new ArArchiveFile { Kind = options.ArchiveKind }; var reader = new ArArchiveFileReader(arArchiveFile, stream, options); diagnostics = reader.Diagnostics; reader.Read(); return(!reader.Diagnostics.HasErrors); }
protected override void Read(ArArchiveFileReader reader) { Stream = reader.ReadAsStream(Size); SizeKind = ValueKind.Auto; }
protected override void Read(ArArchiveFileReader reader) { Stream = reader.ReadAsStream(Size); }