Ejemplo n.º 1
0
        public static EPGMetaFile ReadByte(byte[] data)
        {
            for (int i = 0; i <= 3; i++)
            {
                if (!(data[i].Equals(m_head[i])))
                {
                    "Meta Data type dismatch!!".ErrorLognConsole();
                    return(null);
                }
            }
            int offset = 8;
            var tmp    = BitConverter.ToInt32(data, 4);

            tmp = tmp & 0xFFFFFF;
            int MetaLength = tmp >> 12;
            int LogoLength = tmp & 0xFFF;

            byte[] Meta = new byte[MetaLength];
            byte[] Logo = new byte[LogoLength];
            Array.Copy(data, offset, Meta, 0, MetaLength);
            offset += MetaLength;
            Array.Copy(data, offset, Logo, 0, LogoLength);
            offset += LogoLength;
            int ThumbLength = data.Length - offset;

            byte[] Thumb = new byte[ThumbLength];
            Array.Copy(data, offset, Thumb, 0, ThumbLength);
            var rep = new EPGMetaFile(Meta, Logo, Thumb);

            return(rep);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Read ".meta" file to <see cref="EPGMetaFile"/> object.
 /// </summary>
 /// <param name="path">full file path.</param>
 /// <returns></returns>
 public static EPGMetaFile ReadFile(string path)
 {
     if (File.Exists(path))
     {
         using (FileStream ssr = new FileStream(path, FileMode.Open, FileAccess.Read))
         {
             long   len = ssr.Length;
             byte[] tmp = new byte[len];
             ssr.Read(tmp, 0, (int)len);
             return(EPGMetaFile.ReadByte(tmp));
         }
     }
     else
     {
         "Unable to open or read meta file:\"{0}\"".ErrorLognConsole(path);
         return(null);
     }
 }