- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

ufilearchive.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/util/ufilearchive.hpp 00008 begin : Sat Jan 26 2002 00009 $Id: ufilearchive.hpp,v 1.10 2005/10/17 15:34:49 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UFILEARCHIVE_HPP 00029 #define UFILEARCHIVE_HPP 00030 00031 #include "../uobject.hpp" 00032 00033 #include <vector> 00034 #include <fstream> 00035 00036 namespace ufo { 00037 00048 class UFO_EXPORT UFileArchive : public UObject { 00049 UFO_DECLARE_DYNAMIC_CLASS(UFileArchive) 00050 public: // Public static methods 00055 static bool exists(const std::string & fileName); 00059 static std::vector<std::string> readDir(const std::string & path); 00060 00068 static std::string dirName(const std::string & path); 00069 00073 static bool isDirectory(const std::string & path); 00074 00075 static UFileArchive * getDefault(); 00076 static void setDefault(UFileArchive * archive); 00077 00078 public: // c'tors 00080 UFileArchive(); 00082 UFileArchive(const std::string & searchPath); 00083 00084 public: // Public methods 00086 void addArchive(const std::string & arc); 00088 bool removeArchive(const std::string & arc); 00090 void removeAllArchives(); 00091 00093 void addSearchPath(const std::string & searchPath); 00098 std::string getSearchPath() const; 00102 std::vector<std::string> getSearchPathAsVector() const; 00103 00108 bool existsInArchive(const std::string & fileName); 00109 00114 std::string getAbsolutePath(const std::string & fileName) const; 00115 00116 private: // Private static methods 00117 static UFileArchive * createInstance(); 00118 00119 private: // Private static attributes 00120 static UFileArchive * sm_instance; 00121 00122 private: // Private attributes 00123 std::vector<std::string> m_archives; 00124 }; 00125 00126 inline UFileArchive * 00127 UFileArchive::getDefault() { 00128 if (!sm_instance) { 00129 sm_instance = createInstance(); 00130 } 00131 return sm_instance; 00132 } 00133 00134 inline void 00135 UFileArchive::setDefault(UFileArchive * instance) { 00136 if (instance) { 00137 sm_instance = instance; 00138 } 00139 } 00140 00141 } // namespace ufo 00142 00143 #endif // UFILEARCHIVE_HPP

The libUFO Project - written by Johannes Schmidt