Example #1
0
        internal void GetComputerShares(string computer)
        {
            // find the shares
            HostShareInfo[]             hostShareInfos    = GetHostShareInfo(computer);
            BlockingStaticTaskScheduler treeTaskScheduler = SnaffCon.GetTreeTaskScheduler();

            foreach (HostShareInfo hostShareInfo in hostShareInfos)
            {
                string shareName = GetShareName(hostShareInfo, computer);
                if (!String.IsNullOrWhiteSpace(shareName))
                {
                    bool matched = false;

                    // classify them
                    foreach (ClassifierRule classifier in MyOptions.ShareClassifiers)
                    {
                        ShareClassifier shareClassifier = new ShareClassifier(classifier);
                        if (shareClassifier.ClassifyShare(shareName))
                        {
                            matched = true;
                            break;
                        }
                    }
                    // by default all shares should go on to TreeWalker unless the classifier pulls them out.
                    // send them to TreeWalker
                    if (!matched)
                    {
                        if (IsShareReadable(shareName))
                        {
                            ShareResult shareResult = new ShareResult()
                            {
                                Listable  = true,
                                SharePath = shareName
                            };
                            Mq.ShareResult(shareResult);

                            Mq.Info("Creating a TreeWalker task for " + shareResult.SharePath);
                            treeTaskScheduler.New(() =>
                            {
                                try
                                {
                                    new TreeWalker(shareResult.SharePath);
                                }
                                catch (Exception e)
                                {
                                    Mq.Trace(e.ToString());
                                }
                            });
                        }
                    }
                }
            }
        }
Example #2
0
        public SnaffCon(Options options)
        {
            MyOptions = options;
            Mq        = BlockingMq.GetMq();

            int shareThreads = MyOptions.ShareThreads;
            int treeThreads  = MyOptions.TreeThreads;
            int fileThreads  = MyOptions.FileThreads;

            ShareTaskScheduler = new BlockingStaticTaskScheduler(shareThreads, MyOptions.MaxShareQueue);
            TreeTaskScheduler  = new BlockingStaticTaskScheduler(treeThreads, MyOptions.MaxTreeQueue);
            FileTaskScheduler  = new BlockingStaticTaskScheduler(fileThreads, MyOptions.MaxFileQueue);
        }
Example #3
0
        public TreeWalker(string shareRoot)
        {
            Mq = BlockingMq.GetMq();

            FileTaskScheduler = SnaffCon.GetFileTaskScheduler();

            if (shareRoot == null)
            {
                Mq.Trace("A null made it into TreeWalker. Wtf.");
                return;
            }

            Mq.Trace("About to start a TreeWalker on share " + shareRoot);
            WalkTree(shareRoot);
            Mq.Trace("Finished TreeWalking share " + shareRoot);
        }
Example #4
0
        public SnaffCon(Options options)
        {
            MyOptions = options;
            Mq        = BlockingMq.GetMq();

            int shareThreads = MyOptions.ShareThreads;
            int treeThreads  = MyOptions.TreeThreads;
            int fileThreads  = MyOptions.FileThreads;

            ShareTaskScheduler = new BlockingStaticTaskScheduler(shareThreads, MyOptions.MaxShareQueue);
            TreeTaskScheduler  = new BlockingStaticTaskScheduler(treeThreads, MyOptions.MaxTreeQueue);
            FileTaskScheduler  = new BlockingStaticTaskScheduler(fileThreads, MyOptions.MaxFileQueue);

            FileScanner = new FileScanner(MyOptions.InterestLevel);
            TreeWalker  = new TreeWalker();
            ShareFinder = new ShareFinder();
        }