From 09f307b6cb4f7c69e5b0685acc0bdd18e9d57d40 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 17 Dec 2007 14:47:30 +0000 Subject: home directory creation --- src/common/path.cc | 40 ++++++++++++++++++++++++++++++++++++++++ src/common/path.h | 26 ++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/common/path.cc create mode 100644 src/common/path.h (limited to 'src/common') diff --git a/src/common/path.cc b/src/common/path.cc new file mode 100644 index 0000000..d9fc332 --- /dev/null +++ b/src/common/path.cc @@ -0,0 +1,40 @@ +/* + common/path.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +// project headers +#include "path.h" +#include "console.h" + +#ifdef _WIN32 +#include +#else +#include +#endif + +namespace common { + +void Path::create(std::string path) +{ + std::string tmp(path); + if (tmp[tmp.size()-1] == '/') + tmp = tmp.substr(0, tmp.size() - 1); + +#ifdef _WIN32 + mkdir(tmp.c_str()); +#else + if (!mkdir(tmp.c_str(), 0777)) + conwarn << "Could not create directory " << tmp << std::endl; + else + condebug << "Path created " << tmp << std::endl; +#endif +} + +bool Path::exists(std::string path) +{ + return false; +} + +} diff --git a/src/common/path.h b/src/common/path.h new file mode 100644 index 0000000..43b07d2 --- /dev/null +++ b/src/common/path.h @@ -0,0 +1,26 @@ +/* + common/path.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#ifndef __INCLUDED_PATH_H__ +#define __INCLUDED_PATH_H__ + +// C++ headers +#include +#include + +namespace common { + +/// a class to create directories +class Path +{ +public: + static bool exists(std::string path); + static void create(std::string path); +}; // class Path + +} // namespace common + +#endif // __INCLUDED_PATH_H__ -- cgit v1.2.3