Tanl Linguistic Pipeline |
00001 /* 00002 ** IXE 00003 ** io/FileEnum.h: enumerate files. 00004 ** ---------------------------------------------------------------------- 00005 ** Copyright (c) 2010 Giuseppe Attardi (attardi@di.unipi.it). 00006 ** ---------------------------------------------------------------------- 00007 ** 00008 ** This file is part of Tanl. 00009 ** 00010 ** Tanl is free software; you can redistribute it and/or modify it 00011 ** under the terms of the GNU General Public License, version 3, 00012 ** as published by the Free Software Foundation. 00013 ** 00014 ** Tanl 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, see <http://www.gnu.org/licenses/>. 00021 ** ---------------------------------------------------------------------- 00022 */ 00023 00024 #ifndef IXE_io_FileEnum_H 00025 #define IXE_io_FileEnum_H 00026 00027 // local 00028 #include "File.h" 00029 00030 // standard 00031 #include <vector> 00032 #include <dirent.h> // for DIR, opendir(), readdir() 00033 00034 namespace IXE { 00035 00036 struct FileEnum 00037 { 00038 FileEnum(char const* pathname, 00039 bool recurse_subdirectories = true, 00040 bool follow_symbolic_links = false, 00041 bool verbose = true); 00042 00043 ~FileEnum(); 00044 00045 char const* next(); 00046 00047 private: 00048 std::string pathname; 00049 00050 bool recurse_subdirectories; 00051 bool follow_symbolic_links; 00052 bool verbose; 00053 00054 typedef std::pair<std::string, DIR*> state; 00055 std::vector<state> stack; 00056 }; 00057 00058 } // namespace IXE 00059 00060 #endif // IXE_io_FileEnum_H