----------------------------------------------------------------------------- Purpose: returns true if there is a file to read -----------------------------------------------------------------------------
| 237 | // Purpose: returns true if there is a file to read |
| 238 | //----------------------------------------------------------------------------- |
| 239 | bool CDirIterator::BNextFile() |
| 240 | { |
| 241 | if ( m_bNoFiles ) |
| 242 | return false; |
| 243 | |
| 244 | // use the first result |
| 245 | if ( !m_bUsedFirstFile ) |
| 246 | { |
| 247 | m_bUsedFirstFile = true; |
| 248 | return true; |
| 249 | } |
| 250 | |
| 251 | // find the next item |
| 252 | for ( ;; ) |
| 253 | { |
| 254 | #if defined( _WIN32 ) |
| 255 | bool bFound = ( FindNextFileW( m_hFind, m_pFindData ) != FALSE ); |
| 256 | // Conversion should never fail with valid filenames... |
| 257 | if ( bFound ) |
| 258 | { |
| 259 | m_sFilename = UTF16to8( m_pFindData->cFileName ); |
| 260 | } |
| 261 | #else |
| 262 | bool bFound = ( _findnext( m_hFind, m_pFindData ) == 0 ); |
| 263 | #endif |
| 264 | |
| 265 | if ( !bFound ) |
| 266 | { |
| 267 | // done |
| 268 | m_bNoFiles = true; |
| 269 | return false; |
| 270 | } |
| 271 | |
| 272 | // skip over the '.' and '..' paths |
| 273 | if ( !BValidFilename() ) |
| 274 | continue; |
| 275 | |
| 276 | break; |
| 277 | } |
| 278 | |
| 279 | // have one more file |
| 280 | return true; |
| 281 | } |
| 282 | |
| 283 | |
| 284 | //----------------------------------------------------------------------------- |