Exemplo n.º 1
0
        public static Unit writeTree(IRoseTree <string, Move> tree)
        {
            void copy(Move m)
            {
                Directory.CreateDirectory(m.Destination.DirectoryName);
                m.Source.CopyTo(m.Destination.FullName);
                Console.WriteLine($"Copied to {m.Destination.FullName}");
            }

            bool compareFiles(Move m)
            {
                var sourceStream      = File.ReadAllBytes(m.Source.FullName);
                var destinationStream = File.ReadAllBytes(m.Destination.FullName);

                return(sourceStream == destinationStream);
            }

            Unit move(Move m)
            {
                copy(m);
                if (compareFiles(m))
                {
                    m.Source.Delete();
                }
                return(new Unit());
            }

            tree.Iter(move);
            return(Unit());
        }