/// <summary> /// Gets the LazyCopy reparse data from the <paramref name="path"/> given. /// </summary> /// <param name="path">Path to the file to get the reparse data from.</param> /// <returns> /// Reparse data found or <see langword="null"/>, if it's not set. /// </returns> /// <exception cref="ArgumentNullException"><paramref name="path"/> is <see langword="null"/> or empty.</exception> /// <exception cref="IOException">File cannot be opened.</exception> /// <exception cref="InvalidOperationException">Reparse point data cannot be retrieved.</exception> public static LazyCopyFileData GetReparseData(string path) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } string normalizedPath = LongPathCommon.NormalizePath(path); LongPathFileInfo fileInfo = new LongPathFileInfo(normalizedPath); if (!fileInfo.Exists || !fileInfo.Attributes.HasFlag(FileAttributes.ReparsePoint)) { return(null); } try { LazyCopyReparseData data = ReparsePointHelper.GetReparsePointData <LazyCopyReparseData>(path, LazyCopyFileHelper.LazyCopyReparseTag, LazyCopyFileHelper.LazyCopyReparseGuid); bool useCustomHandler = data.UseCustomHandler > 0; return(new LazyCopyFileData { UseCustomHandler = useCustomHandler, FileSize = data.FileSize, RemotePath = useCustomHandler ? data.RemotePath : PathHelper.ChangeDeviceNameToDriveLetter(data.RemotePath) }); } catch (InvalidOperationException) { return(null); } }
protected override void ProcessPath(PscxPathInfo pscxPath) { var filePath = pscxPath.ProviderPath; if (ReparsePointHelper.IsReparsePoint(filePath)) { if (Raw) { WriteObject(ReparsePointHelper.GetReparsePointData(filePath)); } else { WriteObject(ReparsePointHelper.GetReparsePoint(filePath)); } } }