libept
Main Page
Namespaces
Classes
Files
File List
File Members
ept
popcon
maint
popcon/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
#ifndef EPT_POPCON_PATH_H
25
#define EPT_POPCON_PATH_H
26
27
#include <string>
28
29
namespace
ept {
30
namespace
popcon {
31
35
class
Path
36
{
37
public
:
38
static
std::string
scores
();
39
static
std::string
scoresIndex
();
40
static
std::string
userScores
();
41
static
std::string
userScoresIndex
();
42
43
static
std::string
popconSourceDir
();
44
static
std::string
popconIndexDir
();
45
static
std::string
popconUserSourceDir
();
46
static
std::string
popconUserIndexDir
();
47
48
// Directory where Popcon source data is found
49
static
void
setPopconSourceDir
(
const
std::string &s );
50
51
// Directory where Popcon indexes are kept
52
static
void
setPopconIndexDir
(
const
std::string &s );
53
54
// User-specific directory for Popcon source data
55
static
void
setPopconUserSourceDir
(
const
std::string &s );
56
57
// User-specific directory for Popcon index data
58
static
void
setPopconUserIndexDir
(
const
std::string &s );
59
60
static
int
access
(
const
std::string &,
int
);
61
static
time_t
timestamp
(
const
std::string& );
62
63
// RAII-style classes to temporarily override directories
64
class
OverridePopconSourceDir
65
{
66
std::string old;
67
public
:
68
OverridePopconSourceDir
(
const
std::string& path) : old(
Path
::popconSourceDir())
69
{
70
Path::setPopconSourceDir
(path);
71
}
72
~OverridePopconSourceDir
() {
Path::setPopconSourceDir
(old); }
73
};
74
class
OverridePopconIndexDir
75
{
76
std::string old;
77
public
:
78
OverridePopconIndexDir
(
const
std::string& path) : old(
Path
::popconIndexDir())
79
{
80
Path::setPopconIndexDir
(path);
81
}
82
~OverridePopconIndexDir
() {
Path::setPopconIndexDir
(old); }
83
};
84
class
OverridePopconUserSourceDir
85
{
86
std::string old;
87
public
:
88
OverridePopconUserSourceDir
(
const
std::string& path) : old(
Path
::popconUserSourceDir())
89
{
90
Path::setPopconUserSourceDir
(path);
91
}
92
~OverridePopconUserSourceDir
() {
Path::setPopconUserSourceDir
(old); }
93
};
94
class
OverridePopconUserIndexDir
95
{
96
std::string old;
97
public
:
98
OverridePopconUserIndexDir
(
const
std::string& path) : old(
Path
::popconUserIndexDir())
99
{
100
Path::setPopconUserIndexDir
(path);
101
}
102
~OverridePopconUserIndexDir
() {
Path::setPopconUserIndexDir
(old); }
103
};
104
protected
:
105
static
Path
*
s_instance
;
106
static
Path
&
instance
();
107
108
// Directory where Popcon source data is found
109
std::string
m_popconSourceDir
;
110
111
// Directory where Popcon indexes are kept
112
std::string
m_popconIndexDir
;
113
114
// User-specific directory for Popcon source data
115
std::string
m_popconUserSourceDir
;
116
117
// User-specific directory for Popcon index data
118
std::string
m_popconUserIndexDir
;
119
};
120
121
}
122
}
123
124
// vim:set ts=4 sw=4:
125
#endif
Generated on Mon Nov 4 2013 17:27:47 for libept by
1.8.4