Cleanup & reindent .cpp files

This commit is contained in:
Philippe Vaucher
2014-03-19 11:26:31 +01:00
parent e85651ef84
commit 460205e943
26 changed files with 2349 additions and 2805 deletions

View File

@@ -1,43 +1,44 @@
#include "filesystem.h"
bool hasEnding (std::string const &fullString, std::string const &ending)
{
if (fullString.length() >= ending.length()) {
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
} else {
return false;
}
if (fullString.length() >= ending.length())
{
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
}
else
{
return false;
}
}
bool DirectoryExists( const char* pzPath )
{
if ( pzPath == NULL) return false;
if ( pzPath == NULL) return false;
DIR *pDir;
bool bExists = false;
DIR *pDir;
bool bExists = false;
pDir = opendir (pzPath);
pDir = opendir (pzPath);
if (pDir != NULL)
{
bExists = true;
(void) closedir (pDir);
}
if (pDir != NULL)
{
bExists = true;
(void) closedir (pDir);
}
return bExists;
return bExists;
}
bool fileExists( const char* pzPath )
{
if (pzPath == NULL) return false;
if (pzPath == NULL) return false;
bool fExists = false;
std::ifstream f(pzPath);
fExists = f.is_open();
f.close();
return fExists;
bool fExists = false;
std::ifstream f(pzPath);
fExists = f.is_open();
f.close();
return fExists;
}
std::vector<std::string> getFilesInDir(const char* dirPath)
@@ -47,14 +48,18 @@ std::vector<std::string> getFilesInDir(const char* dirPath)
std::vector<std::string> files;
struct dirent *ent;
if ((dir = opendir (dirPath)) != NULL) {
if ((dir = opendir (dirPath)) != NULL)
{
/* print all the files and directories within directory */
while ((ent = readdir (dir)) != NULL) {
while ((ent = readdir (dir)) != NULL)
{
if (strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0)
files.push_back(ent->d_name);
files.push_back(ent->d_name);
}
closedir (dir);
} else {
}
else
{
/* could not open directory */
perror ("");
return files;
@@ -63,14 +68,14 @@ std::vector<std::string> getFilesInDir(const char* dirPath)
return files;
}
bool stringCompare( const std::string &left, const std::string &right ){
for( std::string::const_iterator lit = left.begin(), rit = right.begin(); lit != left.end() && rit != right.end(); ++lit, ++rit )
if( tolower( *lit ) < tolower( *rit ) )
return true;
else if( tolower( *lit ) > tolower( *rit ) )
return false;
if( left.size() < right.size() )
bool stringCompare( const std::string &left, const std::string &right )
{
for( std::string::const_iterator lit = left.begin(), rit = right.begin(); lit != left.end() && rit != right.end(); ++lit, ++rit )
if( tolower( *lit ) < tolower( *rit ) )
return true;
return false;
else if( tolower( *lit ) > tolower( *rit ) )
return false;
if( left.size() < right.size() )
return true;
return false;
}