GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: translate error code properly in cpSync · nodejs/node@93116dd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_file.cc
  • test/parallel
    • test-fs-cp.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_file.cc‎

Copy file name to clipboardExpand all lines: src/node_file.cc
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3052,7 +3052,14 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) {
30523052
? std::filesystem::symlink_status(src_path, error_code)
30533053
: std::filesystem::status(src_path, error_code);
30543054
if (error_code) {
3055-
return env->ThrowUVException(EEXIST, "lstat", nullptr, src.out());
3055+
#ifdef _WIN32
3056+
int errorno = uv_translate_sys_error(error_code.value());
3057+
#else
3058+
int errorno =
3059+
error_code.value() > 0 ? -error_code.value() : error_code.value();
3060+
#endif
3061+
return env->ThrowUVException(
3062+
errorno, dereference ? "stat" : "lstat", nullptr, src.out());
30563063
}
30573064
auto dest_status =
30583065
dereference ? std::filesystem::symlink_status(dest_path, error_code)
Collapse file

‎test/parallel/test-fs-cp.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-cp.mjs
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,26 @@ if (!isWindows) {
419419
);
420420
}
421421

422+
// It throws an error when attempting to copy a file with a name that is too long.
423+
{
424+
const src = 'a'.repeat(5000);
425+
const dest = nextdir();
426+
assert.throws(
427+
() => cpSync(src, dest),
428+
{ code: isWindows ? 'ENOENT' : 'ENAMETOOLONG' }
429+
);
430+
}
431+
432+
// It throws an error when attempting to copy a dir that does not exist.
433+
{
434+
const src = nextdir();
435+
const dest = nextdir();
436+
assert.throws(
437+
() => cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true })),
438+
{ code: 'ENOENT' }
439+
);
440+
}
441+
422442
// It makes file writeable when updating timestamp, if not writeable.
423443
{
424444
const src = nextdir();

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.