Пример #1
0
        internal void Read(string filename, BinaryReader reader, long size)
        {
            IsStaticLibrary(reader, throw_if_error: true);

            var pos = reader.BaseStream.Position;

            reader.BaseStream.Position += 8;             // header

            byte [] bytes;
            while (reader.BaseStream.Position < pos + size)
            {
                var fileIdentifier            = ReadString(reader, 16);
                var fileModificationTimestamp = ReadDecimal(reader, 12);
                var ownerId  = ReadDecimal(reader, 6);
                var groupId  = ReadDecimal(reader, 6);
                var fileMode = ReadOctal(reader, 8);
                var fileSize = ReadDecimal(reader, 10);
                bytes = reader.ReadBytes(2);                  // ending characters
                if (bytes [0] != 0x60 && bytes [1] != 0x0A)
                {
                    throw ErrorHelper.CreateError(1605, Errors.MT1605, fileIdentifier, filename, bytes[0].ToString("x"), bytes[1].ToString("x"));
                }

                if (fileIdentifier.StartsWith("#1/", StringComparison.Ordinal))
                {
                    var nameLength = int.Parse(fileIdentifier.Substring(3).TrimEnd(' '));
                    fileIdentifier = ReadString(reader, nameLength);
                    fileSize      -= nameLength;
                }

                var nextPosition = reader.BaseStream.Position + fileSize;
                if (MachOFile.IsMachOLibrary(null, reader))
                {
                    var file = new MachOFile(fileIdentifier);
                    file.Read(reader);
                    object_files.Add(file);
                }
                // byte position is always even after each file.
                if (nextPosition % 1 == 1)
                {
                    nextPosition++;
                }
                reader.BaseStream.Position = nextPosition;
            }
        }
Пример #2
0
        internal void ReadEntry(BinaryReader reader)
        {
            reader.BaseStream.Position = offset;

            if (MachOFile.IsMachOLibrary(this, reader))
            {
                entry = new MachOFile(this);
                entry.Read(reader);
            }
            else if (StaticLibrary.IsStaticLibrary(reader))
            {
                static_library = new StaticLibrary();
                static_library.Read(parent?.Filename, reader, size);
            }
            else
            {
                throw ErrorHelper.CreateError(1603, Errors.MX1603, offset, parent.Filename);
            }
        }
Пример #3
0
        internal void ReadEntry(BinaryReader reader)
        {
            reader.BaseStream.Position = offset;

            if (MachOFile.IsMachOLibrary(this, reader))
            {
                entry = new MachOFile(this);
                entry.Read(reader);
            }
            else if (StaticLibrary.IsStaticLibrary(reader))
            {
                static_library = new StaticLibrary();
                static_library.Read(reader);
            }
            else
            {
                throw ErrorHelper.CreateError(1603, "Unknown format for fat entry at position {0} in {1}.", offset, parent.Filename);
            }
        }