(src, dest, opts, mkDir, srcMode)
| 138 | } |
| 139 | |
| 140 | function copyDir(src, dest, opts, mkDir, srcMode) { |
| 141 | if (!opts.filter) { |
| 142 | // The caller didn't provide a js filter function, in this case |
| 143 | // we can run the whole function faster in C++ |
| 144 | // TODO(dario-piotrowicz): look into making cpSyncCopyDir also accept the potential filter function |
| 145 | return fsBinding.cpSyncCopyDir(src, dest, |
| 146 | opts.force, |
| 147 | opts.dereference, |
| 148 | opts.errorOnExist, |
| 149 | opts.verbatimSymlinks, |
| 150 | opts.preserveTimestamps); |
| 151 | } |
| 152 | |
| 153 | if (mkDir) { |
| 154 | mkdirSync(dest); |
| 155 | } |
| 156 | |
| 157 | const dir = opendirSync(src); |
| 158 | |
| 159 | try { |
| 160 | let dirent; |
| 161 | |
| 162 | while ((dirent = dir.readSync()) !== null) { |
| 163 | const { name } = dirent; |
| 164 | const srcItem = join(src, name); |
| 165 | const destItem = join(dest, name); |
| 166 | let shouldCopy = true; |
| 167 | |
| 168 | if (opts.filter) { |
| 169 | shouldCopy = opts.filter(srcItem, destItem); |
| 170 | if (isPromise(shouldCopy)) { |
| 171 | throw new ERR_INVALID_RETURN_VALUE('boolean', 'filter', shouldCopy); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | if (shouldCopy) { |
| 176 | getStats(srcItem, destItem, opts); |
| 177 | } |
| 178 | } |
| 179 | } finally { |
| 180 | dir.closeSync(); |
| 181 | |
| 182 | if (srcMode !== undefined) { |
| 183 | setDestMode(dest, srcMode); |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | // TODO(@anonrig): Move this function to C++. |
| 189 | function onLink(destStat, src, dest, verbatimSymlinks) { |
no test coverage detected
searching dependent graphs…