This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community. Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it. https://www.freifunk-altdorf.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
967 B

var fs = require('fs')
var path = require('path')
var mkdir = require('../mkdirs')
var remove = require('../remove')
function emptyDir (dir, callback) {
callback = callback || function () {}
fs.readdir(dir, function (err, items) {
if (err) return mkdir.mkdirs(dir, callback)
items = items.map(function (item) {
return path.join(dir, item)
})
deleteItem()
function deleteItem () {
var item = items.pop()
if (!item) return callback()
remove.remove(item, function (err) {
if (err) return callback(err)
deleteItem()
})
}
})
}
function emptyDirSync (dir) {
var items
try {
items = fs.readdirSync(dir)
} catch (err) {
return mkdir.mkdirsSync(dir)
}
items.forEach(function (item) {
item = path.join(dir, item)
remove.removeSync(item)
})
}
module.exports = {
emptyDirSync: emptyDirSync,
emptydirSync: emptyDirSync,
emptyDir: emptyDir,
emptydir: emptyDir
}