Skip to content

Commit

Permalink
fs: Remove redundant parameter
Browse files Browse the repository at this point in the history
Every call to 'fs_removeDirectoryAndContents' passes 'VFS_TRUE' as the argument to parameter 'recursive'. Consequently, that parameter can be removed.
  • Loading branch information
michaelheilmann committed Jan 17, 2018
1 parent feba692 commit 52f3624
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
11 changes: 2 additions & 9 deletions egolib/src/egolib/file_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int fs_init(const char *argv0)

//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
void fs_removeDirectoryAndContents(const char *dirname, int recursive)
void fs_removeDirectoryAndContents(const char *dirname)
{
/// @author ZZ
/// @details This function deletes all files in a directory,
Expand All @@ -89,14 +89,7 @@ void fs_removeDirectoryAndContents(const char *dirname, int recursive)
snprintf(filePath, MAX_PATH, "%s" SLASH_STR "%s", dirname, fileName);
if (fs_fileIsDirectory(filePath))
{
if (recursive)
{
fs_removeDirectoryAndContents(filePath, recursive);
}
else
{
fs_removeDirectory(filePath);
}
fs_removeDirectoryAndContents(filePath);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion egolib/src/egolib/file_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ int fs_removeDirectory(const std::string& pathname);
*/
void fs_deleteFile(const std::string& pathname);
bool fs_copyFile(const std::string& source, const std::string& target);
void fs_removeDirectoryAndContents(const char *pathname, int recursive);
void fs_removeDirectoryAndContents(const char *pathname);
/**
* @brief
* Copy all files in a directory into another directory.
Expand Down
3 changes: 1 addition & 2 deletions egolib/src/egolib/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,6 @@ void SearchContext::nextData()

//--------------------------------------------------------------------------------------------
int vfs_removeDirectoryAndContents(const char * dirname) {
static const int recursive = VFS_TRUE;
// buffer the directory delete through PHYSFS, so that we so not access functions that
// we have no right to! :)

Expand All @@ -1628,7 +1627,7 @@ int vfs_removeDirectoryAndContents(const char * dirname) {
if (!resolvedWriteFilename.first) return VFS_FALSE;
if (!fs_fileIsDirectory(resolvedWriteFilename.second.c_str())) return VFS_FALSE;

fs_removeDirectoryAndContents(resolvedWriteFilename.second.c_str(), recursive);
fs_removeDirectoryAndContents(resolvedWriteFilename.second.c_str());

return VFS_TRUE;
}
Expand Down

0 comments on commit 52f3624

Please sign in to comment.