Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: SameFile fails for paths like c:a.txt on windows #8490

Closed
alexbrainman opened this issue Aug 7, 2014 · 2 comments
Closed

os: SameFile fails for paths like c:a.txt on windows #8490

alexbrainman opened this issue Aug 7, 2014 · 2 comments

Comments

@alexbrainman
Copy link
Member

C:\go\root\src\pkg\os>hg id
f3bac1f13638+

C:\go\root\src\pkg\os>hg diff
diff -r f3bac1f13638 src/pkg/os/os_windows_test.go
--- a/src/pkg/os/os_windows_test.go     Thu Aug 07 10:25:50 2014 +1000
+++ b/src/pkg/os/os_windows_test.go     Thu Aug 07 15:06:21 2014 +1000
@@ -4,7 +4,9 @@
        "io/ioutil"
        "os"
        "path/filepath"
+       "runtime"
        "syscall"
+       "testing"
 )

 func init() {
@@ -25,3 +27,58 @@
                supportsSymlinks = false
        }
 }
+
+func TestSameWindowsFile(t *testing.T) {
+       temp, err := ioutil.TempDir("", "TestSameWindowsFile")
+       if err != nil {
+               t.Fatal(err)
+       }
+       defer os.RemoveAll(temp)
+
+       wd, err := os.Getwd()
+       if err != nil {
+               t.Fatal(err)
+       }
+       err = os.Chdir(temp)
+       if err != nil {
+               t.Fatal(err)
+       }
+       defer os.Chdir(wd)
+
+       f, err := os.Create("a")
+       if err != nil {
+               t.Fatal(err)
+       }
+       f.Close()
+
+       ia1, err := os.Stat("a")
+       if err != nil {
+               t.Fatal(err)
+       }
+
+       path, err := filepath.Abs("a")
+       if err != nil {
+               t.Fatal(err)
+       }
+       ia2, err := os.Stat(path)
+       if err != nil {
+               t.Fatal(err)
+       }
+       if !os.SameFile(ia1, ia2) {
+               t.Errorf("files should be same")
+       }
+
+       if runtime.GOOS == "windows" {
+               p := filepath.VolumeName(path) + filepath.Base(path)
+               if err != nil {
+                       t.Fatal(err)
+               }
+               ia3, err := os.Stat(p)
+               if err != nil {
+                       t.Fatal(err)
+               }
+               if !os.SameFile(ia1, ia3) {
+                       t.Errorf("files should be same")
+               }
+       }
+}

C:\go\root\src\pkg\os>go test -run=SameWindowsFile
--- FAIL: TestSameWindowsFile (0.00s)
        os_windows_test.go:81: files should be same
FAIL
exit status 1
FAIL    os      0.094s

Alex
@gopherbot
Copy link

Comment 1:

CL https://golang.org/cl/127740043 mentions this issue.

@alexbrainman
Copy link
Member Author

Comment 2:

This issue was closed by revision 2de65ca.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Fixes golang#8490.

LGTM=r, rsc
R=golang-codereviews, rsc, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/127740043
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
Fixes golang#8490.

LGTM=r, rsc
R=golang-codereviews, rsc, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/127740043
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants