/// <summary> /// Tries to create copy-on-write by calling <see cref="IFileUtilities.CloneFile(string, string, bool)"/>. /// </summary> /// <param name="source">Source of copy.</param> /// <param name="destination">Destination path.</param> /// <param name="followSymlink">Flag indicating whether to follow source symlink or not.</param> public static Possible <Unit> TryCreateCopyOnWrite(string source, string destination, bool followSymlink) { try { using (Counters?.StartStopwatch(StorageCounters.CopyOnWriteDuration)) { Counters?.IncrementCounter(StorageCounters.CopyOnWriteCount); s_fileUtilities.CloneFile(source, destination, followSymlink); Counters?.IncrementCounter(StorageCounters.SuccessfulCopyOnWriteCount); return(Unit.Void); } } catch (NativeWin32Exception ex) { return(NativeFailure.CreateFromException(ex)); } }