public override void SyncStructure(FsFolder destination, bool force) { var folders = Folders.ToList(); var destFolders = destination.Folders.ToList(); foreach (var subFolder in destFolders.Except(folders)) { destination.CombineFolder(subFolder.SubPath).Remove(); } foreach (var subFile in destination.Files.Except(Files)) { destination.CombineFile(subFile.SubPath).Remove(); } foreach (var folder in folders.Except(destFolders)) { destination.CombineFolder(folder.SubPath).Create(); } }
public void ShouldReflectIfExists() { var folder = _folder.CombineFolder(nameof(ShouldReflectIfExists)); folder.Create(); var file = folder.CombineFile("exists.txt"); var sut = file.ToString().ToPath(); Assert.That(sut.Exists, Is.False); file.Write("A"); Assert.That(sut.Exists, Is.True); }
public override void CopyToFolder(FsFolder destination) { var target = destination.CombineFolder(Name).Create(); foreach (var folder in Folders) { var subFolder = folder.Path.Substring(Path.Length); target.CombineFolder(subFolder).Create(); } foreach (var file in Files) { var subFile = file.Path.Substring(Path.Length); file.CopyToFolder(target.CombineFile(subFile).Parent); } }
public override void Copy(FsFolder destination) { destination.Create(); foreach (var subFolder in SearchFolders()) { var subpath = subFolder.Path.Substring(Path.Length); destination.CombineFolder(subpath).Create(); } foreach (var file in SearchFiles()) { var subFile = file.Path.Substring(Path.Length); file.Copy(destination.CombineFile(subFile)); } }
public void Setup() { _folder.Create(); _folder.CombineFile("Test_0_1.txt").Write("0_1"); _folder.CombineFile("Test_0_2.txt").Write("0_2"); var subfolder1 = _folder.CombineFolder("SubFolder_1"); subfolder1.Create(); subfolder1.CombineFile("Test_1_1.txt").Write("1_1"); subfolder1.CombineFile("Test_1_2.txt").Write("1_2"); var subfolder11 = subfolder1.CombineFolder("SubFolder_1_1"); subfolder11.Create(); subfolder11.CombineFile("Test_1_1_1.txt").Write("1_1_1"); subfolder11.CombineFile("Test_1_1_2.txt").Write("1_1_2"); var subfolder111 = subfolder11.CombineFolder("SubFolder_1_1_1"); subfolder111.Create(); subfolder111.CombineFile("Test_1_1_1_1.txt").Write("1_1_1_1"); subfolder111.CombineFile("Test_1_1_1_2.txt").Write("1_1_1_2"); var subfolder12 = subfolder1.CombineFolder("SubFolder_1_2"); subfolder12.Create(); subfolder12.CombineFile("Test_1_2_1.txt").Write("1_2_1"); subfolder12.CombineFile("Test_1_2_2.txt").Write("1_2_2"); var subfolder2 = _folder.CombineFolder("SubFolder_2"); subfolder2.Create(); subfolder2.CombineFile("Test_2_1.txt").Write("2_1"); subfolder2.CombineFile("Test_2_2.txt").Write("2_2"); var subfolder21 = subfolder2.CombineFolder("SubFolder_2_1"); subfolder21.Create(); subfolder21.CombineFile("Test_2_1_1.txt").Write("2_1_1"); subfolder21.CombineFile("Test_2_1_2.txt").Write("2_1_2"); var subfolder22 = subfolder2.CombineFolder("SubFolder_2_2"); subfolder22.Create(); subfolder22.CombineFile("Test_2_2_1.txt").Write("2_2_1"); subfolder22.CombineFile("Test_2_2_2.txt").Write("2_2_2"); }