Skip to content

Commit

Permalink
use os.SameFile instead of syscall package (#15)
Browse files Browse the repository at this point in the history
This should work on Windows and other OS. Behavior should
be the same on Linux.
  • Loading branch information
smola authored and mcuadros committed Aug 1, 2017
1 parent e2bcde8 commit b811f53
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions cmd/siva/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"os"
"path/filepath"
"syscall"

"gopkg.in/src-d/go-siva.v1"
)
Expand Down Expand Up @@ -106,7 +105,7 @@ func (c *CmdPack) packDir(fullpath string) error {
}

func (c *CmdPack) packFile(fullpath string, fi os.FileInfo) error {
if c.sameFile(c.fi, fi) {
if os.SameFile(c.fi, fi) {
fmt.Fprintf(os.Stderr,
"skipping %q, cannot archive the target file\n", fullpath)
return nil
Expand All @@ -120,11 +119,6 @@ func (c *CmdPack) packFile(fullpath string, fi os.FileInfo) error {
return c.writeFile(fullpath, fi)
}

func (c *CmdPack) sameFile(a, b os.FileInfo) bool {
// TODO: only works in linux
return a.Sys().(*syscall.Stat_t).Ino == b.Sys().(*syscall.Stat_t).Ino
}

func (c *CmdPack) writeFileHeader(fullpath string, fi os.FileInfo) error {
h := &siva.Header{
Name: cleanPath(fullpath),
Expand Down

0 comments on commit b811f53

Please sign in to comment.