From 703e03aba33f234712206769f57717ba7d92d23d Mon Sep 17 00:00:00 2001 From: LinuxWizard42 Date: Wed, 12 Oct 2022 22:54:37 +0300 Subject: Added export_allowed file to make repository visible in cgit --- .../fs-extra/lib/copy-sync/copy-file-sync.js | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 node_modules/fs-extra/lib/copy-sync/copy-file-sync.js (limited to 'node_modules/fs-extra/lib/copy-sync/copy-file-sync.js') diff --git a/node_modules/fs-extra/lib/copy-sync/copy-file-sync.js b/node_modules/fs-extra/lib/copy-sync/copy-file-sync.js new file mode 100644 index 0000000..102a6be --- /dev/null +++ b/node_modules/fs-extra/lib/copy-sync/copy-file-sync.js @@ -0,0 +1,41 @@ +'use strict' + +const fs = require('graceful-fs') + +const BUF_LENGTH = 64 * 1024 +const _buff = require('../util/buffer')(BUF_LENGTH) + +function copyFileSync (srcFile, destFile, options) { + const overwrite = options.overwrite + const errorOnExist = options.errorOnExist + const preserveTimestamps = options.preserveTimestamps + + if (fs.existsSync(destFile)) { + if (overwrite) { + fs.unlinkSync(destFile) + } else if (errorOnExist) { + throw new Error(`${destFile} already exists`) + } else return + } + + const fdr = fs.openSync(srcFile, 'r') + const stat = fs.fstatSync(fdr) + const fdw = fs.openSync(destFile, 'w', stat.mode) + let bytesRead = 1 + let pos = 0 + + while (bytesRead > 0) { + bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos) + fs.writeSync(fdw, _buff, 0, bytesRead) + pos += bytesRead + } + + if (preserveTimestamps) { + fs.futimesSync(fdw, stat.atime, stat.mtime) + } + + fs.closeSync(fdr) + fs.closeSync(fdw) +} + +module.exports = copyFileSync -- cgit v1.2.3-86-g962b