diff --git a/cmd/fs/cp.go b/cmd/fs/cp.go index 294d2dab..97fceb93 100644 --- a/cmd/fs/cp.go +++ b/cmd/fs/cp.go @@ -60,7 +60,7 @@ func (c *copy) cpDirToDir(sourceDir, targetDir string) error { } func (c *copy) cpFileToDir(sourcePath, targetDir string) error { - fileName := path.Base(sourcePath) + fileName := filepath.Base(sourcePath) targetPath := path.Join(targetDir, fileName) return c.cpFileToFile(sourcePath, targetPath) diff --git a/internal/fs_cp_test.go b/internal/fs_cp_test.go index 3b73b48d..ab177a36 100644 --- a/internal/fs_cp_test.go +++ b/internal/fs_cp_test.go @@ -6,6 +6,7 @@ import ( "io" "path" "path/filepath" + "runtime" "strings" "testing" @@ -140,6 +141,22 @@ func TestAccFsCpFileToDir(t *testing.T) { } } +func TestAccFsCpFileToDirForWindowsPaths(t *testing.T) { + if runtime.GOOS != "windows" { + t.Skip("Skipping test on non-windows OS") + } + + ctx := context.Background() + sourceFiler, sourceDir := setupLocalFiler(t) + targetFiler, targetDir := setupDbfsFiler(t) + setupSourceFile(t, ctx, sourceFiler) + + windowsPath := filepath.Join(filepath.FromSlash(sourceDir), "foo.txt") + + RequireSuccessfulRun(t, "fs", "cp", windowsPath, targetDir) + assertTargetFile(t, ctx, targetFiler, "foo.txt") +} + func TestAccFsCpDirToDirFileNotOverwritten(t *testing.T) { ctx := context.Background() table := setupTable()