fs: implement copyFileSync in C++ - #65376
Open
anonrig wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
cursor
Bot
force-pushed
the
cursor/copyfilesync-cpp-upstream-317c
branch
from
August 18, 2026 12:47
e13ed43 to
8170ff5
Compare
Move path validation, file URL conversion, NUL checks, mode validation, permission checks, and the copy into a dedicated C++ binding so fs.copyFileSync() no longer goes through getValidatedPath() in JavaScript. VFS dispatch stays in JS and still runs before validation. The copy itself uses uv_fs_copyfile, so flags, mode/timestamp preservation, and UV error shapes stay the same. Also fix FileURLToPath aborting on file URLs with a hostname because the ERR_INVALID_FILE_URL_HOST format string lacked %s. Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
cursor
Bot
force-pushed
the
cursor/copyfilesync-cpp-upstream-317c
branch
from
August 18, 2026 13:11
8170ff5 to
e4dc3a1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65376 +/- ##
==========================================
+ Coverage 90.11% 90.12% +0.01%
==========================================
Files 752 752
Lines 251861 251968 +107
Branches 47365 47396 +31
==========================================
+ Hits 226955 227082 +127
+ Misses 16238 16203 -35
- Partials 8668 8683 +15
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move
fs.copyFileSync()path validation, file URL conversion, NULchecks, mode validation, permission-model checks, and the copy into a
dedicated C++ binding.
JavaScript only does VFS dispatch (still before validation). The copy
itself uses
uv_fs_copyfile, soCOPYFILE_EXCL/FICLONE/FICLONE_FORCE, mode/timestamp preservation, and UV error shapes(
syscall: 'copyfile',path/dest) stay the same.This also fixes a crash in the C++
FileURLToPathhelper:ERR_INVALID_FILE_URL_HOSTused a format string without%s, whichaborted on file URLs with a hostname. That path is now reachable from
copyFileSync.Performance
Same-binary comparison of the old JS
getValidatedPath+binding.copyFilepath vsbinding.copyFileSync(n=10000):benchmark/fs/bench-copyFileSync.js(n=10000) is dominated byuv_fs_copyfileI/O onvalidand by ENOENT oninvalid; thosecases stay within a few percent of the old path.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesTests
test/parallel/test-fs-copyfile.js(Buffer,Uint8Array,file:URL, non-file URL, encoded slashes, file URL host)test/parallel/test-fs-copyfile-respect-permissions.jstest/parallel/test-fs-null-bytes.jstest/parallel/test-fs-error-messages.jstest/parallel/test-permission-fs-read.js/test-permission-fs-write.jscopyFileSynctests