Esempio n. 1
0
 public FileListNode(
     FileListNode parent,
     string name,
     bool isDirectory,
     long length,
     DateTime creationTimeUtc,
     DateTime lastWriteTimeUtc)
 {
     Id               = Guid.NewGuid();
     Parent           = parent;
     Name             = name;
     IsDirectory      = isDirectory;
     Length           = length;
     CreationTimeUtc  = creationTimeUtc;
     LastWriteTimeUtc = lastWriteTimeUtc;
 }
Esempio n. 2
0
        private static void RecursiveReadStream(System.IO.BinaryReader br, FileListNode parent)
        {
            var count = br.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var name             = br.ReadString();
                var isDirectory      = br.ReadBoolean();
                var length           = br.ReadInt64();
                var creationTimeUtc  = DateTime.SpecifyKind(new DateTime(br.ReadInt64()), DateTimeKind.Utc);
                var lastWriteTimeUtc = DateTime.SpecifyKind(new DateTime(br.ReadInt64()), DateTimeKind.Utc);

                var node = new FileListNode(parent, name, isDirectory, length, creationTimeUtc, lastWriteTimeUtc);
                parent.AddChild(node);

                if (node.IsDirectory)
                {
                    RecursiveReadStream(br, node);
                }
            }
        }
Esempio n. 3
0
        // static

        private static void RecursiveReadFolder(FileListNode parent, string path)
        {
            foreach (var folder in System.IO.Directory.GetDirectories(path))
            {
                var node = new FileListNode(parent, System.IO.Path.GetFileName(folder), true, 0, new DateTime(0), new DateTime(0));
                parent.AddChild(node);
                RecursiveReadFolder(node, folder);
            }

            foreach (var filename in System.IO.Directory.GetFiles(path))
            {
                var fi = new System.IO.FileInfo(filename);

                parent.AddChild(new FileListNode(
                                    parent,
                                    System.IO.Path.GetFileName(filename),
                                    false,
                                    fi.Length,
                                    fi.CreationTimeUtc,
                                    fi.LastWriteTimeUtc));
            }
        }
Esempio n. 4
0
            public void AddChild(FileListNode node)
            {
                if (node.IsDirectory)
                {
                    ++SubfolderCount;
                }
                else
                {
                    ++FileCount;
                }

                if (FirstChild == null)
                {
                    FirstChild = node;
                    LastChild  = node;
                    return;
                }

                LastChild.Next = node;
                node.Previous  = LastChild;
                LastChild      = node;
            }
Esempio n. 5
0
        public FileListNode Pop()
        {
            FileListNode ret = new FileListNode(RakNetPINVOKE.RakNetListFileListNode_Pop(swigCPtr), false);

            return(ret);
        }
Esempio n. 6
0
        public FileListNode Get(uint position)
        {
            FileListNode ret = new FileListNode(RakNetPINVOKE.RakNetListFileListNode_Get(swigCPtr, position), false);

            return(ret);
        }
Esempio n. 7
0
 public void Replace(FileListNode input, FileListNode filler, uint position, string file, uint line)
 {
     RakNetPINVOKE.RakNetListFileListNode_Replace__SWIG_0(swigCPtr, FileListNode.getCPtr(input), FileListNode.getCPtr(filler), position, file, line);
     if (RakNetPINVOKE.SWIGPendingException.Pending)
     {
         throw RakNetPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 8
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FileListNode obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Esempio n. 9
0
 public void Replace(FileListNode input)
 {
     RakNetPINVOKE.CSharp_RakNet_RakNetListFileListNode_Replace__SWIG_1(swigCPtr, FileListNode.getCPtr(input));
     if (RakNetPINVOKE.SWIGPendingException.Pending)
     {
         throw RakNetPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 10
0
 public void Insert(FileListNode input, string file, uint line)
 {
     RakNetPINVOKE.CSharp_RakNet_RakNetListFileListNode_Insert__SWIG_1(swigCPtr, FileListNode.getCPtr(input), file, line);
     if (RakNetPINVOKE.SWIGPendingException.Pending)
     {
         throw RakNetPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Esempio n. 11
0
        private void RecursiveCompareTo(List <FileListDifference> differences, FileListNode left, FileListNode right)
        {
            // check to make sure we're not comparing two objects twice
            var check = new HashSet <Guid>();

            for (var node = left.FirstChild; node != null; node = node.Next)
            {
                check.Clear();

                var find = right.FindChild(node.Name);
                if (find != null)
                {
                    check.Add(find.Id);
                    if (node.IsDirectory)
                    {
                        RecursiveCompareTo(differences, node, find);
                    }
                    else if (!CompareDifferences(node, find, out FileListDifference diff))
                    {
                        differences.Add(diff);
                    }
                }
                else
                {
                    differences.Add(new FileListDifference()
                    {
                        Difference = FileListDifferences.RightMissing,
                        Left       = node
                    });
                    continue;
                }
            }

            for (var node = right.FirstChild; node != null; node = node.Next)
            {
                if (check.Contains(node.Id))
                {
                    continue;
                }

                var find = left.FindChild(node.Name);
                if (find != null)
                {
                    if (node.IsDirectory)
                    {
                        RecursiveCompareTo(differences, find, node);
                    }
                    else if (!CompareDifferences(find, node, out FileListDifference diff))
                    {
                        differences.Add(diff);
                    }
                }
                else
                {
                    differences.Add(new FileListDifference()
                    {
                        Difference = FileListDifferences.LeftMissing,
                        Right      = node
                    });
                    continue;
                }
            }
        }