/// <summary>
        /// Enumerate the FileEntries in the given Deb file
        /// </summary>
        /// <param name="fileEntry">The Deb file FileEntry</param>
        /// <param name="options">The ExtractorOptions to use</param>
        /// <param name="governor">The ResourceGovernor to use</param>
        /// <returns>The FileEntries found</returns>
        public static IEnumerable <FileEntry> GetFileEntries(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor)
        {
            if (fileEntry == null)
            {
                yield break;
            }

            // First, cut out the file signature (8 bytes) and global header (64 bytes)
            fileEntry.Content.Position = 72;
            var headerBytes = new byte[60];

            while (true)
            {
                if (fileEntry.Content.Length - fileEntry.Content.Position < 60)  // The header for each file is 60 bytes
                {
                    break;
                }
                fileEntry.Content.Read(headerBytes, 0, 60);
                var filename      = Encoding.ASCII.GetString(headerBytes[0..16]).Trim(); // filename is 16 bytes
Esempio n. 2
0
        /// <summary>
        /// Get the FileEntries contained in the FileEntry representing an Ar file
        /// </summary>
        /// <param name="fileEntry">The FileEntry to parse</param>
        /// <param name="options">The ExtractorOptions</param>
        /// <param name="governor">The RsourceGovernor to use</param>
        /// <returns>The FileEntries found.</returns>
        public static IEnumerable <FileEntry> GetFileEntries(FileEntry fileEntry, ExtractorOptions options, ResourceGovernor governor)
        {
            if (fileEntry == null)
            {
                yield break;
            }
            // First, cut out the file signature (8 bytes)
            fileEntry.Content.Position = 8;
            var filenameLookup = new Dictionary <int, string>();
            var headerBuffer   = new byte[60];

            while (true)
            {
                if (fileEntry.Content.Length - fileEntry.Content.Position < 60)  // The header for each file is 60 bytes
                {
                    break;
                }

                fileEntry.Content.Read(headerBuffer, 0, 60);
                var headerString = Encoding.ASCII.GetString(headerBuffer);
                if (long.TryParse(Encoding.ASCII.GetString(headerBuffer[48..58]), out var size))// header size in bytes
 public ResourceGovernor(ExtractorOptions opts)
 {
     options           = opts;
     GovernorStopwatch = new Stopwatch();
 }