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 #ifndef EPT_TEXTSEARCH_PATH_H 00025 #define EPT_TEXTSEARCH_PATH_H 00026 00027 #include <string> 00028 00029 struct stat; 00030 00031 namespace ept { 00032 namespace textsearch { 00033 00037 class Path 00038 { 00039 public: 00040 static std::string indexDir(); 00041 00042 // Directory where Popcon source data is found 00043 static void setIndexDir( const std::string &s ); 00044 00045 static int access( const std::string &, int ); 00046 static time_t indexTimestamp(); 00047 static void setTimestamp(time_t ts); 00048 00049 // RAII-style classes to temporarily override directories 00050 class OverrideIndexDir 00051 { 00052 std::string old; 00053 public: 00054 OverrideIndexDir(const std::string& path) : old(Path::indexDir()) 00055 { 00056 Path::setIndexDir(path); 00057 } 00058 ~OverrideIndexDir() { Path::setIndexDir(old); } 00059 }; 00060 00061 protected: 00062 static Path *s_instance; 00063 static Path &instance(); 00064 00065 // Directory where Popcon source data is found 00066 std::string m_indexDir; 00067 }; 00068 00069 } 00070 } 00071 00072 // vim:set ts=4 sw=4: 00073 #endif