Open
Description
When calling FileManager.copyItems(atPath:toPath:)
with a source folder and a destination folder without a trailing slash, the copied files in the source directory will be renamed to have the destination directory name prepended to the file/directory names.
This is occurring on macOS 15.4.1 (24E263) and it didn’t occur in macOS 15.3 and earlier.
swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0
Filed feedback FB17323332
Script to reproduce the issue
mkdir -p a/b/c z
touch a/b/foo.txt
echo 'import Foundation; try FileManager.default.copyItem(atPath: "a/b/", toPath: "z/b")' | swift -
It will start with the following folder structure before preforming the copy
.
├── a
│ └── b
│ ├── c
│ └── foo.txt
└── z
After the copy, the resulting folder structure should be
.
├── a
│ └── b
│ ├── c
│ └── foo.txt
└── z
└── b
├── c
└── foo.txt
But it is actually the following, prepending the contained item names with the destination directory name.
.
├── a
│ └── b
│ ├── c
│ └── foo.txt
└── z
├── b
├── bc
└── bfoo.txt
Adding a trailing slash to the toPath
to become "z/b/"
works around the issue.
Metadata
Metadata
Assignees
Labels
No labels