Skip to content

Commit

Permalink
Added "rm -rf" command that will remove all contents of the directory…
Browse files Browse the repository at this point in the history
… including subdirectories recursively. The read-only attribute for files will be ignored.
  • Loading branch information
Paul Ring committed Sep 30, 2010
1 parent 8dc1c9a commit 03876f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions OpenLog_v2/OpenLog_v2.pde
Expand Up @@ -1004,17 +1004,17 @@ void command_shell(void)
if(command_arg == 0)
continue;

//Remove empty folder.
//@NOTE: Unfortunately -rf does not work due to a buggy rmRfStar() function.
//Calling rmRfStart() will result in OpenLog rebooting.
if (strncmp_P(command_arg, PSTR("-f"), 2) == 0)
//Removing an empty folder "rm -f".
//Removing non-empty folder and all subfolders "rm -rf".
tmp_var = 1;
if (strncmp_P(command_arg, PSTR("-f"), 2) == 0 || (tmp_var = strncmp_P(command_arg, PSTR("-rf"), 3)) == 0)
{
if (file.open(currentDirectory, command_arg, O_READ))
file.close(); //There is a file called "-f"
file.close(); //There is a file called "-f" or "-rf" so remove the file
else
{
//remove and goto parent directory
if (currentDirectory.rmDir()) gotoDir("..");
if ((tmp_var == 0) ? currentDirectory.rmRfStar() : currentDirectory.rmDir()) gotoDir("..");
#ifdef INCLUDE_SIMPLE_EMBEDDED
command_succedded = 1;
#endif
Expand Down
2 changes: 1 addition & 1 deletion OpenLog_v2/SdFat.cpp
Expand Up @@ -1042,7 +1042,7 @@ uint8_t SdFile::rmRfStar(void)
if (!f.open(*this, index, O_READ)) return false;
if (f.isSubDir()) {
// recursively delete
return rmRfStar();
if (!f.rmRfStar()) return false;
}
else {
// ignore read-only
Expand Down

0 comments on commit 03876f4

Please sign in to comment.