mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 21:30:16 +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]]
|
[[projects]]
|
||||||
name = "github.com/schollz/tarinator-go"
|
name = "github.com/schollz/tarinator-go"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "835680f17d252bd7a6047e670079f35e5626dc1e"
|
revision = "a8626a55d48dbb55141e51226eefa15c157a65a8"
|
||||||
version = "v0.1.0"
|
version = "v0.3.3"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/sirupsen/logrus"
|
name = "github.com/sirupsen/logrus"
|
||||||
|
|
|
@ -253,7 +253,7 @@ func (c *Connection) Run() error {
|
||||||
|
|
||||||
}
|
}
|
||||||
if c.Local {
|
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 {
|
} else {
|
||||||
fmt.Fprintf(os.Stderr, "Code is: %s\n", c.Code)
|
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 {
|
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)
|
info, err := os.Stat(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -46,7 +53,8 @@ func tarwalk(source, target string, tw *tar.Writer) error {
|
||||||
|
|
||||||
var baseDir string
|
var baseDir string
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
baseDir = filepath.Base(source)
|
baseDir = filepath.ToSlash(filepath.Base(source))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return filepath.Walk(source,
|
return filepath.Walk(source,
|
||||||
|
@ -59,6 +67,7 @@ func tarwalk(source, target string, tw *tar.Writer) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = filepath.ToSlash(path)
|
||||||
if baseDir != "" {
|
if baseDir != "" {
|
||||||
header.Name = filepath.ToSlash(filepath.Join(baseDir, strings.TrimPrefix(path, source)))
|
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)
|
tarBallReader := tar.NewReader(fileReader)
|
||||||
|
extractPath = filepath.FromSlash(extractPath)
|
||||||
for {
|
for {
|
||||||
header, err := tarBallReader.Next()
|
header, err := tarBallReader.Next()
|
||||||
if err != nil {
|
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) {
|
func TestArchive(t *testing.T) {
|
||||||
paths := []string{
|
paths := []string{
|
||||||
"somescript.sh",
|
"somescript.sh",
|
||||||
"test_files/",
|
"./test_files/",
|
||||||
}
|
}
|
||||||
|
|
||||||
err := Tarinate(paths, "output_test.tar.gz")
|
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