Added startsWith function

This commit is contained in:
Matt Hill
2014-05-18 12:49:56 -05:00
parent d2bee35fa9
commit 0751720d95
2 changed files with 10 additions and 0 deletions

View File

@@ -1,5 +1,14 @@
#include "filesystem.h" #include "filesystem.h"
bool startsWith(std::string const &fullString, std::string const &prefix)
{
if(fullString.substr(0, prefix.size()) == prefix) {
return true;
}
return false;
}
bool hasEnding (std::string const &fullString, std::string const &ending) bool hasEnding (std::string const &fullString, std::string const &ending)
{ {
if (fullString.length() >= ending.length()) if (fullString.length() >= ending.length())

View File

@@ -17,6 +17,7 @@
#include <string.h> #include <string.h>
#include <vector> #include <vector>
bool startsWith(std::string const &fullString, std::string const &prefix);
bool hasEnding (std::string const &fullString, std::string const &ending); bool hasEnding (std::string const &fullString, std::string const &ending);
bool DirectoryExists( const char* pzPath ); bool DirectoryExists( const char* pzPath );
bool fileExists( const char* pzPath ); bool fileExists( const char* pzPath );