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