Parse() static private method

static private Parse ( Stream d ) : IBEncodeValue
d Stream
return IBEncodeValue
Exemplo n.º 1
0
 public void Parse(Stream s)
 {
     for (byte i = (byte)s.ReadByte(); i != 0x65; i = (byte)s.ReadByte())
     {
         BEncodeValue item = BEncode.Parse(s, i);
         this.values.Add(item);
     }
 }
Exemplo n.º 2
0
        public void Parse(Stream s)
        {
            byte current = (byte)s.ReadByte();

            while ((char)current != 'e')
            {
                IBEncodeValue value = BEncode.Parse(s, current);
                values.Add(value);
                current = (byte)s.ReadByte();
            }
        }
Exemplo n.º 3
0
        internal bool OpenTorrent(string localFilename)
        {
            data = null; // clear any old data
            bool hasOpened = false;

            localTorrentFile = localFilename;
            data             = new ValueDictionary();
            FileStream   fs = null;
            BinaryReader r  = null;

            try
            {
                fs = File.OpenRead(localFilename);
                r  = new BinaryReader(fs);

                // Parse the BEncode .torrent file
                data = (ValueDictionary)BEncode.Parse(r.BaseStream);

                // Check the torrent for its form, initialize this object
                LoadTorrent();

                hasOpened = true;
                r.Close();
                fs.Close();
            }
            catch (IOException)
            {
                hasOpened = false;
            }
            finally
            {
                if (r != null)
                {
                    r.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
            }

            return(hasOpened);
        }
Exemplo n.º 4
0
 public void Parse(Stream s)
 {
     for (byte num1 = (byte)s.ReadByte(); num1 != 0x65; num1 = (byte)s.ReadByte())
     {
         if (!char.IsNumber((char)num1))
         {
             throw new TorrentException("Key expected to be a string.");
         }
         ValueString text1 = new ValueString();
         text1.Parse(s, num1);
         BEncodeValue value1 = BEncode.Parse(s);
         if (dict.ContainsKey(text1.String))
         {
             dict[text1.String] = value1;
         }
         else
         {
             dict.Add(text1.String, value1);
         }
     }
 }
Exemplo n.º 5
0
        public bool OpenTorrent(string localFilename)
        {
            this.data = null;
            bool flag = false;

            this.localTorrentFile = localFilename;
            this.data             = new ValueDictionary();
            FileStream   input  = null;
            BinaryReader reader = null;

            try
            {
                input     = File.OpenRead(localFilename);
                reader    = new BinaryReader(input);
                this.data = (ValueDictionary)BEncode.Parse(reader.BaseStream);
                this.LoadTorrent();
                flag = true;
                reader.Close();
                input.Close();
            }
            catch (IOException)
            {
                flag = false;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (input != null)
                {
                    input.Close();
                }
            }
            return(flag);
        }
 public void Parse(Stream s)
 {
     for (byte i = (byte)s.ReadByte(); i != 0x65; i = (byte)s.ReadByte())
     {
         if (!char.IsNumber((char)i))
         {
             return;
         }
         ValueString str = new ValueString();
         str.Parse(s, i);
         BEncodeValue value2 = BEncode.Parse(s);
         if (str.String != null)
         {
             if (this.dict.ContainsKey(str.String))
             {
                 this.dict[str.String] = value2;
             }
             else
             {
                 this.dict.Add(str.String, value2);
             }
         }
     }
 }