Пример #1
0
        /// <inheritdoc/>
        public override bool Read()
        {
            this.EnsureMagicRead();

            if (this.EntryStream != null)
            {
                this.EntryStream.Dispose();
            }

            this.Align(2);

            if (this.Stream.Position == this.Stream.Length)
            {
                return(false);
            }

            this.entryHeader = this.Stream.ReadStruct <ArHeader>();
            this.FileHeader  = this.entryHeader;
            this.FileName    = this.entryHeader.FileName;

            if (this.entryHeader.EndChar != "`\n")
            {
                throw new InvalidDataException("The magic for the file entry is invalid");
            }

            this.EntryStream = new SubStream(this.Stream, this.Stream.Position, this.entryHeader.FileSize, leaveParentOpen: true);

            return(true);
        }
Пример #2
0
 public static void WriteEntry(Stream output, ArHeader header, Stream data)
 {
     output.WriteStruct(header);
     data.CopyTo(output);
     if (output.Position % 2 != 0)
     {
         output.WriteByte(0);
     }
 }
Пример #3
0
        public static void WriteEntry(Stream output, string name, LinuxFileMode mode, Stream data)
        {
            var hdr = new ArHeader
            {
                EndChar      = "`\n",
                FileMode     = mode,
                FileName     = name,
                FileSize     = (uint)data.Length,
                GroupId      = 0,
                OwnerId      = 0,
                LastModified = DateTimeOffset.UtcNow
            };

            WriteEntry(output, hdr, data);
        }