void CFiles::GetFileNames(CMapStringInt* pcFileNames) { CFileIterator cIter; CFileIteratorReturn* pcReturn; int* piValue; int iRank; pcReturn = StartIteration(&cIter); while (pcReturn) { piValue = pcFileNames->Get(pcReturn->GetFullName()); if (!piValue) { iRank = pcReturn->GetFileRank() << 16; pcFileNames->Put(pcReturn->GetFullName(), iRank + 1); } else { iRank = (*piValue) >> 16; if (iRank < pcReturn->GetFileRank()) { iRank = pcReturn->GetFileRank() << 16; *piValue = iRank | (*piValue & 0xFFFF); } (*piValue)++; } pcReturn = Iterate(&cIter); } StopIteration(&cIter); }
types::str file::next() { if (not is_open) throw ValueError("I/O operation on closed file"); if (feof(**data) && mode.find_first_of("ra") == -1) // If we are at eof on reading mode throw exception throw StopIteration("file.next() : EOF reached."); return readline(); }
double PixelIterator::__next__(){ Ilwis::PixelIterator& iter = this->ptr(); if (iter.linearPosition() != this->_endposition){ double d = (*iter); ++iter; return d; }else{ throw StopIteration(); } }
void CPackFiles::GetFiles(CArrayPackFileNodePtrs* pcPackFiles) { CPackFileIterator cIter; CFileNodePackFileNode* pcFile; pcFile = StartIteration(&cIter); while (pcFile) { pcPackFiles->Add(&pcFile); pcFile = Iterate(&cIter); } StopIteration(&cIter); }
template<typename OutputType, typename RangeType, typename IlwOutput, typename IlwRange> OutputType RangeIterator<OutputType, RangeType, IlwOutput, IlwRange>::__next__(){ Ilwis::RangeIterator<IlwOutput, IlwRange>& iter = this->ptr(); if (iter.isValid()){ IlwOutput t = (*iter); ++iter; return t; // OutputType o = t; // DomainItem tempDI; // if(TypeIsDouble<OutputType>::value) // return t; // else // tempDI(o); // return o; }else{ throw StopIteration(); } }
I_Disk_Location_Ptr Directory::NextItem( void ) { I_Disk_Location_Ptr pLocation = nullptr; #if FBL_WIN WIN32_FIND_DATAW FileData; if ( mStarted ) { if ( !::FindNextFileW( mDirent, &FileData) ) StopIteration(); } else { if ( mDirent ) StopIteration(); String file_path( mpLocation->get_Path()); if( file_path.charAt( file_path.length()-1 ) != I_Disk_Location::sPathDelimiterU ) file_path += I_Disk_Location::sPathDelimiterU; file_path += "*"; mDirent = ::FindFirstFileW( file_path.c_str(), &FileData ); if ( mDirent == INVALID_HANDLE_VALUE ) mDirent = NULL; else mStarted = true; } if ( mDirent ) { String file_path( mpLocation->get_Path() ); if( file_path.charAt( file_path.length()-1 ) != I_Disk_Location::sPathDelimiterU ) file_path += I_Disk_Location::sPathDelimiterU; file_path += FileData.cFileName; pLocation = fbl_dynamic_cast<I_Disk_Location>(CreateDiskLocation( file_path.c_str() ) ); } #endif // FBL_WIN #if FBL_POSIX_API dirent* pDirent = ::readdir( mDirent ); if( pDirent ) { String file_path( mpLocation->get_Path().c_str() ); if( file_path.charAt( file_path.length()-1 ) != I_Disk_Location::sPathDelimiterU ) file_path += Location::sPathDelimiterU; file_path += pDirent->d_name; pLocation = new Location( file_path.c_str() ); pLocation->put_IsDirectory( bool(pDirent->d_type == DT_DIR) ); } #endif // FBL_POSIX_API #if FBL_MAC && !FBL_MAC_MACHO bool IsDirectory; Str255 pasName; ((DirData*) mDirent)->Read( pasName, IsDirectory ); if( pasName[0] > 0 ) { Location_Disk_FSSpec_Ptr pLocSpec = fbl_dynamic_cast<Location_Disk_FSSpec>(mpLocation); const FSSpec* pThisDirectory = pLocSpec->get_FSSpec(); FSSpec childSpec; FSMakeFSSpec( pThisDirectory->vRefNum, ((DirData*) mDirent)->GetDirID(), pasName, &childSpec ); pLocation = CreateDiskLocationFromFSSpec( &childSpec ); pLocation->put_IsDirectory( IsDirectory ); } #endif // FBL_MAC && !FBL_MAC_MACHO return pLocation; }
Directory::~Directory( void ) { StopIteration(); }