libept
|
00001 // -*- mode: c++; indent-tabs-mode: t -*- 00006 /* 00007 * Copyright (C) 2005,2006,2007 Enrico Zini <enrico@debian.org> 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 #include <string> 00025 00026 struct stat; 00027 00028 #ifndef EPT_DEBTAGS_PATH_H 00029 #define EPT_DEBTAGS_PATH_H 00030 00031 namespace ept { 00032 namespace debtags { 00033 00037 class Path 00038 { 00039 public: 00040 static std::string vocabulary(); 00041 static std::string vocabularyIndex(); 00042 static std::string userVocabulary(); 00043 static std::string userVocabularyIndex(); 00044 static std::string tagdb(); 00045 static std::string tagdbIndex(); 00046 static std::string userTagdb(); 00047 static std::string userTagdbIndex(); 00048 static std::string pkgidx(); 00049 static std::string userPkgidx(); 00050 00051 static std::string debtagsSourceDir(); 00052 static std::string debtagsIndexDir(); 00053 static std::string debtagsUserSourceDir(); 00054 static std::string debtagsUserIndexDir(); 00055 00056 // Directory where Debtags source data is found 00057 static void setDebtagsSourceDir( const std::string &s ); 00058 00059 // Directory where Debtags indexes are kept 00060 static void setDebtagsIndexDir( const std::string &s ); 00061 00062 // User-specific directory for Debtags source data 00063 static void setDebtagsUserSourceDir( const std::string &s ); 00064 00065 // User-specific directory for Debtags index data 00066 static void setDebtagsUserIndexDir( const std::string &s ); 00067 00068 static int access( const std::string &, int ); 00069 static time_t timestamp( const std::string& ); 00070 00071 // RAII-style classes to temporarily override directories 00072 class OverrideDebtagsSourceDir 00073 { 00074 std::string old; 00075 public: 00076 OverrideDebtagsSourceDir(const std::string& path) : old(Path::debtagsSourceDir()) 00077 { 00078 Path::setDebtagsSourceDir(path); 00079 } 00080 ~OverrideDebtagsSourceDir() { Path::setDebtagsSourceDir(old); } 00081 }; 00082 class OverrideDebtagsIndexDir 00083 { 00084 std::string old; 00085 public: 00086 OverrideDebtagsIndexDir(const std::string& path) : old(Path::debtagsIndexDir()) 00087 { 00088 Path::setDebtagsIndexDir(path); 00089 } 00090 ~OverrideDebtagsIndexDir() { Path::setDebtagsIndexDir(old); } 00091 }; 00092 class OverrideDebtagsUserSourceDir 00093 { 00094 std::string old; 00095 public: 00096 OverrideDebtagsUserSourceDir(const std::string& path) : old(Path::debtagsUserSourceDir()) 00097 { 00098 Path::setDebtagsUserSourceDir(path); 00099 } 00100 ~OverrideDebtagsUserSourceDir() { Path::setDebtagsUserSourceDir(old); } 00101 }; 00102 class OverrideDebtagsUserIndexDir 00103 { 00104 std::string old; 00105 public: 00106 OverrideDebtagsUserIndexDir(const std::string& path) : old(Path::debtagsUserIndexDir()) 00107 { 00108 Path::setDebtagsUserIndexDir(path); 00109 } 00110 ~OverrideDebtagsUserIndexDir() { Path::setDebtagsUserIndexDir(old); } 00111 }; 00112 protected: 00113 static Path *s_instance; 00114 static Path &instance(); 00115 00116 // Directory where Debtags source data is found 00117 std::string m_debtagsSourceDir; 00118 00119 // Directory where Debtags indexes are kept 00120 std::string m_debtagsIndexDir; 00121 00122 // User-specific directory for Debtags source data 00123 std::string m_debtagsUserSourceDir; 00124 00125 // User-specific directory for Debtags index data 00126 std::string m_debtagsUserIndexDir; 00127 }; 00128 00129 } 00130 } 00131 00132 // vim:set ts=4 sw=4: 00133 #endif