add Path::exists()

This commit is contained in:
josh committed 2014-06-22 15:30:05 -04:00
1 parent b55d8d0f09
commit e3cb7b15b4
3 files changed
+16

No files matched your search

+1
View File
@@ -14,6 +14,7 @@ namespace jes
Path dirname();
Path join(const Path & other);
const std::string & to_s() { return m_path; }
bool exists();
protected:
void clean();
std::string m_path;
+9
View File
@@ -1,4 +1,7 @@
#include "jes/Path.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
namespace jes
{
@@ -46,6 +49,12 @@ namespace jes
return Path(m_path + '/' + other.m_path);
}
bool Path::exists()
{
struct stat st;
return stat(m_path.c_str(), &st) == 0;
}
void Path::clean()
{
for (char & c : m_path)