MCPcopy Create free account
hub / github.com/nodejs/node / _rimraf

Function _rimraf

lib/internal/fs/rimraf.js:58–87  ·  view source on GitHub ↗
(path, options, callback)

Source from the content-addressed store, hash-verified

56
57
58function _rimraf(path, options, callback) {
59 // SunOS lets the root user unlink directories. Use lstat here to make sure
60 // it's not a directory.
61 lstat(path, (err, stats) => {
62 if (err) {
63 if (err.code === 'ENOENT')
64 return callback(null);
65
66 // Windows can EPERM on stat.
67 if (isWindows && err.code === 'EPERM')
68 return fixWinEPERM(path, options, err, callback);
69 } else if (stats.isDirectory()) {
70 return _rmdir(path, options, err, callback);
71 }
72
73 unlink(path, (err) => {
74 if (err) {
75 if (err.code === 'ENOENT')
76 return callback(null);
77 if (err.code === 'EISDIR')
78 return _rmdir(path, options, err, callback);
79 if (err.code === 'EPERM') {
80 return epermHandler(path, options, err, callback);
81 }
82 }
83
84 return callback(err);
85 });
86 });
87}
88
89
90function fixWinEPERM(path, options, originalErr, callback) {

Callers 1

rimrafFunction · 0.85

Calls 6

fixWinEPERMFunction · 0.85
lstatFunction · 0.70
_rmdirFunction · 0.70
unlinkFunction · 0.70
callbackFunction · 0.50
isDirectoryMethod · 0.45

Tested by

no test coverage detected