예제 #1
0
 public void RemoveChild(FsItem r)
 {
     Children.Remove(r);
     if (r.IsFolder())
     {
         Folders.Remove(r);
     }
     else
     {
         Files.Remove(r);
     }
     r.Parent = null;
 }
예제 #2
0
        private void CheckForNewOrChangedFiles(ref PollResults results, List <FsItem> items)
        {
            //Compare our tree with the FS items.
            foreach (FsItem item in items)
            {
                if ((!item.IsFolder() && Globals.Settings.PollFiles) || (item.IsFolder() && Globals.Settings.PollDirectories))
                {
                    if (FsItemState == FsItemState.Added)
                    {
                        //We are a new Dir
                        //Simply add everything to the new parent.
                        AddChildNode(item);
                        item.FsItemState = FsItemState.Added;
                        results.NumAdded++;
                    }
                    else
                    {
                        FsItem child = FindChild(item, false);
                        if (child != null)
                        {
                            //item is there.
                            //*We will ignore changes to folders (whcih in windows, shows only parent folder changed if contents changed).
                            //Instead we show the whole parent branch as modified if a file gets changed
                            if (child.IsFolder() == false)
                            {
                                if (item.LastModifyTime > child.LastModifyTime)
                                {
                                    child.FsItemState   = FsItemState.Changed;
                                    child.NewModifyTime = item.LastModifyTime;
                                    results.NumChanged++;
                                    child.WriteCount++;
                                }

                                CheckHotFile(child, ref results);
                            }
                        }
                        else
                        {
                            AddChildNode(item);
                            item.FsItemState = FsItemState.Added;
                            results.NumAdded++;
                        }
                    }
                }
            }
        }
예제 #3
0
        public FsItem AddChildNode(FsItem item)
        {
            System.Diagnostics.Debug.Assert(item.Parent == null);
            item.Parent = this;

            if (item.IsFolder())
            {
                Folders.Add(item);
            }
            else
            {
                Files.Add(item);
            }
            Children.Add(item);

            return(item);
        }