summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Zini <enrico@enricozini.org>2015-06-17 22:52:19 +0200
committerEnrico Zini <enrico@enricozini.org>2015-06-17 22:52:19 +0200
commit17bc9b97284f94e0686df95601cd1612fdf351bc (patch)
treee9bae5a8d3ff4c2ffe262f9d450181107e9348b0
parentf3fd2b05c7c620edd0aae8330bf43c5246459300 (diff)
downloadlibept-17bc9b97284f94e0686df95601cd1612fdf351bc.tar.gz
Removed debtags/maint/path and debtags/maint/sourcedir
-rw-r--r--ept/debtags/debtags.cc48
-rw-r--r--ept/debtags/debtags.h8
-rw-r--r--ept/debtags/debtags.tcc22
-rw-r--r--ept/debtags/debtags.test.h106
-rw-r--r--ept/debtags/expression.test.h1
-rw-r--r--ept/debtags/maint/path.cc113
-rw-r--r--ept/debtags/maint/path.h125
-rw-r--r--ept/debtags/maint/sourcedir.cc141
-rw-r--r--ept/debtags/maint/sourcedir.h75
-rw-r--r--ept/debtags/maint/sourcedir.tcc55
-rw-r--r--ept/debtags/vocabulary.test.h1
-rw-r--r--ept/test.h13
12 files changed, 64 insertions, 644 deletions
diff --git a/ept/debtags/debtags.cc b/ept/debtags/debtags.cc
index a889ae3..5d633f4 100644
--- a/ept/debtags/debtags.cc
+++ b/ept/debtags/debtags.cc
@@ -24,8 +24,6 @@
*/
#include <ept/debtags/debtags.h>
-#include <ept/debtags/maint/path.h>
-#include <ept/debtags/maint/sourcedir.h>
#include <tagcoll/patch.h>
#include <tagcoll/coll/simple.h>
@@ -52,43 +50,32 @@ namespace ept {
namespace debtags {
Debtags::Debtags(bool editable)
+ : m_timestamp(0)
{
- // Read and merge tag data
- SourceDir mainSource(Path::debtagsSourceDir());
- SourceDir userSource(Path::debtagsUserSourceDir());
+ string src = pathname();
+ if (!sys::fs::exists(src))
+ return;
- mainSource.readTags(inserter(*this));
- userSource.readTags(inserter(*this));
+ // Read uncompressed data
+ tagcoll::input::Stdio in(src);
- time_t ts_main_src = mainSource.tagTimestamp();
- time_t ts_user_src = userSource.tagTimestamp();
- m_timestamp = ts_main_src > ts_user_src ? ts_main_src : ts_user_src;
+ // Read the collection
+ tagcoll::textformat::parse(in, inserter(*this));
- // Initialize the patch collection layer
- rcdir = Path::debtagsUserSourceDir();
+ // Read the timestamp
+ m_timestamp = sys::fs::timestamp(src, 0);
+}
- string patchFile = str::joinpath(rcdir, "patch");
- if (Path::access(patchFile, F_OK) == 0)
- {
- input::Stdio in(patchFile);
- PatchList<string, string> patch;
- textformat::parsePatch(in, inserter(patch));
- applyChange(patch);
- }
+string Debtags::pathname()
+{
+ const char* res = getenv("DEBTAGS_TAGS");
+ if (!res) res = "/var/lib/debtags/package-tags";
+ return res;
}
tagcoll::PatchList<std::string, std::string> Debtags::changes() const
{
- // Read original tag data
- SourceDir mainSource(Path::debtagsSourceDir());
- SourceDir userSource(Path::debtagsUserSourceDir());
- coll::Simple<string, string> orig;
- mainSource.readTags(inserter(orig));
- userSource.readTags(inserter(orig));
-
- tagcoll::PatchList<std::string, std::string> res;
- res.addPatch(orig, *this);
- return res;
+ return tagcoll::PatchList<std::string, std::string>();
}
@@ -202,7 +189,6 @@ void Debtags::sendPatch(const PatchList<std::string, std::string>& patch)
}
}
-#include <ept/debtags/maint/sourcedir.tcc>
#include <tagcoll/patch.tcc>
#include <tagcoll/coll/simple.tcc>
#include <tagcoll/coll/fast.tcc>
diff --git a/ept/debtags/debtags.h b/ept/debtags/debtags.h
index 24b033b..06f3b64 100644
--- a/ept/debtags/debtags.h
+++ b/ept/debtags/debtags.h
@@ -174,6 +174,14 @@ public:
*/
template<typename OUT>
void outputPatched(const std::string& filename, const OUT& out);
+
+ /**
+ * Return the default pathname for the debtags tags.
+ *
+ * This returns /var/lib/debtags/package-tags, unless it has been
+ * overridden by setting $DEBTAGS_TAGS
+ */
+ static std::string pathname();
};
diff --git a/ept/debtags/debtags.tcc b/ept/debtags/debtags.tcc
index 48f80fb..37183a2 100644
--- a/ept/debtags/debtags.tcc
+++ b/ept/debtags/debtags.tcc
@@ -27,13 +27,11 @@
#define EPT_DEBTAGS_DEBTAGS_TCC
#include <ept/debtags/debtags.h>
-#include <ept/debtags/maint/path.h>
-#include <ept/debtags/maint/sourcedir.h>
-
#include <tagcoll/coll/simple.h>
#include <tagcoll/input/stdio.h>
#include <tagcoll/stream/patcher.h>
#include <tagcoll/TextFormat.h>
+#include <wibble/sys/fs.h>
namespace ept {
namespace debtags {
@@ -41,13 +39,15 @@ namespace debtags {
template<typename OUT>
void Debtags::outputSystem(const OUT& cons)
{
- // Read and merge tag data
- SourceDir mainSource(Path::debtagsSourceDir());
- SourceDir userSource(Path::debtagsUserSourceDir());
- tagcoll::coll::Simple<string, string> merged;
- mainSource.readTags(inserter(merged));
- userSource.readTags(inserter(merged));
- merged.output(cons);
+ string src = pathname();
+ if (!wibble::sys::fs::exists(src))
+ return;
+
+ // Read uncompressed data
+ tagcoll::input::Stdio in(src);
+
+ // Read the collection
+ tagcoll::textformat::parse(in, cons);
}
@@ -91,10 +91,10 @@ void Debtags::outputPatched(const std::string& filename, const OUT& out)
}
}
-#include <ept/debtags/maint/sourcedir.tcc>
#include <tagcoll/coll/simple.tcc>
#include <tagcoll/coll/fast.tcc>
#include <tagcoll/patch.tcc>
+#include <tagcoll/TextFormat.tcc>
#endif
diff --git a/ept/debtags/debtags.test.h b/ept/debtags/debtags.test.h
index f7613c2..60de7e0 100644
--- a/ept/debtags/debtags.test.h
+++ b/ept/debtags/debtags.test.h
@@ -45,13 +45,17 @@ using namespace ept;
using namespace ept::debtags;
using namespace wibble::operators;
+#define testfile TEST_ENV_DIR "debtags/package-tags"
+
struct TestDebtags : DebtagsTestEnvironment
{
- Debtags debtags;
-
TestDebtags() {}
- Test _1() {
+ Test _1()
+ {
+ EnvOverride eo("DEBTAGS_TAGS", testfile);
+ Debtags debtags;
+
for (Debtags::const_iterator i = debtags.begin(); i != debtags.end(); ++i)
{
*i;
@@ -62,16 +66,18 @@ struct TestDebtags : DebtagsTestEnvironment
debtags.outputSystem(stream::countingSink(items, tags));
int pitems = 0, ptags = 0;
- debtags.outputPatched(stream::countingSink(pitems, ptags));
+ debtags.outputPatched(stream::countingSink(pitems, ptags));
- assert(items > 10);
- assert(tags > 10);
- assert(items <= pitems);
- assert(tags <= ptags);
-}
+ assert(items > 10);
+ assert(tags > 10);
+ assert(items <= pitems);
+ assert(tags <= ptags);
+ }
- Test _2()
-{
+ Test _2()
+ {
+ EnvOverride eo("DEBTAGS_TAGS", testfile);
+ Debtags debtags;
string p("debtags");
std::set<std::string> tags = debtags.getTagsOfItem(p);
assert( !tags.empty() );
@@ -96,9 +102,11 @@ struct TestDebtags : DebtagsTestEnvironment
assert( tags.find("works-with::software:package") != tags.end() );
}
- Test _3()
-{
- using namespace std;
+ Test _3()
+ {
+ using namespace std;
+ EnvOverride eo("DEBTAGS_TAGS", testfile);
+ Debtags debtags;
/* Get the 'debtags' package */
string p("debtags");
@@ -180,71 +188,11 @@ struct TestDebtags : DebtagsTestEnvironment
//c.debtags().getTags(""); // XXX HACK AWW!
}
- Test _4()
-{
- std::string patchfile = Path::debtagsUserSourceDir() + "patch";
- unlink(patchfile.c_str());
-
- string p("debtags");
-
- /* Get its tags */
- std::set<std::string> tags = debtags.getTagsOfItem(p);
- assert(!tags.empty());
-
- // Ensure that it's not tagged with gameplaying
- std::string t = "use::gameplaying";
- assert(tags.find(t) == tags.end());
-
- // Add the gameplaying tag
- PatchList<string, string> change;
- change.addPatch(Patch<string, string>(p, wibble::singleton(t), wibble::Empty<string>()));
- debtags.applyChange(change);
-
- // See that the patch is non empty
- PatchList<string, string> tmp = debtags.changes();
- assert(tmp.size() > 0);
- assert_eq(tmp.size(), 1u);
-
- // Ensure that the tag has been added
- tags = debtags.getTagsOfItem(p);
- assert(!tags.empty());
-
- t = "use::gameplaying";
- assert(tags.find(t) != tags.end());
-
- // Save the patch
- debtags.savePatch();
-
- // Check that the saved patch is correct
- FILE* in = fopen(patchfile.c_str(), "r");
- string writtenPatch;
- int c;
- while ((c = getc(in)) != EOF)
- writtenPatch += c;
- fclose(in);
-
- assert_eq(writtenPatch, string("debtags: +use::gameplaying\n"));
-
- unlink(patchfile.c_str());
-
- // Reapply the patch and see that it doesn't disrept things
- debtags.applyChange(change);
-
- // The patch should not have changed
- tmp = debtags.changes();
- assert_eq(tmp.size(), 1u);
- assert_eq(tmp.begin()->first, p);
- assert_eq(tmp.begin()->second.item, p);
-}
-
-// If there is no data, Debtags should work as an empty collection
- Test _5()
-{
- Path::OverrideDebtagsSourceDir odsd("./empty");
- Path::OverrideDebtagsIndexDir odid("./empty");
- Path::OverrideDebtagsUserSourceDir odusd("./empty");
- Path::OverrideDebtagsUserIndexDir oduid("./empty");
- Debtags empty;
+ // If there is no data, Debtags should work as an empty collection
+ Test _4()
+ {
+ EnvOverride eo("DEBTAGS_TAGS", "./empty/notags");
+ Debtags empty;
assert(empty.begin() == empty.end());
assert_eq(empty.timestamp(), 0);
diff --git a/ept/debtags/expression.test.h b/ept/debtags/expression.test.h
index 9f2ea08..b3789ab 100644
--- a/ept/debtags/expression.test.h
+++ b/ept/debtags/expression.test.h
@@ -19,7 +19,6 @@
*/
#include <wibble/test.h>
-#include <ept/debtags/maint/path.h>
#include <tagcoll/expression.h>
#include <ept/debtags/vocabulary.h>
diff --git a/ept/debtags/maint/path.cc b/ept/debtags/maint/path.cc
deleted file mode 100644
index bb08682..0000000
--- a/ept/debtags/maint/path.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-// -*- mode: c++; indent-tabs-mode: t -*-
-
-/** \file
- * debtags paths
- */
-
-/*
- * Copyright (C) 2005,2006,2007 Enrico Zini <enrico@debian.org>, Peter Rockai <me@mornfall.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <ept/debtags/maint/path.h>
-#include <ept/config.h>
-
-#include <wibble/sys/fs.h>
-#include <wibble/string.h>
-
-#include <sys/types.h> // getpwuid, getuid
-#include <pwd.h> // getpwuid
-#include <unistd.h> // getuid
-
-using namespace wibble;
-
-namespace ept {
-namespace debtags {
-
-static std::string userdir()
-{
- std::string rcdir;
-
- struct passwd* udata = getpwuid(getuid());
- rcdir = str::joinpath(udata->pw_dir, ".debtags");
-
- return rcdir;
-}
-
-
-Path &Path::instance() {
- if (!s_instance) {
- s_instance = new Path;
- instance().m_debtagsSourceDir = DEBTAGS_DB_DIR;
- instance().m_debtagsIndexDir = DEBTAGS_DB_DIR;
- instance().m_debtagsUserSourceDir = userdir();
- instance().m_debtagsUserIndexDir = userdir();
- }
- return *s_instance;
-}
-
-int Path::access( const std::string &s, int m ) {
- return ::access( s.c_str(), m );
-}
-
-time_t Path::timestamp( const std::string& file ) {
- return sys::fs::timestamp(file, 0);
-}
-
-void Path::setDebtagsSourceDir( const std::string &s )
-{
- instance().m_debtagsSourceDir = s;
-}
-void Path::setDebtagsIndexDir( const std::string &s )
-{
- instance().m_debtagsIndexDir = s;
-}
-void Path::setDebtagsUserSourceDir( const std::string &s )
-{
- instance().m_debtagsUserSourceDir = s;
-}
-void Path::setDebtagsUserIndexDir( const std::string &s )
-{
- instance().m_debtagsUserIndexDir = s;
-}
-
-std::string Path::debtagsSourceDir() { return instance().m_debtagsSourceDir; }
-std::string Path::debtagsIndexDir() { return instance().m_debtagsIndexDir; }
-std::string Path::debtagsUserSourceDir() { return instance().m_debtagsUserSourceDir; }
-std::string Path::debtagsUserIndexDir() { return instance().m_debtagsUserIndexDir; }
-
-std::string Path::vocabulary() {
- return str::joinpath(debtagsIndexDir(), "vocabulary");
-}
-
-std::string Path::userVocabulary() {
- return str::joinpath(debtagsUserIndexDir(), "vocabulary");
-}
-
-std::string Path::tagdb() {
- return str::joinpath(debtagsIndexDir(), "package-tags");
-}
-
-std::string Path::userTagdb() {
- return str::joinpath(debtagsUserIndexDir(), "package-tags");
-}
-
-Path *Path::s_instance = 0;
-
-}
-}
-
-// vim:set ts=4 sw=4:
diff --git a/ept/debtags/maint/path.h b/ept/debtags/maint/path.h
deleted file mode 100644
index 2c7f95e..0000000
--- a/ept/debtags/maint/path.h
+++ /dev/null
@@ -1,125 +0,0 @@
-// -*- mode: c++; indent-tabs-mode: t -*-
-/** \file
- * debtags paths
- */
-
-/*
- * Copyright (C) 2005,2006,2007 Enrico Zini <enrico@debian.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <string>
-
-#ifndef EPT_DEBTAGS_PATH_H
-#define EPT_DEBTAGS_PATH_H
-
-namespace ept {
-namespace debtags {
-
-/**
- * Singleton class to configure and access the various Debtags paths
- */
-class Path
-{
-public:
- static std::string vocabulary();
- static std::string userVocabulary();
- static std::string tagdb();
- static std::string userTagdb();
-
- static std::string debtagsSourceDir();
- static std::string debtagsIndexDir();
- static std::string debtagsUserSourceDir();
- static std::string debtagsUserIndexDir();
-
- // Directory where Debtags source data is found
- static void setDebtagsSourceDir( const std::string &s );
-
- // Directory where Debtags indexes are kept
- static void setDebtagsIndexDir( const std::string &s );
-
- // User-specific directory for Debtags source data
- static void setDebtagsUserSourceDir( const std::string &s );
-
- // User-specific directory for Debtags index data
- static void setDebtagsUserIndexDir( const std::string &s );
-
- static int access( const std::string &, int );
- static time_t timestamp( const std::string& );
-
- // RAII-style classes to temporarily override directories
- class OverrideDebtagsSourceDir
- {
- std::string old;
- public:
- OverrideDebtagsSourceDir(const std::string& path) : old(Path::debtagsSourceDir())
- {
- Path::setDebtagsSourceDir(path);
- }
- ~OverrideDebtagsSourceDir() { Path::setDebtagsSourceDir(old); }
- };
- class OverrideDebtagsIndexDir
- {
- std::string old;
- public:
- OverrideDebtagsIndexDir(const std::string& path) : old(Path::debtagsIndexDir())
- {
- Path::setDebtagsIndexDir(path);
- }
- ~OverrideDebtagsIndexDir() { Path::setDebtagsIndexDir(old); }
- };
- class OverrideDebtagsUserSourceDir
- {
- std::string old;
- public:
- OverrideDebtagsUserSourceDir(const std::string& path) : old(Path::debtagsUserSourceDir())
- {
- Path::setDebtagsUserSourceDir(path);
- }
- ~OverrideDebtagsUserSourceDir() { Path::setDebtagsUserSourceDir(old); }
- };
- class OverrideDebtagsUserIndexDir
- {
- std::string old;
- public:
- OverrideDebtagsUserIndexDir(const std::string& path) : old(Path::debtagsUserIndexDir())
- {
- Path::setDebtagsUserIndexDir(path);
- }
- ~OverrideDebtagsUserIndexDir() { Path::setDebtagsUserIndexDir(old); }
- };
-protected:
- static Path *s_instance;
- static Path &instance();
-
- // Directory where Debtags source data is found
- std::string m_debtagsSourceDir;
-
- // Directory where Debtags indexes are kept
- std::string m_debtagsIndexDir;
-
- // User-specific directory for Debtags source data
- std::string m_debtagsUserSourceDir;
-
- // User-specific directory for Debtags index data
- std::string m_debtagsUserIndexDir;
-};
-
-}
-}
-
-// vim:set ts=4 sw=4:
-#endif
diff --git a/ept/debtags/maint/sourcedir.cc b/ept/debtags/maint/sourcedir.cc
deleted file mode 100644
index 859455a..0000000
--- a/ept/debtags/maint/sourcedir.cc
+++ /dev/null
@@ -1,141 +0,0 @@
-#include <ept/debtags/maint/sourcedir.h>
-#include <ept/debtags/vocabulary.h>
-#include <ept/debtags/maint/path.h>
-
-#include <wibble/string.h>
-#include <wibble/sys/fs.h>
-
-#include <tagcoll/input/zlib.h>
-#include <tagcoll/input/stdio.h>
-
-using namespace std;
-using namespace wibble;
-
-namespace ept {
-namespace debtags {
-
-SourceDir::SourceDir(const std::string& path)
- : sys::fs::Directory(path)
-{
-}
-SourceDir::~SourceDir()
-{
-}
-
-SourceDir::FileType SourceDir::fileType(const std::string& name)
-{
- if (name[0] == '.') return SKIP;
-
- // Filenames need to be at least 5 characters long (one char plus
- // extension)
- if (name.size() <= 4) return SKIP;
-
- if (name == "package-tags") return TAG;
- if (name == "vocabulary") return VOC;
-
- // Only look at .voc and .tag files
- std::string ext(name, name.size() - 4);
- if (ext == ".voc")
- return VOC;
- if (ext == ".tag")
- return TAG;
-
- // Now look for compressed files, which must have the 4 character extension
- // plus the 3 chars of '.gz'
- if (name.size() <= 7) return SKIP;
-
- ext = name.substr(name.size() - 7);
- if (ext == ".voc.gz")
- return VOCGZ;
- if (ext == ".tag.gz")
- return TAGGZ;
-
- return SKIP;
-}
-
-time_t SourceDir::timestamp()
-{
- if (!exists()) return 0;
-
- time_t max = 0;
- for (const_iterator d = begin(); d != end(); ++d)
- {
- string name = *d;
- FileType type = fileType(name);
- if (type == SKIP) continue;
-
- time_t ts = Path::timestamp(str::joinpath(m_path, name));
- if (ts > max) max = ts;
- }
-
- return max;
-}
-
-time_t SourceDir::vocTimestamp()
-{
- if (!exists()) return 0;
-
- time_t max = 0;
- for (const_iterator d = begin(); d != end(); ++d)
- {
- string name = *d;
- FileType type = fileType(name);
- if (type != VOC and type != VOCGZ) continue;
-
- time_t ts = Path::timestamp(str::joinpath(m_path, name));
- if (ts > max) max = ts;
- }
-
- return max;
-}
-
-time_t SourceDir::tagTimestamp()
-{
- if (!exists()) return 0;
-
- time_t max = 0;
- for (const_iterator d = begin(); d != end(); ++d)
- {
- string name = *d;
- FileType type = fileType(name);
- if (type != TAG and type != TAGGZ) continue;
-
- time_t ts = Path::timestamp(str::joinpath(m_path, name));
- if (ts > max) max = ts;
- }
-
- return max;
-}
-
-void SourceDir::readVocabularies(Vocabulary& out)
-{
- if (!exists()) return;
-
- for (const_iterator d = begin(); d != end(); ++d)
- {
- string name = *d;
- if (name[0] == '.') continue;
- FileType type = fileType(name);
- if (type == VOC)
- {
- // Read uncompressed data
- tagcoll::input::Stdio in(str::joinpath(m_path, name));
-
- // Read the vocabulary
- out.read(in);
- }
- else if (type == VOCGZ)
- {
- // Read compressed data
- tagcoll::input::Zlib in(str::joinpath(m_path, name));
-
- // Read the vocabulary
- out.read(in);
- }
- }
-}
-
-}
-}
-
-// vim:set ts=4 sw=4:
diff --git a/ept/debtags/maint/sourcedir.h b/ept/debtags/maint/sourcedir.h
deleted file mode 100644
index 33d38e3..0000000
--- a/ept/debtags/maint/sourcedir.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef EPT_DEBTAGS_SOURCEDIR_H
-#define EPT_DEBTAGS_SOURCEDIR_H
-
-/** @file
- * @author Enrico Zini <enrico@enricozini.org>
- * Debtags data source directory access
- */
-
-/*
- * Copyright (C) 2003--2013 Enrico Zini <enrico@debian.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <string>
-#include <wibble/sys/fs.h>
-
-namespace ept {
-namespace debtags {
-
-class Vocabulary;
-
-/**
- * Access a directory containing Debtags data files
- */
-class SourceDir : public wibble::sys::fs::Directory
-{
-protected:
- enum FileType { SKIP, TAG, VOC, TAGGZ, VOCGZ };
-
- // Check if a file name is a tag file, a vocabulary file or a file to skip.
- // Please notice that it works on file names, not paths.
- FileType fileType(const std::string& name);
-
-public:
- SourceDir(const std::string& path);
- ~SourceDir();
-
- /// Return the time of the newest file in the source directory
- time_t timestamp();
-
- /// Return the time of the newest vocabulary file in the source directory
- time_t vocTimestamp();
-
- /// Return the time of the newest tag file in the source directory
- time_t tagTimestamp();
-
- /// Read the tag files in the directory and output their content to out
- template<typename OUT>
- void readTags(OUT out);
-
- /**
- * Read the vocabulary files in the directory and output their content to
- * out
- */
- void readVocabularies(Vocabulary& out);
-};
-
-}
-}
-
-// vim:set ts=4 sw=4:
-#endif
diff --git a/ept/debtags/maint/sourcedir.tcc b/ept/debtags/maint/sourcedir.tcc
deleted file mode 100644
index ab31e9b..0000000
--- a/ept/debtags/maint/sourcedir.tcc
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef EPT_DEBTAGS_SOURCEDIR_TCC
-#define EPT_DEBTAGS_SOURCEDIR_TCC
-
-/** @file
- * @author Enrico Zini <enrico@enricozini.org>
- * Debtags data source directory access
- */
-#include <ept/debtags/maint/sourcedir.h>
-
-#include <tagcoll/input/zlib.h>
-#include <tagcoll/input/stdio.h>
-#include <wibble/sys/fs.h>
-
-using namespace wibble;
-
-namespace ept {
-namespace debtags {
-
-template<typename OUT>
-void SourceDir::readTags(OUT out)
-{
- if (!exists()) return;
-
- for (const_iterator d = begin(); d != end(); ++d)
- {
- string name = *d;
- FileType type = fileType(name);
- if (type == TAG)
- {
- // Read uncompressed data
- tagcoll::input::Stdio in(m_path + "/" + name);
-
- // Read the collection
- tagcoll::textformat::parse(in, out);
- }
- else if (type == TAGGZ)
- {
- // Read compressed data
- tagcoll::input::Zlib in(m_path + "/" + name);
-
- // Read the collection
- tagcoll::textformat::parse(in, out);
- }
- }
-}
-
-}
-}
-
-#include <tagcoll/TextFormat.tcc>
-
-#endif
-
-// -*- C++ -*-
-// vim:set ts=4 sw=4:
diff --git a/ept/debtags/vocabulary.test.h b/ept/debtags/vocabulary.test.h
index 0635d6f..00c152c 100644
--- a/ept/debtags/vocabulary.test.h
+++ b/ept/debtags/vocabulary.test.h
@@ -20,7 +20,6 @@
#include <wibble/test.h>
#include <ept/debtags/vocabulary.h>
-#include <ept/debtags/maint/path.h>
#include <tagcoll/utils/set.h>
#include <tagcoll/input/stdio.h>
#include "ept/test.h"
diff --git a/ept/test.h b/ept/test.h
index 26a900a..fc29ed6 100644
--- a/ept/test.h
+++ b/ept/test.h
@@ -1,6 +1,5 @@
//#include <ept/core/apt.h>
#include <ept/config.h>
-#include <ept/debtags/maint/path.h>
#include <wibble/test.h>
@@ -34,17 +33,7 @@ struct AptTestEnvironment {
};
struct DebtagsTestEnvironment : AptTestEnvironment {
- ept::debtags::Path::OverrideDebtagsSourceDir odsd;
- ept::debtags::Path::OverrideDebtagsIndexDir odid;
- ept::debtags::Path::OverrideDebtagsUserSourceDir odusd;
- ept::debtags::Path::OverrideDebtagsUserIndexDir oduid;
-
- DebtagsTestEnvironment()
- : odsd( TEST_ENV_DIR "debtags/"),
- odid( TEST_ENV_DIR "debtags/"),
- odusd( TEST_ENV_DIR "debtags/"),
- oduid( TEST_ENV_DIR "debtags/")
- {}
+ DebtagsTestEnvironment() {}
};
struct EnvOverride