MCPcopy Create free account
hub / github.com/VemtoOrg/vemto2 / clearFolder

Method clearFolder

src/main/base/FileSystem.ts:252–272  ·  view source on GitHub ↗
(folderPath: string, removeOwnFolder: boolean = false)

Source from the content-addressed store, hash-verified

250 }
251
252 clearFolder(folderPath: string, removeOwnFolder: boolean = false): FileSystem {
253 if(this.folderDoesNotExist(folderPath)) return this
254
255 console.log('Clearing Folder: ' + folderPath)
256
257 fs.readdirSync(folderPath).forEach((file) => {
258 const curPath = path.join(folderPath, file)
259
260 if (fs.lstatSync(curPath).isDirectory()) {
261 this.clearFolder(curPath, true)
262 } else {
263 fs.unlinkSync(curPath)
264 }
265 })
266
267 if(removeOwnFolder) {
268 fs.rmdirSync(folderPath)
269 }
270
271 return this
272 }
273
274 walkSync(
275 dir: string,

Callers 1

HandleIpcMessagesFunction · 0.80

Calls 3

folderDoesNotExistMethod · 0.95
joinMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected