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 userVocabulary(); 00042 static std::string tagdb(); 00043 static std::string userTagdb(); 00044 00045 static std::string debtagsSourceDir(); 00046 static std::string debtagsIndexDir(); 00047 static std::string debtagsUserSourceDir(); 00048 static std::string debtagsUserIndexDir(); 00049 00050 // Directory where Debtags source data is found 00051 static void setDebtagsSourceDir( const std::string &s ); 00052 00053 // Directory where Debtags indexes are kept 00054 static void setDebtagsIndexDir( const std::string &s ); 00055 00056 // User-specific directory for Debtags source data 00057 static void setDebtagsUserSourceDir( const std::string &s ); 00058 00059 // User-specific directory for Debtags index data 00060 static void setDebtagsUserIndexDir( const std::string &s ); 00061 00062 static int access( const std::string &, int ); 00063 static time_t timestamp( const std::string& ); 00064 00065 // RAII-style classes to temporarily override directories 00066 class OverrideDebtagsSourceDir 00067 { 00068 std::string old; 00069 public: 00070 OverrideDebtagsSourceDir(const std::string& path) : old(Path::debtagsSourceDir()) 00071 { 00072 Path::setDebtagsSourceDir(path); 00073 } 00074 ~OverrideDebtagsSourceDir() { Path::setDebtagsSourceDir(old); } 00075 }; 00076 class OverrideDebtagsIndexDir 00077 { 00078 std::string old; 00079 public: 00080 OverrideDebtagsIndexDir(const std::string& path) : old(Path::debtagsIndexDir()) 00081 { 00082 Path::setDebtagsIndexDir(path); 00083 } 00084 ~OverrideDebtagsIndexDir() { Path::setDebtagsIndexDir(old); } 00085 }; 00086 class OverrideDebtagsUserSourceDir 00087 { 00088 std::string old; 00089 public: 00090 OverrideDebtagsUserSourceDir(const std::string& path) : old(Path::debtagsUserSourceDir()) 00091 { 00092 Path::setDebtagsUserSourceDir(path); 00093 } 00094 ~OverrideDebtagsUserSourceDir() { Path::setDebtagsUserSourceDir(old); } 00095 }; 00096 class OverrideDebtagsUserIndexDir 00097 { 00098 std::string old; 00099 public: 00100 OverrideDebtagsUserIndexDir(const std::string& path) : old(Path::debtagsUserIndexDir()) 00101 { 00102 Path::setDebtagsUserIndexDir(path); 00103 } 00104 ~OverrideDebtagsUserIndexDir() { Path::setDebtagsUserIndexDir(old); } 00105 }; 00106 protected: 00107 static Path *s_instance; 00108 static Path &instance(); 00109 00110 // Directory where Debtags source data is found 00111 std::string m_debtagsSourceDir; 00112 00113 // Directory where Debtags indexes are kept 00114 std::string m_debtagsIndexDir; 00115 00116 // User-specific directory for Debtags source data 00117 std::string m_debtagsUserSourceDir; 00118 00119 // User-specific directory for Debtags index data 00120 std::string m_debtagsUserIndexDir; 00121 }; 00122 00123 } 00124 } 00125 00126 // vim:set ts=4 sw=4: 00127 #endif