2015-05-21 02:33:05 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <system_error>
|
|
|
|
|
|
|
|
#include "HECLDatabase.hpp"
|
2015-05-24 04:51:16 +00:00
|
|
|
#include "CSQLiteMain.hpp"
|
2015-05-21 02:33:05 +00:00
|
|
|
|
|
|
|
namespace HECLDatabase
|
|
|
|
{
|
|
|
|
|
|
|
|
class CProject : public IProject
|
|
|
|
{
|
|
|
|
std::string m_rootPath;
|
2015-05-24 04:51:16 +00:00
|
|
|
CSQLiteMain* m_db;
|
2015-05-21 02:33:05 +00:00
|
|
|
public:
|
|
|
|
CProject(const std::string& rootPath)
|
|
|
|
: m_rootPath(rootPath)
|
|
|
|
{
|
|
|
|
/* Stat for existing project directory (must already exist) */
|
|
|
|
struct stat myStat;
|
|
|
|
if (stat(m_rootPath.c_str(), &myStat))
|
|
|
|
throw std::error_code(errno, std::system_category());
|
|
|
|
|
|
|
|
if (!S_ISDIR(myStat.st_mode))
|
|
|
|
throw std::invalid_argument("provided path must be a directory; '" + m_rootPath + "' isn't");
|
|
|
|
|
|
|
|
/* Create project directory */
|
|
|
|
if (mkdir((m_rootPath + "/.hecl").c_str(), 0755))
|
|
|
|
{
|
|
|
|
if (errno != EEXIST)
|
|
|
|
throw std::error_code(errno, std::system_category());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create or open databases */
|
2015-05-24 04:51:16 +00:00
|
|
|
m_db = new CSQLiteMain(m_rootPath + "/.hecl/main.db");
|
2015-05-21 02:33:05 +00:00
|
|
|
}
|
|
|
|
|
2015-05-22 08:21:44 +00:00
|
|
|
~CProject()
|
|
|
|
{
|
2015-05-24 04:51:16 +00:00
|
|
|
delete m_db;
|
2015-05-21 02:33:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void registerLogger(HECL::TLogger logger)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-05-27 09:09:05 +00:00
|
|
|
const HECL::ProjectRootPath& getProjectRootPath(bool absolute) const
|
2015-05-21 02:33:05 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool addPath(const std::string& path)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool removePath(const std::string& path, bool recursive)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool addGroup(const std::string& path)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool removeGroup(const std::string& path)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cookPath(const std::string& path,
|
|
|
|
std::function<void(std::string&, Cost, unsigned)> feedbackCb,
|
|
|
|
bool recursive)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void interruptCook()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cleanPath(const std::string& path, bool recursive)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool packagePath(const std::string& path, bool recursive)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-05-27 09:09:05 +00:00
|
|
|
IProject* OpenProject(const std::string& rootPath)
|
2015-05-21 02:33:05 +00:00
|
|
|
{
|
|
|
|
return new CProject(rootPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|