recursive checking when compiling with gcc
This commit is contained in:
parent
b6ea2e43ff
commit
97003e8064
31
main.cpp
31
main.cpp
|
@ -14,6 +14,9 @@
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#include <dir.h>
|
#include <dir.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#include <glob.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool Debug = false;
|
bool Debug = false;
|
||||||
|
@ -35,6 +38,16 @@ static void AddFiles( std::vector<std::string> &filenames, const char path[], co
|
||||||
filenames.push_back( fname.str() );
|
filenames.push_back( fname.str() );
|
||||||
}
|
}
|
||||||
findclose(&f);
|
findclose(&f);
|
||||||
|
#else
|
||||||
|
glob_t glob_results;
|
||||||
|
glob(pattern, 0, 0, &glob_results);
|
||||||
|
for ( unsigned int i = 0; i < glob_results.gl_pathc; i++ )
|
||||||
|
{
|
||||||
|
std::ostringstream fname;
|
||||||
|
fname << path << glob_results.gl_pathv[i];
|
||||||
|
filenames.push_back( fname.str() );
|
||||||
|
}
|
||||||
|
globfree(&glob_results);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +70,22 @@ static void RecursiveAddFiles( std::vector<std::string> &filenames, const char p
|
||||||
chdir( ".." );
|
chdir( ".." );
|
||||||
}
|
}
|
||||||
findclose(&f);
|
findclose(&f);
|
||||||
|
#else
|
||||||
|
glob_t glob_results;
|
||||||
|
glob("*", GLOB_ONLYDIR, 0, &glob_results);
|
||||||
|
for ( unsigned int i = 0; i < glob_results.gl_pathc; i++ )
|
||||||
|
{
|
||||||
|
const char *dirname = glob_results.gl_pathv[i];
|
||||||
|
if ( dirname[0] == '.' )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
chdir( dirname );
|
||||||
|
std::ostringstream curdir;
|
||||||
|
curdir << path << dirname << "/";
|
||||||
|
RecursiveAddFiles( filenames, curdir.str().c_str() );
|
||||||
|
chdir( ".." );
|
||||||
|
}
|
||||||
|
globfree(&glob_results);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +143,7 @@ int main(int argc, char* argv[])
|
||||||
" When this option is given, all messages are shown.\n"
|
" When this option is given, all messages are shown.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --style Check coding style.\n"
|
" --style Check coding style.\n"
|
||||||
" --recursive Recursily check all *.cpp, *.cc and *.c files\n";
|
" --recursive Recursively check all *.cpp, *.cc and *.c files\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue