CSL.BEncoding.decode_bytes C# (CSharp) Method

decode_bytes() private static method

private static decode_bytes ( byte x, int &f ) : byte[]
x byte
f int
return byte[]
        private static byte[] decode_bytes(byte[] x, ref int f)
        {
            string s = "";
            while (x[f] != ':')
            {
                s += (char)x[f];
                f++;
            }
            f++;

            Regex r = new Regex("^(0|[1-9][0-9]*)$", RegexOptions.Compiled);

            //if (!r.IsMatch(s))
                //throw new BitTorrentException("Integer value is invalid");

            int l = int.Parse(s);
            if (l > 0)
            {
                byte[] rv = new byte[l];
                Buffer.BlockCopy(x, f, rv, 0, l);
                f += l;
                return rv;
            }
            return null;
        }