예제 #1
0
        public int Compare(ContentInfo x, ContentInfo y)
        {
            // are x and y valid?
            int i;

            if ((i = Compare(x == null, y == null)) != -2)
            {
                return(i);
            }
            if ((i = Compare(x.ContainsKey(ID), y.ContainsKey(ID))) != -2)
            {
                if (i == 0)
                {
                    return(string.Compare(x[ID], y[ID]));
                }
                else
                {
                    return(i);
                }
            }
            if ((i = Compare(x.ContainsKey(TTH), y.ContainsKey(TTH))) != -2)
            {
                if (i == 0)
                {
                    return(string.Compare(x[TTH], y[TTH]));
                }
                else
                {
                    return(i);
                }
            }
            if ((i = Compare(x.ContainsKey(VIRTUAL), y.ContainsKey(VIRTUAL))) != -2)
            {
                if (i == 0)
                {
                    return(string.Compare(x[VIRTUAL], y[VIRTUAL]));
                }
                else
                {
                    return(i);
                }
            }
            if ((i = x.LastModified.CompareTo(y.LastModified)) != 0)
            {
                return(i);
            }
            if ((i = x.Size.CompareTo(y.Size)) != 0)
            {
                return(i);
            }
            // We dont know how to compare them anymore so make them equal :)
            return(0);
        }
예제 #2
0
        public void Generate(FlowLib.Containers.ContentInfo info)
        {
            if (info.ContainsKey(ContentInfo.STORAGEPATH))
            {
                TthThreaded tth = new TthThreaded(info.Get(ContentInfo.STORAGEPATH));
                tth.ThreadPriority = priority;
                tth.ThreadCount    = count;
                byte[] bytes = tth.GetTTH_Value();
                info.Set(ContentInfo.TTH, Base32.Encode(bytes));
                //byte[][][] tree = tth.TTH;
                //if (tree != null && tree.Length > 0)
                //{
                //    int startIndex = 0;
                //    //if (tree.Length >= 8)
                //    //    startIndex = 7;
                //    long length = 0;
                //    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                //    for (int i = 0; i < tree[startIndex].Length; i++)
                //    {
                //        // Ignore the rest if more then 65KiB has been writed
                //        //if (length > 66560)
                //        //    break;
                //        length += tree[startIndex][i].Length;
                //        ms.Write(tree[startIndex][i], 0, tree[startIndex][i].Length);
                //    }

                //    info.Set(ContentInfo.TTHL, Base32.Encode(ms.ToArray()));
                //}
            }
        }