1 : #ifndef EPT_DEBTAGS_SOURCEDIR_H
2 : #define EPT_DEBTAGS_SOURCEDIR_H
3 :
4 : /** @file
5 : * @author Enrico Zini <enrico@enricozini.org>
6 : * Debtags data source directory access
7 : */
8 :
9 : /*
10 : * Copyright (C) 2003,2004,2005,2006,2007 Enrico Zini <enrico@debian.org>
11 : *
12 : * This program is free software; you can redistribute it and/or modify
13 : * it under the terms of the GNU General Public License as published by
14 : * the Free Software Foundation; either version 2 of the License, or
15 : * (at your option) any later version.
16 : *
17 : * This program is distributed in the hope that it will be useful,
18 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 : * GNU General Public License for more details.
21 : *
22 : * You should have received a copy of the GNU General Public License
23 : * along with this program; if not, write to the Free Software
24 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 : */
26 :
27 : #include <wibble/sys/fs.h>
28 : #include <string>
29 :
30 : namespace ept {
31 : namespace debtags {
32 :
33 : class VocabularyMerger;
34 :
35 : /**
36 : * Access a directory containing Debtags data files
37 : */
38 : class SourceDir : public wibble::sys::fs::Directory
39 82 : {
40 : protected:
41 : enum FileType { SKIP, TAG, VOC, TAGGZ, VOCGZ };
42 :
43 : // Check if a file name is a tag file, a vocabulary file or a file to skip.
44 : // Please notice that it works on file names, not paths.
45 : FileType fileType(const std::string& name);
46 :
47 : public:
48 82 : SourceDir(const std::string& path) : Directory(path) {}
49 :
50 : /// Return the time of the newest file in the source directory
51 : time_t timestamp();
52 :
53 : /// Return the time of the newest vocabulary file in the source directory
54 : time_t vocTimestamp();
55 :
56 : /// Return the time of the newest tag file in the source directory
57 : time_t tagTimestamp();
58 :
59 : /// Read the tag files in the directory and output their content to out
60 : template<typename OUT>
61 4 : void readTags(OUT out);
62 :
63 : /**
64 : * Read the vocabulary files in the directory and output their content to
65 : * out
66 : */
67 : void readVocabularies(VocabularyMerger& out);
68 : };
69 :
70 : }
71 : }
72 :
73 : // vim:set ts=4 sw=4:
74 : #endif
|