20#define ROSTLAB_STDLIB 1
37typedef std::vector<std::string>
42inline bool file_exists(
const std::string& __path );
43inline int system(
const char* __path, ... );
44inline int system(
const std::vector<std::string>& __args );
45inline std::string
tolower( std::string __str );
51 if( stat( __path.c_str(), &buf ) )
return false;
59 std::vector<std::string> argvec;
60 argvec.push_back( __path );
63 va_start( listPointer, __path );
66 while( ( arg = va_arg( listPointer,
char* ) ) != NULL )
68 argvec.push_back( arg );
70 va_end( listPointer );
76inline int system(
const char* __path, ... )
78 std::vector<std::string> argvec;
79 argvec.push_back( __path );
82 va_start( listPointer, __path );
85 while( ( arg = va_arg( listPointer,
char* ) ) != NULL )
87 argvec.push_back( arg );
89 va_end( listPointer );
94inline int system(
const std::vector<std::string>& __args )
100 char* argv[ __args.size()+1 ];
101 for(
size_t i = 0; i < __args.size(); ++i ) argv[i] =
const_cast<char*
>( __args[i].c_str() );
102 argv[__args.size()] = NULL;
104 if( execvp( argv[0], argv ) )
throw runtime_error( strerror( errno ) );
108 if( !waitpid( pid, &status, 0 ) )
throw runtime_error( strerror( errno ) );
109 if( !WIFEXITED(status) )
throw runtime_error(
"child exited abnormally" );
114inline std::string
tolower( std::string __str )
116 for( std::string::iterator s_i = __str.begin(); s_i != __str.end(); ++s_i ) *s_i =
::tolower( *s_i );
std::string tolower(std::string __str)
argvec_type mkargvec(const char *__path,...)
bool file_exists(const std::string &__path)
int system(const char *__path,...)
std::vector< std::string > argvec_type