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); } }
Directory GetRootDirectory(PathName name) { string root = Path.GetPathRoot(name.GetAbsolutePath()); var di = new DirectoryInfo(root); return(new DotNetDirectory(DirectoryName.GetDirectoryName(di.FullName))); }
public Directory GetDirectory(string path) { if (!Path.IsPathRooted(path)) { path = Path.Combine(System.IO.Directory.GetCurrentDirectory(), path); } return(new DotNetDirectory(DirectoryName.GetDirectoryName(path))); }
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); } }
public static DirectoryName GetDirectoryName(DirectoryName directoryName, string child) { return(GetDirectoryName(directoryName.Name.Combine(child))); }
public abstract DirectoryName Combine(DirectoryName child);
public Directory GetDirectory(DirectoryName name) { Directory directory = ResolveDirectory(name.Name); return(directory); }
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"); }
public DotNetDirectory(DirectoryName directoryName) { Name = directoryName; }
public static DirectoryName GetDirectoryName(DirectoryName directoryName, string child) { return GetDirectoryName(directoryName.Name.Combine(child)); }
public Directory GetCurrentDirectory() { var directory = DirectoryName.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()); return(new DotNetDirectory(directory)); }
public void When_you_get_a_directory_that_exists() { _directoryName = FileName.GetFileName(Assembly.GetExecutingAssembly().Location).GetDirectoryName(); _directoryInQuestion = Locator.GetDirectory(_directoryName); }
public IEnumerable <Directory> GetDirectories() { return(System.IO.Directory.GetDirectories(Name.GetPath()) .Select(directory => (Directory) new DotNetDirectory(DirectoryName.GetDirectoryName(directory)))); }
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); } }
public Directory GetDirectory(DirectoryName name) { Directory directory = ResolveDirectory(name.Name); return directory; }