예제 #1
0
        public void CopyTo(DirectoryName path)
        {
            //refactor this out?
            if (!System.IO.Directory.Exists(path.GetPath()))
            {
                System.IO.Directory.CreateDirectory(path.GetPath());
            }

            // Copy all files.
            var files = GetFiles();

            foreach (var file in files)
            {
                var fileDestination = FileName.GetFileName(path, file.Name.GetName());
                file.CopyTo(fileDestination);
            }

            // Process subdirectories.
            var dirs = GetDirectories();

            foreach (var dir in dirs)
            {
                var destinationDir = DirectoryName.GetDirectoryName(path, dir.Name.GetName());
                dir.CopyTo(destinationDir);
            }
        }
예제 #2
0
        Directory GetRootDirectory(PathName name)
        {
            string root = Path.GetPathRoot(name.GetAbsolutePath());

            var di = new DirectoryInfo(root);

            return(new DotNetDirectory(DirectoryName.GetDirectoryName(di.FullName)));
        }
예제 #3
0
        public Directory GetDirectory(string path)
        {
            if (!Path.IsPathRooted(path))
            {
                path = Path.Combine(System.IO.Directory.GetCurrentDirectory(), path);
            }

            return(new DotNetDirectory(DirectoryName.GetDirectoryName(path)));
        }
예제 #4
0
        public void WorkWithTempDir(Action <Directory> tempAction)
        {
            string tempDir = Path.Combine(Path.GetTempPath(), "magnum.fs");

            tempDir = Path.Combine(tempDir, Guid.NewGuid().ToString());
            var d = new DotNetDirectory(DirectoryName.GetDirectoryName(tempDir));

            if (!d.Exists())
            {
                CreateDirectory(d);
            }
            try
            {
                tempAction(d);
            }
            finally
            {
                Delete(d);
            }
        }
예제 #5
0
 public static DirectoryName GetDirectoryName(DirectoryName directoryName, string child)
 {
     return(GetDirectoryName(directoryName.Name.Combine(child)));
 }
예제 #6
0
 public abstract DirectoryName Combine(DirectoryName child);
예제 #7
0
        public Directory GetDirectory(DirectoryName name)
        {
            Directory directory = ResolveDirectory(name.Name);

            return(directory);
        }
예제 #8
0
        public Directory GetChildDirectory(string name)
        {
            DirectoryName directoryName = Name.Combine(name);

            return(new DotNetDirectory(directoryName));
        }
 public void When_you_get_a_directory_that_DOESNT_exist()
 {
     _fileName = DirectoryName.GetDirectoryName(".\\doesntexist");
 }
예제 #10
0
 public DotNetDirectory(DirectoryName directoryName)
 {
     Name = directoryName;
 }
예제 #11
0
 public static DirectoryName GetDirectoryName(DirectoryName directoryName, string child)
 {
     return GetDirectoryName(directoryName.Name.Combine(child));
 }
예제 #12
0
		public abstract DirectoryName Combine(DirectoryName child);
예제 #13
0
        public Directory GetCurrentDirectory()
        {
            var directory = DirectoryName.GetDirectoryName(System.IO.Directory.GetCurrentDirectory());

            return(new DotNetDirectory(directory));
        }
예제 #14
0
 public void When_you_get_a_directory_that_exists()
 {
     _directoryName = FileName.GetFileName(Assembly.GetExecutingAssembly().Location).GetDirectoryName();
     _directoryInQuestion = Locator.GetDirectory(_directoryName);
 }
예제 #15
0
		public DotNetDirectory(DirectoryName directoryName)
		{
			Name = directoryName;
		}
예제 #16
0
 public IEnumerable <Directory> GetDirectories()
 {
     return(System.IO.Directory.GetDirectories(Name.GetPath())
            .Select(directory => (Directory) new DotNetDirectory(DirectoryName.GetDirectoryName(directory))));
 }
예제 #17
0
        public void CopyTo(DirectoryName path)
        {
            //refactor this out?
            if (!System.IO.Directory.Exists(path.GetPath()))
                System.IO.Directory.CreateDirectory(path.GetPath());

            // Copy all files.
            var files = GetFiles();

            foreach (var file in files)
            {
                var fileDestination = FileName.GetFileName(path, file.Name.GetName());
                file.CopyTo(fileDestination);
            }

            // Process subdirectories.
            var dirs = GetDirectories();
            foreach (var dir in dirs)
            {
                var destinationDir = DirectoryName.GetDirectoryName(path, dir.Name.GetName());
                dir.CopyTo(destinationDir);
            }
        }
예제 #18
0
		public Directory GetDirectory(DirectoryName name)
		{
			Directory directory = ResolveDirectory(name.Name);

			return directory;
		}