mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
Fix tarinator for windows
This commit is contained in:
parent
1ced0aa532
commit
f689ca3909
5 changed files with 15 additions and 6 deletions
4
Gopkg.lock
generated
4
Gopkg.lock
generated
|
@ -52,8 +52,8 @@
|
|||
[[projects]]
|
||||
name = "github.com/schollz/tarinator-go"
|
||||
packages = ["."]
|
||||
revision = "835680f17d252bd7a6047e670079f35e5626dc1e"
|
||||
version = "v0.1.0"
|
||||
revision = "a8626a55d48dbb55141e51226eefa15c157a65a8"
|
||||
version = "v0.3.3"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sirupsen/logrus"
|
||||
|
|
|
@ -253,7 +253,7 @@ func (c *Connection) Run() error {
|
|||
|
||||
}
|
||||
if c.Local {
|
||||
fmt.Fprintf(os.Stderr, "Receive with: croc --code 8-local --server %s --yes\n", GetLocalIP())
|
||||
fmt.Fprintf(os.Stderr, "Receive with: croc --code %s --server %s --yes\n", c.Code, GetLocalIP())
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "Code is: %s\n", c.Code)
|
||||
}
|
||||
|
|
13
vendor/github.com/schollz/tarinator-go/tarinator.go
generated
vendored
13
vendor/github.com/schollz/tarinator-go/tarinator.go
generated
vendored
|
@ -39,6 +39,13 @@ func Tarinate(paths []string, tarPath string) error {
|
|||
}
|
||||
|
||||
func tarwalk(source, target string, tw *tar.Writer) error {
|
||||
source = filepath.ToSlash(source)
|
||||
if len(source) > 0 {
|
||||
if source[0:2] == "./" {
|
||||
source = source[2:]
|
||||
}
|
||||
}
|
||||
|
||||
info, err := os.Stat(source)
|
||||
if err != nil {
|
||||
return nil
|
||||
|
@ -46,7 +53,8 @@ func tarwalk(source, target string, tw *tar.Writer) error {
|
|||
|
||||
var baseDir string
|
||||
if info.IsDir() {
|
||||
baseDir = filepath.Base(source)
|
||||
baseDir = filepath.ToSlash(filepath.Base(source))
|
||||
|
||||
}
|
||||
|
||||
return filepath.Walk(source,
|
||||
|
@ -59,6 +67,7 @@ func tarwalk(source, target string, tw *tar.Writer) error {
|
|||
return err
|
||||
}
|
||||
|
||||
path = filepath.ToSlash(path)
|
||||
if baseDir != "" {
|
||||
header.Name = filepath.ToSlash(filepath.Join(baseDir, strings.TrimPrefix(path, source)))
|
||||
}
|
||||
|
@ -104,7 +113,7 @@ func UnTarinate(extractPath, sourcefile string) error {
|
|||
}
|
||||
|
||||
tarBallReader := tar.NewReader(fileReader)
|
||||
|
||||
extractPath = filepath.FromSlash(extractPath)
|
||||
for {
|
||||
header, err := tarBallReader.Next()
|
||||
if err != nil {
|
||||
|
|
2
vendor/github.com/schollz/tarinator-go/tarinator_test.go
generated
vendored
2
vendor/github.com/schollz/tarinator-go/tarinator_test.go
generated
vendored
|
@ -9,7 +9,7 @@ import (
|
|||
func TestArchive(t *testing.T) {
|
||||
paths := []string{
|
||||
"somescript.sh",
|
||||
"test_files/",
|
||||
"./test_files/",
|
||||
}
|
||||
|
||||
err := Tarinate(paths, "output_test.tar.gz")
|
||||
|
|
0
vendor/github.com/schollz/tarinator-go/test_files/.dotfile
generated
vendored
Normal file
0
vendor/github.com/schollz/tarinator-go/test_files/.dotfile
generated
vendored
Normal file
Loading…
Add table
Add a link
Reference in a new issue