CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_store_FSDirectory_ 00008 #define _lucene_store_FSDirectory_ 00009 00010 00011 #include "Directory.h" 00012 #include "IndexInput.h" 00013 #include "IndexOutput.h" 00014 #include <string> 00015 #include <vector> 00016 00017 //#include "Lock.h" 00018 //#include "LockFactory.h" 00019 //#include "CLucene/util/VoidMap.h" 00020 CL_CLASS_DEF(util,StringBuffer) 00021 00022 CL_NS_DEF(store) 00023 00031 class CLUCENE_EXPORT FSDirectory:public Directory{ 00032 private: 00033 class FSIndexOutput; 00034 class FSIndexInput; 00035 friend class FSDirectory::FSIndexOutput; 00036 friend class FSDirectory::FSIndexInput; 00037 00038 protected: 00039 FSDirectory(const char* path, const bool createDir, LockFactory* lockFactory=NULL); 00040 private: 00041 char* directory; 00042 char* lockDir; 00043 int refCount; 00044 void create(); 00045 00046 static const char* LOCK_DIR; 00047 static const char* getLockDir(); 00048 char* getLockPrefix() const; 00049 static bool disableLocks; 00050 00051 void priv_getFN(char* buffer, const char* name) const; 00052 bool useMMap; 00053 00054 protected: 00056 bool doDeleteFile(const char* name); 00057 00058 public: 00062 ~FSDirectory(); 00063 00065 void list(std::vector<std::string>* names) const; 00066 00068 bool fileExists(const char* name) const; 00069 00071 const char* getDirName() const; 00072 00073 00088 static FSDirectory* getDirectory(const char* file, const bool create, LockFactory* lockFactory=NULL); 00089 00091 int64_t fileModified(const char* name) const; 00092 00093 //static 00095 static int64_t fileModified(const char* dir, const char* name); 00096 00097 //static 00099 int64_t fileLength(const char* name) const; 00100 00102 IndexInput* openInput(const char* name); 00103 IndexInput* openInput(const char* name, int32_t bufferSize); 00104 00105 IndexInput* openMMapFile(const char* name, int32_t bufferSize=LUCENE_STREAM_BUFFER_SIZE); 00106 00108 void renameFile(const char* from, const char* to); 00109 00111 void touchFile(const char* name); 00112 00115 IndexOutput* createOutput(const char* name); 00116 00120 void close(); 00121 00126 void setUseMMap(bool value){ useMMap = value; } 00130 bool getUseMMap() const{ return useMMap; } 00131 00132 TCHAR* toString() const; 00133 00134 static const char* DirectoryType(){ return "FS"; } 00135 const char* getDirectoryType() const{ return "FS"; } 00136 00142 static void setDisableLocks(bool doDisableLocks) { disableLocks = doDisableLocks; } 00143 00148 static bool getDisableLocks() { return disableLocks; } 00149 00150 }; 00151 00152 CL_NS_END 00153 #endif