コード例 #1
0
        public void Write(ref ReparseDataBuffer buffer)
        {
            // set simple fields
            buffer.ReparseTag = ReparseTag;
            buffer.Reserved = 0;

            StringBuilder sb = new StringBuilder();
            sb.Append(SubstituteName);
            sb.Append('\0');
            sb.Append(PrintName);
            sb.Append('\0');

            // set subname
            buffer.SubstituteNameOffset = 0;
            buffer.SubstituteNameLength = (ushort)(SubstituteName != null ? SubstituteName.Length * sizeof(char) : 0);

            // set printname
            buffer.PrintNameOffset = (ushort)(buffer.SubstituteNameLength + 2);
            buffer.PrintNameLength = (ushort)(PrintName != null ? PrintName.Length * sizeof(char) : 0);

            // set length
            buffer.ReparseDataLength = (ushort)(sb.Length * sizeof(char) + 8);

            buffer.PathBuffer = sb.ToString();
        }
コード例 #2
0
 public static bool GetReparseInformation(this FileSystemInfo dir, out ReparseDataBuffer buffer)
 {
     using (SafeFileHandle hFile = dir.GetHandle())
     {
         using (HG<ReparseDataBuffer> hg = new HG<ReparseDataBuffer>())
         {
             int bytesReturned = 0;
             bool rc = Kernel32.DeviceIoControl(
                 hFile,
                 EIOControlCode.FsctlGetReparsePoint,
                 IntPtr.Zero,
                 0,
                 hg.Pointer,
                 hg.SizeOf,
                 ref bytesReturned,
                 IntPtr.Zero);
             buffer = hg.Structure;
             return rc;
         }
     }
 }
コード例 #3
0
 public static bool SetReparseInformation(this FileSystemInfo dir, ReparseDataBuffer buffer)
 {
     using (SafeFileHandle hFile = dir.GetHandle())
     {
         using (HG<ReparseDataBuffer> hg = new HG<ReparseDataBuffer>(buffer))
         {
             int bytesReturned = 0;
             bool rc = Kernel32.DeviceIoControl(
                 hFile,
                 EIOControlCode.FsctlSetReparsePoint,
                 hg.Pointer,
                 (int)(buffer.ReparseDataLength + Constants.REPARSE_MOUNTPOINT_HEADER_SIZE),
                 IntPtr.Zero,
                 0,
                 ref bytesReturned,
                 IntPtr.Zero);
             return rc;
         }
     }
 }
コード例 #4
0
 public void Read(ref ReparseDataBuffer buffer)
 {
     ReparseTag = buffer.ReparseTag;
     SubstituteName = buffer.PathBuffer.Substring(buffer.SubstituteNameOffset, buffer.SubstituteNameLength / sizeof(char));
     PrintName = buffer.PathBuffer.Substring(buffer.PrintNameOffset, buffer.PrintNameLength / sizeof(char));
 }
コード例 #5
0
 public ReparseDataBuffer Build()
 {
     ReparseDataBuffer buffer = new ReparseDataBuffer();
     Write(ref buffer);
     return buffer;
 }