• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _DEDIRECTORYITERATOR_HPP
2 #define _DEDIRECTORYITERATOR_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Directory iterator.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "deDefs.hpp"
27 #include "deFilePath.hpp"
28 
29 #define DE_DIRITER_WIN32		0
30 #define DE_DIRITER_POSIX		1
31 
32 #if (DE_OS == DE_OS_WIN32 && DE_COMPILER == DE_COMPILER_MSC)
33 #	define DE_DIRITER DE_DIRITER_WIN32
34 #elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_WIN32 && DE_COMPILER == DE_COMPILER_CLANG)
35 #	define DE_DIRITER DE_DIRITER_POSIX
36 #endif
37 
38 #if !defined(DE_DIRITER)
39 #	error Implement tcu::DirectoryIterator for your platform.
40 #endif
41 
42 #if (DE_DIRITER == DE_DIRITER_WIN32)
43 #	include <io.h> /* _finddata32_t */
44 #elif (DE_DIRITER == DE_DIRITER_POSIX)
45 #	include <sys/types.h>
46 #	include <dirent.h>
47 #endif
48 
49 namespace de
50 {
51 
52 class DirectoryIterator
53 {
54 public:
55 							DirectoryIterator		(const FilePath& path);
56 							~DirectoryIterator		(void);
57 
58 	FilePath				getItem					(void) const;
59 	bool					hasItem					(void) const;
60 	void					next					(void);
61 
62 private:
63 							DirectoryIterator		(const DirectoryIterator& other);
64 	DirectoryIterator&		operator=				(const DirectoryIterator& other);
65 
66 	FilePath				m_path;
67 
68 #if (DE_DIRITER == DE_DIRITER_WIN32)
69 	void					skipCurAndParent		(void);
70 
71 	bool					m_hasItem;
72 	deIntptr				m_handle;
73 	struct _finddata32_t	m_fileInfo;
74 
75 #elif (DE_DIRITER == DE_DIRITER_POSIX)
76 	DIR*					m_handle;
77 	struct dirent*			m_curEntry;
78 #endif
79 };
80 
81 } // de
82 
83 #endif // _DEDIRECTORYITERATOR_HPP
84