Beispiel #1
0
 public void AddChild(GHFileSystemNode node)
 {
     if (!Children.ContainsKey(node.Name))
     {
         Children.Add(node.Name, node);
     }
 }
        public static GHFileSystem LoadFromCompressedString(string publicIp, string localIp, Queue <char> imageQueue, StringBuilder sb)
        {
            GHFileSystem fileSystem = new GHFileSystem()
            {
                PublicIp = publicIp, LocalIp = localIp
            };
            GHFileSystemNode activeNode = null;

            while (imageQueue.Count > 0)
            {
                sb.Clear();
                while (imageQueue.Peek() < 32768)
                {
                    sb.Append(GHTextConvertor.Utf14ToDoubleUtf7(imageQueue.Dequeue()));
                }

                if (imageQueue.Peek() == (char)Depth.Up)
                {
                    activeNode = activeNode.Parent;
                    imageQueue.Dequeue();
                    continue;
                }

                var tmp = new GHFileSystemNode(activeNode, sb.ToString())
                {
                    FileSystem = fileSystem
                };
                tmp.FileFlags = (FileFlag)imageQueue.Dequeue() - 32768;
                if (activeNode != null)
                {
                    activeNode.AddChild(tmp);
                    if (activeNode.IsHomeFolder && !fileSystem.Users.ContainsKey(tmp.Name))
                    {
                        fileSystem.Users.Add(tmp.Name, new GHFileSystemUser()
                        {
                            FileSystem = fileSystem, HomeFolder = tmp
                        });
                    }
                    else if (tmp.IsRootUserFolder)
                    {
                        fileSystem.Users.Add(tmp.Name, new GHFileSystemUser()
                        {
                            FileSystem = fileSystem, HomeFolder = tmp
                        });
                    }
                }

                if (imageQueue.Peek() == (char)Depth.Down)
                {
                    imageQueue.Dequeue();
                    activeNode = tmp;
                }
            }

            fileSystem.RootNode = activeNode;
            return(fileSystem);
        }
Beispiel #3
0
 public GHFileSystemNode(GHFileSystemNode parent, string name)
 {
     Name     = name;
     Parent   = parent ?? this;
     Children = new Dictionary <string, GHFileSystemNode>();
 }