Commit 7c3a5c48 authored by Damien Leroux's avatar Damien Leroux
Browse files

Make it possible to create deep directory structures.

parent e6cf0408
all: spell-qtl spell-pedigree spell-marker
spell-qtl:
depend:
cd src && make .depend
cd src/bayes/ && make .depend
cd src/pedigree/ && make .depend
spell-qtl: depend
cd src && $(MAKE)
spell-pedigree:
spell-pedigree: depend
cd src/pedigree && $(MAKE)
spell-marker:
spell-marker: depend
cd src/bayes && $(MAKE)
clean:
......
......@@ -19,7 +19,8 @@ CXXARGS=-Wextra -Wall -pthread -fPIC -DEIGEN_NO_DEPRECATED_WARNING $(VERSION_DEF
#CXXARGS=-Wextra -Wall -pthread -fPIC -DEIGEN_NO_DEPRECATED_WARNING $(VERSION_DEFINES)
#DEBUG_OPTS=-ggdb -O0
OPT_OPTS=-O3 -DEIGEN_NO_DEBUG -DNDEBUG
OPT_OPTS=-O2 -DEIGEN_NO_DEBUG -DNDEBUG
#OPT_OPTS=-O3 -DEIGEN_NO_DEBUG -DNDEBUG
#OPT_OPTS=-ggdb -O2 -DEIGEN_NO_DEBUG -DNDEBUG
#DEBUG_OPTS=-ggdb -DNDEBUG
#OPT_OPTS=-O3 -DNDEBUG
......
......@@ -78,5 +78,25 @@ bool ensure_directory_exists(const std::string& path)
|| mkdir(path.c_str(), 0770) != -1;
}
static inline
bool ensure_directories_exist(const std::string& path)
{
auto i = path.begin(), j = path.end();
bool ok = true;
/*if (*i == '/') { ++i; }*/
do {
if (i != j) {
++i;
}
while (i != j && *i != '/') { ++i; }
std::string sub(path.begin(), i);
/*MSG_INFO("ensure_directory_exists " << sub);*/
ok = ensure_directory_exists(sub);
} while (ok && i != j);
return ok;
}
#endif
......@@ -239,7 +239,7 @@ struct disk_hashtable<ValueType(AllArgs...)> {
: m_base_path(base_path)
/*: m_base_path(MESSAGE(active_settings->work_directory << '/' << base_name))*/
{
ensure_directory_exists(m_base_path);
ensure_directories_exist(m_base_path);
}
std::string
......@@ -321,7 +321,7 @@ struct disk_hashtable<ValueType(AllArgs...)> {
{
std::string hashed_key = hash(std::forward<AllArgs>(args)...);
std::string path = MESSAGE(m_base_path << '/' << hashed_key);
ensure_directory_exists(path);
ensure_directories_exist(path);
std::vector<std::string> entries = get_entries(path);
put(path, entries, value, std::forward<AllArgs>(args)...);
}
......@@ -351,7 +351,7 @@ struct disk_hashtable<ValueType(AllArgs...)> {
{
std::string hashed_key = hash(std::forward<AllArgs>(args)...);
std::string path = MESSAGE(m_base_path << '/' << hashed_key);
ensure_directory_exists(path);
ensure_directories_exist(path);
std::vector<std::string> entries = get_entries(path);
std::pair<bool, value_type> ret;
ret.first = find([&] (std::fstream& ifs) { cache_input ci(ifs); ci & ret.second; },
......
......@@ -1565,7 +1565,7 @@ settings_constraint_t
bool settings_t::sanity_check() const
{
ensure_directory_exists(work_directory);
ensure_directories_exist(work_directory);
settings_constraint_t::check(this);
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment