mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 18:11: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"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/linuxkit/linuxkit/src/cmd/linuxkit/version"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -235,7 +233,11 @@ func (c *buildCtx) Copy(w io.WriteCloser) error {
|
||||
if err != nil {
|
||||
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 {
|
||||
return fmt.Errorf("ctx: Writing header for %s: %v", p, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user