温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/fs/copyFileSync
点击访问原文链接

Node fs.copyFileSync function | API Reference | Bun

Node fs.copyFileSync function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:fs/copyFileSyncFcopyFileSync

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:fs/copyFileSyncFcopyFileSync

function

fs.copyFileSyncfunction copyFileSync(src: PathLike,dest: PathLike,mode?: number): void;

Synchronously copies src to dest. By default, dest is overwritten if it already exists. Returns undefined. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.

mode is an optional integer that specifies the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g.fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE).

fs.constants.COPYFILE_EXCL: The copy operation will fail if dest already exists.fs.constants.COPYFILE_FICLONE: The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then a fallback copy mechanism is used.fs.constants.COPYFILE_FICLONE_FORCE: The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then the operation will fail.
import { copyFileSync, constants } from 'node:fs';

// destination.txt will be created or overwritten by default.
copyFileSync('source.txt', 'destination.txt');
console.log('source.txt was copied to destination.txt');

// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
copyFileSync('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
@param src

source filename to copy

@param dest

destination filename of the copy operation

@param mode

modifiers for copy operation.

Referenced typestype PathLike = string | Buffer | URL

Valid types for path values in "fs".

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Node fs.copyFileSync function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for function node:fs.copyFileSync | Bun