Remove dir

Added a check if the $file in the delete function is a dir or not, if it
is a dir then use rmdir() otherwise use unlink()