Exemplo n.º 1
0
 public static AbstractTag ReadFromGzippedFile(String filename)
 {
     using (FileStream input = File.OpenRead(filename))
     {
         using (GZipStream gzipStream = new GZipStream(input, CompressionMode.Decompress))
         {
             return(AbstractTag.Read(gzipStream));
         }
     }
 }
Exemplo n.º 2
0
        public static AbstractTag ReadFromFile(String filename)
        {
            AbstractTag tag = null;

            //Check if gzipped stream
            try
            {
                using (FileStream input = File.OpenRead(filename))
                {
                    using (GZipStream gzipStream = new GZipStream(input, CompressionMode.Decompress))
                    {
                        tag = AbstractTag.Read(gzipStream);
                    }
                }
            }
            catch (Exception)
            {
                tag = null;
            }

            if (tag != null)
            {
                return(tag);
            }

            //Try Deflate stream
            try
            {
                using (FileStream input = File.OpenRead(filename))
                {
                    using (DeflateStream deflateStream = new DeflateStream(input, CompressionMode.Decompress))
                    {
                        tag = AbstractTag.Read(deflateStream);
                    }
                }
            }
            catch (Exception)
            {
                tag = null;
            }

            if (tag != null)
            {
                return(tag);
            }

            //Assume uncompressed stream
            using (FileStream input = File.OpenRead(filename))
            {
                tag = AbstractTag.Read(input);
            }

            return(tag);
        }
Exemplo n.º 3
0
        internal static Dictionary <String, AbstractTag> ReadDictionary(Stream input)
        {
            Dictionary <String, AbstractTag> dict = new Dictionary <String, AbstractTag>();
            AbstractTag tag = AbstractTag.Read(input);

            while (tag.Type != TagType.End)
            {
                dict[tag.Name] = tag;
                tag            = AbstractTag.Read(input);
            }

            return(dict);
        }