Esempio n. 1
0
File: KfsScan.cs Progetto: tmbx/kwm
        /// <summary>
        /// Helper method for Sync().
        /// </summary>
        private void SyncRecursive(KfsLocalDirectory dir, KfsScanObject obj)
        {
            // We're synchronizing a directory.
            if (obj is KfsScanDirectory)
            {
                KfsScanDirectory objAsDir = (KfsScanDirectory)obj;
                KfsLocalDirectory subDir = null;

                // We're synchronizing the root directory.
                if (dir == null)
                {
                    subDir = m_share.LocalView.Root;
                }

                else
                {
                    // Make sure the subdirectory exists.
                    if (!dir.ContainsDirectory(obj.Name))
                    {
                        if (dir.Contains(obj.Name))
                            dir.GetObject(obj.Name).RemoveFromView();

                        new KfsLocalDirectory(m_share, dir, obj.Name);
                    }

                    subDir = dir.GetDirectory(obj.Name);
                }

                // Remove the stale children.
                SortedDictionary<String, KfsLocalObject> subDirChildTree =
                    new SortedDictionary<String, KfsLocalObject>(subDir.ChildTree);
                foreach (KfsLocalObject o in subDirChildTree.Values)
                {
                    if (!objAsDir.Contains(o.Name))
                    {
                        o.RemoveFromView();
                    }
                }

                // Synchronize the children.
                foreach (KfsScanObject o in objAsDir.ChildTree.Values)
                {
                    SyncRecursive(subDir, o);
                }
            }

            // We're synchronizing a file.
            else
            {
                if (!dir.ContainsFile(obj.Name))
                {
                    if (dir.Contains(obj.Name))
                        dir.GetObject(obj.Name).RemoveFromView();

                    new KfsLocalFile(m_share, dir, obj.Name);
                }

                // Request the local status of the file to be updated.
                KfsServerFile serverFile = dir.GetFile(obj.Name).GetServerCounterpart();
                if (serverFile != null) serverFile.RequestUpdate();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Helper method for NormalizeState().
 /// </summary>
 private void NormalizeLocalDirectory(KfsLocalDirectory d)
 {
     SortedDictionary<String, KfsLocalObject> newTree = new SortedDictionary<String, KfsLocalObject>(KfsPath.Comparer);
     foreach (KfsLocalObject o in d.ChildTree.Values)
     {
         newTree.Add(o.Name, o);
         KfsLocalDirectory od = o as KfsLocalDirectory;
         if (od != null) NormalizeLocalDirectory(od);
     }
     d.ChildTree = newTree;
 }
Esempio n. 3
0
 public KfsLocalDirectory(KfsShare S, KfsLocalDirectory P, String N)
     : base(S, P, N)
 {
 }
Esempio n. 4
0
 /// <summary>
 /// Helper method for GetPathArray().
 /// </summary>
 private void GetPathArrayRecursive(List<String> a, KfsLocalDirectory c, bool lf)
 {
     if (!lf) a.Add(c.RelativePath);
     foreach (KfsLocalObject o in c.ChildTree.Values)
     {
         if (o is KfsLocalDirectory)
         {
             GetPathArrayRecursive(a, o as KfsLocalDirectory, lf);
         }
         else
         {
             a.Add(o.RelativePath);
         }
     }
     if (lf) a.Add(c.RelativePath);
 }
Esempio n. 5
0
 /// <summary>
 /// This constructor creates the object and inserts it in the view.
 /// </summary>
 /// <param name="S">Share</param>
 /// <param name="P">Parent directory</param>
 /// <param name="N">Name</param>
 public KfsLocalObject(KfsShare S, KfsLocalDirectory P, String N)
 {
     Share = S;
     Parent = P;
     Name = N;
     AddToView();
 }