| 
									
										
										
										
											2019-05-27 09:26:54 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-06 15:34:26 +02:00
										 |  |  | #include <AK/String.h>
 | 
					
						
							| 
									
										
										
										
											2019-05-28 11:53:16 +02:00
										 |  |  | #include <dirent.h>
 | 
					
						
							| 
									
										
										
										
											2019-05-27 09:26:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class CDirIterator { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-06-07 17:13:23 +02:00
										 |  |  |     enum Flags { | 
					
						
							| 
									
										
										
										
											2019-05-27 09:26:54 +02:00
										 |  |  |         NoFlags = 0x0, | 
					
						
							|  |  |  |         SkipDots = 0x1, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-02 12:26:28 +02:00
										 |  |  |     CDirIterator(const StringView& path, Flags = Flags::NoFlags); | 
					
						
							| 
									
										
										
										
											2019-05-27 09:26:54 +02:00
										 |  |  |     ~CDirIterator(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool has_error() const { return m_error != 0; } | 
					
						
							|  |  |  |     int error() const { return m_error; } | 
					
						
							|  |  |  |     const char* error_string() const { return strerror(m_error); } | 
					
						
							|  |  |  |     bool has_next(); | 
					
						
							|  |  |  |     String next_path(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     DIR* m_dir = nullptr; | 
					
						
							|  |  |  |     int m_error = 0; | 
					
						
							|  |  |  |     String m_next; | 
					
						
							|  |  |  |     int m_flags; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool advance_next(); | 
					
						
							|  |  |  | }; |