-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Windows
Milestone
Description
On Windows, a symlink to a directory is reported as a directory and a symlink at the same time. This confuses tar.FileInfoHeader, which reports the object as a directory, whereas on UNIX systems it would be reported as a symlink. I believe it makes much more sense to report a symlink.
What version of Go are you using (go version
)?
$ go version
go version go1.7.1 windows/amd64
What operating system and processor architecture are you using (go env
)?
$ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=x:\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
What did you do?
Run the following program:
package main
import (
"archive/tar"
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
func main() {
tempdir, err := ioutil.TempDir("", "")
if err != nil {
panic(err)
}
defer os.RemoveAll(tempdir)
os.Symlink(`c:\`, filepath.Join(tempdir, "directorysymlink"))
// os.Symlink("/", filepath.Join(tempdir, "directorysymlink"))
fi, err := os.Lstat(filepath.Join(tempdir, "directorysymlink"))
if err != nil {
panic(err)
}
hdr, err := tar.FileInfoHeader(fi, "directorysymlink")
if err != nil {
panic(err)
}
fmt.Printf("Typeflag: %c, Mode: 0x%x, Linkname: %q\n", hdr.Typeflag, hdr.Mode, hdr.Linkname)
}
What did you expect to see?
On Windows, this returns Typeflag: 5, Mode: 0x41ff, Linkname: ""
What did you see instead?
I'd expect to see Typeflag: 2, Mode: 0xa1ff, Linkname: "directorysymlink"
, as is reported on non-Windows systems.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Windows