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_Directory 00008 #define _lucene_store_Directory 00009 00010 00011 #include "CLucene/util/VoidMapSetDefinitions.h" 00012 #include "CLucene/LuceneThreads.h" 00013 #include <string> 00014 00015 CL_CLASS_DEF(store,Lock) 00016 CL_CLASS_DEF(store,IndexInput) 00017 CL_CLASS_DEF(store,IndexOutput) 00018 CL_CLASS_DEF(store,LockFactory) 00019 CL_CLASS_DEF(store,LuceneLock) 00020 00021 CL_NS_DEF(store) 00022 00035 class CLUCENE_EXPORT Directory: LUCENE_REFBASE { 00036 protected: 00037 LockFactory* lockFactory; 00038 00039 Directory(){ 00040 } 00041 // Removes an existing file in the directory. 00042 virtual bool doDeleteFile(const char* name) = 0; 00043 public: 00044 DEFINE_MUTEX(THIS_LOCK) 00045 00046 virtual ~Directory(); 00047 00048 // Returns an null terminated array of strings, one for each file in the directory. 00049 char** list() const; 00050 virtual void list(std::vector<std::string>* names) const = 0; 00051 00052 // Returns true iff a file with the given name exists. 00053 virtual bool fileExists(const char* name) const = 0; 00054 00055 // Returns the time the named file was last modified. 00056 virtual int64_t fileModified(const char* name) const = 0; 00057 00058 // Returns the length of a file in the directory. 00059 virtual int64_t fileLength(const char* name) const = 0; 00060 00061 // Returns a stream reading an existing file. 00062 virtual IndexInput* openInput(const char* name) = 0; 00063 virtual IndexInput* openInput(const char* name, int32_t bufferSize); 00064 00066 virtual void touchFile(const char* name) = 0; 00067 00068 // Removes an existing file in the directory. 00069 virtual bool deleteFile(const char* name, const bool throwError=true); 00070 00071 // Renames an existing file in the directory. 00072 // If a file already exists with the new name, then it is replaced. 00073 // This replacement should be atomic. 00074 virtual void renameFile(const char* from, const char* to) = 0; 00075 00076 // Creates a new, empty file in the directory with the given name. 00077 // Returns a stream writing this file. 00078 virtual IndexOutput* createOutput(const char* name) = 0; 00079 00080 // Construct a {@link Lock}. 00081 // @param name the name of the lock file 00082 virtual LuceneLock* makeLock(const char* name); 00083 00084 virtual void clearLock(const char* name); 00085 00086 // Closes the store. 00087 virtual void close() = 0; 00088 00089 virtual TCHAR* toString() const = 0; 00090 00091 virtual const char* getDirectoryType() const = 0; 00092 00093 void setLockFactory( LockFactory* lockFactory ); 00094 00095 LockFactory* getLockFactory(); 00096 00097 virtual TCHAR* getLockID(); 00098 }; 00099 CL_NS_END 00100 #endif