Skip to content

Commit

Permalink
fs: Rewrite 'fs_removeDirectoryAndContents'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelheilmann committed Jan 17, 2018
1 parent 23fc946 commit 9741899
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions egolib/src/egolib/file_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,36 +71,7 @@ int fs_init(const char *argv0)
//--------------------------------------------------------------------------------------------
void fs_removeDirectoryAndContents(const char *dirname)
{
/// @author ZZ
/// @details This function deletes all files in a directory,
/// and the directory itself

char filePath[MAX_PATH] = EMPTY_CSTR;
const char *fileName;
fs_find_context_t fs_search;

// List all the files in the directory
fileName = fs_findFirstFile(dirname, NULL, &fs_search);
while (NULL != fileName)
{
// Ignore files that start with a ., like .svn for example.
if ('.' != fileName[0])
{
snprintf(filePath, MAX_PATH, "%s" SLASH_STR "%s", dirname, fileName);
if (fs_fileIsDirectory(filePath))
{
fs_removeDirectoryAndContents(filePath);
}
else
{
fs_deleteFile(filePath);
}
}
fileName = fs_findNextFile(&fs_search);
}
fs_findClose(&fs_search);

fs_removeDirectory(dirname);
id::file_system::delete_directory_recursive(dirname);
}

//--------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 9741899

Please sign in to comment.