Beispiel #1
0
        /// <summary>
        /// Prüft, ob im Verzeichnis der Anwendung Dekomprimierungstabellen zu finden sind und
        /// verwendet diese dann.
        /// </summary>
        /// <returns>Liste aller erfolgreich geladenen Tabellen.</returns>
        public static int[] DynamicLoadTables()
        {
            // Reset
            List <int> tables = new List <int>();

            // Get the directory
            DirectoryInfo tableDirectory = RunTimeLoader.RunTimePath;

            // Check files
            for (int i = 0; i++ < CodePages.Length;)
            {
                try
                {
                    // Attach to file
                    FileInfo table = new FileInfo(Path.Combine(tableDirectory.FullName, string.Format("CodePage{0}.xht", i)));

                    // Load it
                    if (table.Exists)
                    {
                        // Process
                        LoadTable(i, HuffmanPairTable.Load(table.FullName));

                        // Remember
                        tables.Add(i);
                    }
                }
                catch
                {
                    // Ignore any error
                }
            }

            // Report
            return(tables.ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// Liest die <i>Huffman</i> Tabellen aus den Ressourcen.
        /// </summary>
        static TextDecoder()
        {
            // Create binary representation helper
            BinaryTables = new ushort[CodePages.Length][];

            // Attach to self
            Type me = typeof(TextDecoder);

            // Load all
            for (int i = CodePages.Length; i > 0; --i)
            {
                try
                {
                    // Attach to resource
                    using (Stream stream = me.Assembly.GetManifestResourceStream(string.Format("{0}.CodePage{1}.xht", me.Namespace, i)))
                    {
                        // Just load
                        LoadTable(i, HuffmanPairTable.Load(stream));
                    }
                }
                catch
                {
                    // Ignore any error - just do not decompress
                }
            }

            // Check for overloads
            DynamicLoadTables();
        }