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 #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 static std::string index(); 00042 00043 // Directory where Popcon source data is found 00044 static void setIndexDir( const std::string &s ); 00045 00046 static int access( const std::string &, int ); 00047 static time_t indexTimestamp(); 00048 static void setTimestamp(time_t ts); 00049 00050 // RAII-style classes to temporarily override directories 00051 class OverrideIndexDir 00052 { 00053 std::string old; 00054 public: 00055 OverrideIndexDir(const std::string& path) : old(Path::indexDir()) 00056 { 00057 Path::setIndexDir(path); 00058 } 00059 ~OverrideIndexDir() { Path::setIndexDir(old); } 00060 }; 00061 00062 protected: 00063 static Path *s_instance; 00064 static Path &instance(); 00065 00066 // Directory where Popcon source data is found 00067 std::string m_indexDir; 00068 }; 00069 00070 } 00071 } 00072 00073 // vim:set ts=4 sw=4: 00074 #endif