Skip to content

Commit 9c46a42

Browse files
committed
windows: expose reparse buffer types
These are needed for interacting with reparse buffers on Windows. Searching on github reveals a lot of repositories that have copied these types, so it would make sense to export them directly. This also copies a method on SymbolicLinkReparseBuffer from go/src/internal/syscall/windows/reparse_windows.go to ease interacting with symbolic links.
1 parent 543f21a commit 9c46a42

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

windows/types_windows.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ type TCPKeepalive struct {
18961896
Interval uint32
18971897
}
18981898

1899-
type symbolicLinkReparseBuffer struct {
1899+
type SymbolicLinkReparseBuffer struct {
19001900
SubstituteNameOffset uint16
19011901
SubstituteNameLength uint16
19021902
PrintNameOffset uint16
@@ -1905,15 +1905,28 @@ type symbolicLinkReparseBuffer struct {
19051905
PathBuffer [1]uint16
19061906
}
19071907

1908-
type mountPointReparseBuffer struct {
1908+
// Path returns path stored in rb.
1909+
func (rb *SymbolicLinkReparseBuffer) Path() string {
1910+
n1 := rb.SubstituteNameOffset / 2
1911+
n2 := (rb.SubstituteNameOffset + rb.SubstituteNameLength) / 2
1912+
return syscall.UTF16ToString((*[0xffff]uint16)(unsafe.Pointer(&rb.PathBuffer[0]))[n1:n2:n2])
1913+
}
1914+
1915+
type MountPointReparseBuffer struct {
19091916
SubstituteNameOffset uint16
19101917
SubstituteNameLength uint16
19111918
PrintNameOffset uint16
19121919
PrintNameLength uint16
19131920
PathBuffer [1]uint16
19141921
}
19151922

1916-
type reparseDataBuffer struct {
1923+
type ReparseDataBufferHeader struct {
1924+
ReparseTag uint32
1925+
ReparseDataLength uint16
1926+
Reserved uint16
1927+
}
1928+
1929+
type ReparseDataBuffer struct {
19171930
ReparseTag uint32
19181931
ReparseDataLength uint16
19191932
Reserved uint16
@@ -1974,6 +1987,7 @@ const (
19741987
IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
19751988
IO_REPARSE_TAG_SYMLINK = 0xA000000C
19761989
SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
1990+
SYMBOLIC_LINK_FLAG_RELATIVE = 1
19771991
)
19781992

19791993
const (

0 commit comments

Comments
 (0)