public NPath Move(NPath dest) { ThrowIfRelative(); if (dest.IsRelative) { return(Move(Parent.Combine(dest))); } if (dest.DirectoryExists()) { return(Move(dest.Combine(FileName))); } if (FileExists()) { dest.EnsureParentDirectoryExists(); File.Move(ToString(), dest.ToString()); return(dest); } if (DirectoryExists()) { Directory.Move(ToString(), dest.ToString()); return(dest); } throw new ArgumentException("Move() called on a path that doesn't exist: " + ToString()); }
public NPath Copy(NPath dest, Func <NPath, bool> fileFilter) { ThrowIfRelative(); if (dest.IsRelative) { dest = Parent.Combine(dest); } if (dest.DirectoryExists()) { return(CopyWithDeterminedDestination(dest.Combine(FileName), fileFilter)); } return(CopyWithDeterminedDestination(dest, fileFilter)); }
public NPath Copy(NPath dest, Func <NPath, bool> fileFilter) { ThrowIfRelative(); if (dest.IsRelative) { dest = Parent().Combine(dest); } if (dest.DirectoryExists()) { return(Copy(dest.Combine(FileName), fileFilter)); } if (FileExists()) { if (!fileFilter(dest)) { return(null); } dest.EnsureParentDirectoryExists(); File.Copy(ToString(), dest.ToString(), true); return(dest); } if (DirectoryExists()) { dest.EnsureDirectoryExists(); foreach (var thing in Contents()) { thing.Copy(dest.Combine(thing.RelativeTo(this)), fileFilter); } return(dest); } throw new ArgumentException("Copy() called on path that doesnt exist: " + ToString()); }
public NPath Move(NPath dest) { ThrowIfRelative(); if (dest.IsRelative) return Move(Parent.Combine(dest)); if (dest.DirectoryExists()) return Move(dest.Combine(FileName)); if (FileExists()) { dest.EnsureParentDirectoryExists(); File.Move(ToString(), dest.ToString()); return dest; } if (DirectoryExists()) { Directory.Move(ToString(), dest.ToString()); return dest; } throw new ArgumentException("Move() called on a path that doesn't exist: " + ToString()); }
public NPath Copy(NPath dest, Func<NPath, bool> fileFilter) { ThrowIfRelative(); if (dest.IsRelative) dest = Parent.Combine(dest); if (dest.DirectoryExists()) return CopyWithDeterminedDestination(dest.Combine(FileName), fileFilter); return CopyWithDeterminedDestination (dest, fileFilter); }