示例#1
0
        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;
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <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);
        }
示例#5
0
 protected override void Read(ArArchiveFileReader reader)
 {
     Stream   = reader.ReadAsStream(Size);
     SizeKind = ValueKind.Auto;
 }
示例#6
0
 protected override void Read(ArArchiveFileReader reader)
 {
     Stream = reader.ReadAsStream(Size);
 }