Example #1
0
        public List <Block> Partition()
        {
            List <Block> result = new List <Block>();

            using (FileStream fs = File.OpenRead(info.FullName))
            {
                using (StreamReader sr = new StreamReader(fs))
                {
                    String           content = sr.ReadToEnd();
                    RabinPrintfinger rabin   = new RabinPrintfinger();
                    int j = 0;
                    for (int i = 0; i < content.Length - windowSize; i++)
                    {
                        String window = content.Substring(i, windowSize);
                        if (rabin.PrintFinger(window) == 0)
                        {
                            Block b = new Block(this, content.Substring(j, i + windowSize - j));
                            b.percentage = b.content.Length / content.Length;
                            j            = i;
                            result.Add(b);
                            fileTemplate.Add(b.ToString());
                        }
                    }
                    Block lastb = new Block(this, content.Substring(j, content.Length - j));
                    lastb.percentage = lastb.content.Length / content.Length;
                    result.Add(lastb);
                    fileTemplate.Add(lastb.name);
                }
            }

            return(result);
        }
Example #2
0
        public List<Block> Partition()
        {
            List<Block> result = new List<Block>();
            using (FileStream fs = File.OpenRead(info.FullName))
            {
                using (StreamReader sr = new StreamReader(fs))
                {
                    String content = sr.ReadToEnd();
                    RabinPrintfinger rabin = new RabinPrintfinger();
                    int j = 0;
                    for (int i = 0; i < content.Length - windowSize; i++)
                    {
                        String window = content.Substring(i, windowSize);
                        if (rabin.PrintFinger(window) == 0)
                        {
                            Block b = new Block(this, content.Substring(j, i + windowSize - j));
                            b.percentage = b.content.Length / content.Length;
                            j = i;
                            result.Add(b);
                            fileTemplate.Add(b.ToString());
                        }
                    }
                    Block lastb = new Block(this, content.Substring(j, content.Length - j));
                    lastb.percentage = lastb.content.Length / content.Length;
                    result.Add(lastb);
                    fileTemplate.Add(lastb.name);
                }
            }

            return result;
        }