static void BackupEntry(IAbsoluteDirectoryPath workingDirectory, IAbsoluteDirectoryPath backupPath, IAbsoluteFilePath entry) { var backupDestination = entry.GetRelativePathFrom(workingDirectory).GetAbsolutePathFrom(backupPath); DeleteDestinationIfDirectory(backupDestination); DeleteParentFilesIfExists(backupDestination, backupPath); backupDestination.MakeSureParentPathExists(); entry.Move(backupDestination); }
public void Test_GetRelativePathWithError3() { IAbsoluteFilePath filePathTo = @"C:\Dir1\File.txt".ToAbsoluteFilePath(); IAbsoluteDirectoryPath absoluteDirectoryPathFrom = @"D:\Dir1".ToAbsoluteDirectoryPath(); Assert.IsFalse(filePathTo.CanGetRelativePathFrom(absoluteDirectoryPathFrom)); string failureReason; Assert.IsFalse(filePathTo.CanGetRelativePathFrom(absoluteDirectoryPathFrom, out failureReason)); Assert.IsTrue(failureReason == @"Cannot compute relative path from 2 paths that are not on the same volume PathFrom = ""D:\Dir1"" PathTo = ""C:\Dir1\File.txt"""); filePathTo.GetRelativePathFrom(absoluteDirectoryPathFrom); }
public Data(IAbsoluteFilePath realFile, IAbsoluteDirectoryPath basePath) { FileName = realFile.FileName; RealFileLocation = realFile.GetRelativePathFrom(basePath); RpfPlacement = RealFileLocation.ParentDirectoryPath; }