MCPcopy Index your code
hub / github.com/nodejs/node / getStatsForCopy

Function getStatsForCopy

lib/internal/fs/cp/cp.js:195–238  ·  view source on GitHub ↗
(destStat, src, dest, opts)

Source from the content-addressed store, hash-verified

193}
194
195async function getStatsForCopy(destStat, src, dest, opts) {
196 const statFn = opts.dereference ? stat : lstat;
197 const srcStat = await statFn(src);
198 if (srcStat.isDirectory() && opts.recursive) {
199 return onDir(srcStat, destStat, src, dest, opts);
200 } else if (srcStat.isDirectory()) {
201 throw new ERR_FS_EISDIR({
202 message: `${src} is a directory (not copied)`,
203 path: src,
204 syscall: 'cp',
205 errno: EISDIR,
206 code: 'EISDIR',
207 });
208 } else if (srcStat.isFile() ||
209 srcStat.isCharacterDevice() ||
210 srcStat.isBlockDevice()) {
211 return onFile(srcStat, destStat, src, dest, opts);
212 } else if (srcStat.isSymbolicLink()) {
213 return onLink(destStat, src, dest, opts);
214 } else if (srcStat.isSocket()) {
215 throw new ERR_FS_CP_SOCKET({
216 message: `cannot copy a socket file: ${dest}`,
217 path: dest,
218 syscall: 'cp',
219 errno: EINVAL,
220 code: 'EINVAL',
221 });
222 } else if (srcStat.isFIFO()) {
223 throw new ERR_FS_CP_FIFO_PIPE({
224 message: `cannot copy a FIFO pipe: ${dest}`,
225 path: dest,
226 syscall: 'cp',
227 errno: EINVAL,
228 code: 'EINVAL',
229 });
230 }
231 throw new ERR_FS_CP_UNKNOWN({
232 message: `cannot copy an unknown file type: ${dest}`,
233 path: dest,
234 syscall: 'cp',
235 errno: EINVAL,
236 code: 'EINVAL',
237 });
238}
239
240function onFile(srcStat, destStat, src, dest, opts) {
241 if (!destStat) return _copyFile(srcStat, src, dest, opts);

Callers 2

checkParentDirFunction · 0.85
copyDirFunction · 0.85

Calls 10

isCharacterDeviceMethod · 0.80
isBlockDeviceMethod · 0.80
isSocketMethod · 0.80
isFIFOMethod · 0.80
onDirFunction · 0.70
onFileFunction · 0.70
onLinkFunction · 0.70
isDirectoryMethod · 0.45
isFileMethod · 0.45
isSymbolicLinkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…