summaryrefslogtreecommitdiff
path: root/ept/debtags
diff options
context:
space:
mode:
authorEnrico Zini <enrico@enricozini.org>2013-10-24 01:36:38 +0200
committerEnrico Zini <enrico@enricozini.org>2013-10-24 01:36:38 +0200
commit866a0cbcda0e33941f0709d8a0d5bb00fdd786b6 (patch)
tree3fa51fef71e687c672253f4e4a6a779d96619e75 /ept/debtags
parent584ced4ff06a00caa3837deb6452314346ba5373 (diff)
downloadlibept-866a0cbcda0e33941f0709d8a0d5bb00fdd786b6.tar.gz
Prepared new release
* Dropped Conflict on long-disappeared version of debtags * Ported to debhelper * Ported to libwibble 1.1 * Removed obsolete debian/README
Diffstat (limited to 'ept/debtags')
-rw-r--r--ept/debtags/maint/sourcedir.cc50
-rw-r--r--ept/debtags/maint/sourcedir.h7
-rw-r--r--ept/debtags/maint/sourcedir.tcc15
3 files changed, 23 insertions, 49 deletions
diff --git a/ept/debtags/maint/sourcedir.cc b/ept/debtags/maint/sourcedir.cc
index 67ca7d7..cd1f1f9 100644
--- a/ept/debtags/maint/sourcedir.cc
+++ b/ept/debtags/maint/sourcedir.cc
@@ -15,7 +15,7 @@ namespace ept {
namespace debtags {
SourceDir::SourceDir(const std::string& path)
- : path(path)
+ : sys::fs::Directory(path)
{
}
SourceDir::~SourceDir()
@@ -52,21 +52,16 @@ SourceDir::FileType SourceDir::fileType(const std::string& name)
time_t SourceDir::timestamp()
{
- auto_ptr<sys::fs::Directory> dir;
- try {
- dir.reset(new sys::fs::Directory(path));
- } catch (wibble::exception::System& e) {
- return 0;
- }
+ if (!exists()) return 0;
time_t max = 0;
- for (sys::fs::Directory::const_iterator d = dir->begin(); d != dir->end(); ++d)
+ 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(path, name));
+ time_t ts = Path::timestamp(str::joinpath(m_path, name));
if (ts > max) max = ts;
}
@@ -75,21 +70,16 @@ time_t SourceDir::timestamp()
time_t SourceDir::vocTimestamp()
{
- auto_ptr<sys::fs::Directory> dir;
- try {
- dir.reset(new sys::fs::Directory(path));
- } catch (wibble::exception::System& e) {
- return 0;
- }
+ if (!exists()) return 0;
time_t max = 0;
- for (sys::fs::Directory::const_iterator d = dir->begin(); d != dir->end(); ++d)
+ 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(path, name));
+ time_t ts = Path::timestamp(str::joinpath(m_path, name));
if (ts > max) max = ts;
}
@@ -98,21 +88,16 @@ time_t SourceDir::vocTimestamp()
time_t SourceDir::tagTimestamp()
{
- auto_ptr<sys::fs::Directory> dir;
- try {
- dir.reset(new sys::fs::Directory(path));
- } catch (wibble::exception::System& e) {
- return 0;
- }
+ if (!exists()) return 0;
time_t max = 0;
- for (sys::fs::Directory::const_iterator d = dir->begin(); d != dir->end(); ++d)
+ 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(path, name));
+ time_t ts = Path::timestamp(str::joinpath(m_path, name));
if (ts > max) max = ts;
}
@@ -121,14 +106,9 @@ time_t SourceDir::tagTimestamp()
void SourceDir::readVocabularies(Vocabulary& out)
{
- auto_ptr<sys::fs::Directory> dir;
- try {
- dir.reset(new sys::fs::Directory(path));
- } catch (wibble::exception::System& e) {
- return;
- }
-
- for (sys::fs::Directory::const_iterator d = dir->begin(); d != dir->end(); ++d)
+ if (!exists()) return;
+
+ for (const_iterator d = begin(); d != end(); ++d)
{
string name = *d;
if (name[0] == '.') continue;
@@ -136,7 +116,7 @@ void SourceDir::readVocabularies(Vocabulary& out)
if (type == VOC)
{
// Read uncompressed data
- tagcoll::input::Stdio in(str::joinpath(path, name));
+ tagcoll::input::Stdio in(str::joinpath(m_path, name));
// Read the vocabulary
out.read(in);
@@ -144,7 +124,7 @@ void SourceDir::readVocabularies(Vocabulary& out)
else if (type == VOCGZ)
{
// Read compressed data
- tagcoll::input::Zlib in(str::joinpath(path, name));
+ tagcoll::input::Zlib in(str::joinpath(m_path, name));
// Read the vocabulary
out.read(in);
diff --git a/ept/debtags/maint/sourcedir.h b/ept/debtags/maint/sourcedir.h
index 3357c04..33d38e3 100644
--- a/ept/debtags/maint/sourcedir.h
+++ b/ept/debtags/maint/sourcedir.h
@@ -7,7 +7,7 @@
*/
/*
- * Copyright (C) 2003,2004,2005,2006,2007 Enrico Zini <enrico@debian.org>
+ * 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
@@ -25,6 +25,7 @@
*/
#include <string>
+#include <wibble/sys/fs.h>
namespace ept {
namespace debtags {
@@ -34,13 +35,11 @@ class Vocabulary;
/**
* Access a directory containing Debtags data files
*/
-class SourceDir
+class SourceDir : public wibble::sys::fs::Directory
{
protected:
enum FileType { SKIP, TAG, VOC, TAGGZ, VOCGZ };
- std::string path;
-
// 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);
diff --git a/ept/debtags/maint/sourcedir.tcc b/ept/debtags/maint/sourcedir.tcc
index 1d1c7f0..ab31e9b 100644
--- a/ept/debtags/maint/sourcedir.tcc
+++ b/ept/debtags/maint/sourcedir.tcc
@@ -19,21 +19,16 @@ namespace debtags {
template<typename OUT>
void SourceDir::readTags(OUT out)
{
- auto_ptr<sys::fs::Directory> dir;
- try {
- dir.reset(new sys::fs::Directory(path));
- } catch (wibble::exception::System& e) {
- return;
- }
-
- for (sys::fs::Directory::const_iterator d = dir->begin(); d != dir->end(); ++d)
+ 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(path + "/" + name);
+ tagcoll::input::Stdio in(m_path + "/" + name);
// Read the collection
tagcoll::textformat::parse(in, out);
@@ -41,7 +36,7 @@ void SourceDir::readTags(OUT out)
else if (type == TAGGZ)
{
// Read compressed data
- tagcoll::input::Zlib in(path + "/" + name);
+ tagcoll::input::Zlib in(m_path + "/" + name);
// Read the collection
tagcoll::textformat::parse(in, out);