libept
debtags/maint/path.h
Go to the documentation of this file.
1 // -*- mode: c++; indent-tabs-mode: t -*-
6 /*
7  * Copyright (C) 2005,2006,2007 Enrico Zini <enrico@debian.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #include <string>
25 
26 struct stat;
27 
28 #ifndef EPT_DEBTAGS_PATH_H
29 #define EPT_DEBTAGS_PATH_H
30 
31 namespace ept {
32 namespace debtags {
33 
37 class Path
38 {
39 public:
40  static std::string vocabulary();
41  static std::string vocabularyIndex();
42  static std::string userVocabulary();
43  static std::string userVocabularyIndex();
44  static std::string tagdb();
45  static std::string tagdbIndex();
46  static std::string userTagdb();
47  static std::string userTagdbIndex();
48  static std::string pkgidx();
49  static std::string userPkgidx();
50 
51  static std::string debtagsSourceDir();
52  static std::string debtagsIndexDir();
53  static std::string debtagsUserSourceDir();
54  static std::string debtagsUserIndexDir();
55 
56  // Directory where Debtags source data is found
57  static void setDebtagsSourceDir( const std::string &s );
58 
59  // Directory where Debtags indexes are kept
60  static void setDebtagsIndexDir( const std::string &s );
61 
62  // User-specific directory for Debtags source data
63  static void setDebtagsUserSourceDir( const std::string &s );
64 
65  // User-specific directory for Debtags index data
66  static void setDebtagsUserIndexDir( const std::string &s );
67 
68  static int access( const std::string &, int );
69  static time_t timestamp( const std::string& );
70 
71  // RAII-style classes to temporarily override directories
73  {
74  std::string old;
75  public:
76  OverrideDebtagsSourceDir(const std::string& path) : old(Path::debtagsSourceDir())
77  {
79  }
81  };
83  {
84  std::string old;
85  public:
86  OverrideDebtagsIndexDir(const std::string& path) : old(Path::debtagsIndexDir())
87  {
89  }
91  };
93  {
94  std::string old;
95  public:
96  OverrideDebtagsUserSourceDir(const std::string& path) : old(Path::debtagsUserSourceDir())
97  {
99  }
101  };
103  {
104  std::string old;
105  public:
106  OverrideDebtagsUserIndexDir(const std::string& path) : old(Path::debtagsUserIndexDir())
107  {
109  }
111  };
112 protected:
113  static Path *s_instance;
114  static Path &instance();
115 
116  // Directory where Debtags source data is found
117  std::string m_debtagsSourceDir;
118 
119  // Directory where Debtags indexes are kept
120  std::string m_debtagsIndexDir;
121 
122  // User-specific directory for Debtags source data
124 
125  // User-specific directory for Debtags index data
127 };
128 
129 }
130 }
131 
132 // vim:set ts=4 sw=4:
133 #endif