Exemple #1
0
 /// <summary>
 /// Creates a <see cref="TrackedFileContentInfo"/> with an associated change tracking subscription.
 /// </summary>
 public TrackedFileContentInfo(FileContentInfo fileContentInfo, FileChangeTrackingSubscription subscription, PathAtom fileName, ReparsePointInfo?reparsePointInfo = null)
 {
     Subscription     = subscription;
     FileContentInfo  = fileContentInfo;
     FileName         = fileName;
     ReparsePointInfo = reparsePointInfo ?? ReparsePointInfo.CreateNoneReparsePoint();
 }
Exemple #2
0
 /// <nodoc/>
 public FileMaterializationInfo GetFileMaterializationInfo(PathTable pathTable)
 {
     return new FileMaterializationInfo(
         new FileContentInfo(ContentHash.ToContentHash(), FileContentInfo.LengthAndExistence.Deserialize(Length)),
         !string.IsNullOrEmpty(FileName) ? PathAtom.Create(pathTable.StringTable, FileName) : PathAtom.Invalid,
         ReparsePointInfo.Create(ReparsePointType.ToReparsePointType(), ReparsePointTarget));
 }
Exemple #3
0
 /// <summary>
 /// Creates a <see cref="TrackedFileContentInfo"/> with an associated change tracking subscription.
 /// </summary>
 public TrackedFileContentInfo(FileContentInfo fileContentInfo, FileChangeTrackingSubscription subscription, PathAtom fileName, ReparsePointInfo?reparsePointInfo = null, bool isUndeclaredFileRewrite = false)
 {
     Subscription            = subscription;
     FileContentInfo         = fileContentInfo;
     FileName                = fileName;
     ReparsePointInfo        = reparsePointInfo ?? ReparsePointInfo.CreateNoneReparsePoint();
     IsUndeclaredFileRewrite = isUndeclaredFileRewrite;
 }
Exemple #4
0
        private static ReparsePointInfo InternalGetTarget(SafeFileHandle handle)
        {
            int    outBufferSize = Marshal.SizeOf(typeof(REPARSE_DATA_BUFFER));
            IntPtr outBuffer     = Marshal.AllocHGlobal(outBufferSize);

            try
            {
                int  bytesReturned;
                bool result = DeviceIoControl(handle.DangerousGetHandle(), FSCTL_GET_REPARSE_POINT,
                                              IntPtr.Zero, 0, outBuffer, outBufferSize, out bytesReturned, IntPtr.Zero);

                if (!result)
                {
                    int error = Marshal.GetLastWin32Error();
                    if (error == ERROR_NOT_A_REPARSE_POINT)
                    {
                        return(null);
                    }

                    ThrowLastWin32Error("Unable to get information about junction point.");
                }

                REPARSE_DATA_BUFFER reparseDataBuffer = (REPARSE_DATA_BUFFER)
                                                        Marshal.PtrToStructure(outBuffer, typeof(REPARSE_DATA_BUFFER));

                var res = new ReparsePointInfo
                {
                    ReparseTag = (ReparsePointTag)reparseDataBuffer.ReparseTag,
                    IsJunction = reparseDataBuffer.ReparseTag == IO_REPARSE_TAG_MOUNT_POINT,
                };

                if (!res.IsJunction)
                {
                    return(res);
                }

                res.SubstituteName = Encoding.Unicode.GetString(reparseDataBuffer.PathBuffer,
                                                                reparseDataBuffer.SubstituteNameOffset, reparseDataBuffer.SubstituteNameLength);
                res.PrintName = Encoding.Unicode.GetString(reparseDataBuffer.PathBuffer,
                                                           reparseDataBuffer.PrintNameOffset, reparseDataBuffer.PrintNameLength);

                return(res);
            }
            finally
            {
                Marshal.FreeHGlobal(outBuffer);
            }
        }