mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-22 10:31:35 +00:00
Fix relative path under Windows
Using filepath primitives instead of manipulating file paths manually takes care of platform specific formats. Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
This commit is contained in:
parent
816ef159d5
commit
e17b603be8
@ -6,10 +6,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/version"
|
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/version"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@ -235,7 +233,11 @@ func (c *buildCtx) Copy(w io.WriteCloser) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("ctx: Converting FileInfo for %s: %v", p, err)
|
return fmt.Errorf("ctx: Converting FileInfo for %s: %v", p, err)
|
||||||
}
|
}
|
||||||
h.Name = path.Join(s.dst, strings.TrimPrefix(p, s.src))
|
rel, err := filepath.Rel(s.src, p)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
h.Name = filepath.ToSlash(filepath.Join(s.dst, rel))
|
||||||
if err := tw.WriteHeader(h); err != nil {
|
if err := tw.WriteHeader(h); err != nil {
|
||||||
return fmt.Errorf("ctx: Writing header for %s: %v", p, err)
|
return fmt.Errorf("ctx: Writing header for %s: %v", p, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user