Remove $native.remove()

This commit is contained in:
Kevin Sawicki
2013-03-07 18:36:20 -08:00
parent d91c540d47
commit 2f8b1d5e3e
2 changed files with 13 additions and 13 deletions

View File

@@ -86,7 +86,19 @@ module.exports =
# Remove a file at the given path. Throws an error if path is not a
# file or a symbolic link to a file.
remove: (path) ->
$native.remove path
if @isFile(path)
nodeFs.unlinkSync(path)
else if @isDirectory(path)
removeDirectory = (path) =>
for entry in nodeFs.readdirSync(path)
entryPath = @join(path, entry)
stats = nodeFs.statSync(entryPath)
if stats.isDirectory()
removeDirectory(entryPath)
else if stats.isFile()
nodeFs.unlinkSync(entryPath)
nodeFs.rmdirSync(path)
removeDirectory(path)
# Open, read, and close a file, returning the file's contents.
read: (path) ->