UtiLite
0.3.1
A lite utilities library
|
00001 /* 00002 * utilite is a cross-platform library with 00003 * useful utilities for fast and small developing. 00004 * Copyright (C) 2010 Mathieu Labbe 00005 * 00006 * utilite is free library: you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * utilite is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef UDIRECTORY_H 00021 #define UDIRECTORY_H 00022 00023 #include "utilite/UtiLiteExp.h" // DLL export/import defines 00024 00025 #include <string> 00026 #include <vector> 00027 #include <list> 00028 00034 class UTILITE_EXP UDirectory 00035 { 00036 public: 00042 static bool exists(const std::string & dirPath); 00043 00049 static std::string getDir(const std::string & filePath); 00050 00056 static std::string currentDir(bool trailingSeparator = false); 00057 00063 static bool makeDir(const std::string & dirPath); 00064 00070 static bool removeDir(const std::string & dirPath); 00071 00076 static std::string homeDir(); 00077 00081 static std::string separator(); 00082 00083 public: 00090 UDirectory(const std::string & path = "", const std::string & extensions = ""); 00091 UDirectory(const UDirectory & dir); 00092 UDirectory & operator=(const UDirectory & dir); 00093 ~UDirectory(); 00094 00099 void setPath(const std::string & path, const std::string & extensions = ""); 00100 00104 void update(); 00105 00110 bool isValid(); 00111 00116 std::string getNextFileName(); 00117 00123 const std::list<std::string> & getFileNames() const {return fileNames_;} 00124 00128 void rewind(); 00129 00130 private: 00131 std::string path_; 00132 std::vector<std::string> extensions_; 00133 std::list<std::string> fileNames_; 00134 std::list<std::string>::iterator iFileName_; 00135 }; 00136 00137 #endif /* UDIRECTORY_H */