⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directory.cpp

📁 这是VCF框架的代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		// resetting the existing finder		finder_->reset();		finder_->owningDirectory_				= this;		filterFileObject = finder_->getSearchFilterFileObject();		FileSearchFilterStandard* filterFileObjectStandard = dynamic_cast<FileSearchFilterStandard*>( filterFileObject );		if ( NULL != filterFileObjectStandard ) {			if ( filterFileObjectStandard->basenameFilterList_ != basenameFilterList || 				   filterFileObjectStandard->pathnameFilterList_ != pathnameFilterList ) {				filterFileObjectStandard->buildSearchFilters( basenameFilterList, pathnameFilterList );			}		} else {			delete filterFileObject;			filterFileObject = new FileSearchFilterStandard( basenameFilterList, pathnameFilterList );		}	}	*/	result = findFiles( filterFileObject, true );	return result;}Directory::Finder* Directory::findFiles( FileSearchFilter* filterFileObject/*=NULL*/, const bool& ownFilterFileObject/*=false*/ ){	Directory::Finder* result = NULL;	if ( FilePath::isRelativePath( fileName_ ) ) {		String msg = Format("Please provide a full path name to the directory when performing a file search.\nPath: %s") % fileName_;		throw BasicException( MAKE_ERROR_MSG_2( msg ) );	}	//if ( NULL == finder_ ) {		result = new Directory::Finder( this, filterFileObject, ownFilterFileObject );		if ( NULL == result ) {			throw NoFreeMemException();		}		/*	} else {		finder_->reset();		finder_->owningDirectory_				= this;		finder_->setSearchFilterFileObject( filterFileObject, ownFilterFileObject );	}*/		return result;}File* Directory::Finder::getCurrentElement() const{	return currentElement_;}bool Directory::Finder::nextElement(){	// continues the search until a valid element is found 	// or the search is completed along all the allowed subdirectories	while( true )	{		FilePeer* dirPeer = rootSearchFinder_->activeFinder_->owningDirectory_->getPeer();		if ( !rootSearchFinder_->activeFinder_->searchHasMoreElements_ ) {			dirPeer->initFileSearch( this );		}		// attention: this will change the activeFinder_ if it changes subdirectory level		currentElement_ = dirPeer->findNextFileInSearch( rootSearchFinder_->activeFinder_ );		// normally breaks and return the file/dir found to the user		if ( currentElement_ ) {			// if we want to display only files or directories names			if ( ( currentElement_->isDirectory() && Directory::Finder::dmFiles == rootSearchFinder_->displayMode_ ) ||				   ( !currentElement_->isDirectory() && Directory::Finder::dmDirs == rootSearchFinder_->displayMode_ ) ) {				searchHasMoreElements_ = true;				continue;			} 			else {				break;			}		} 		else {			// otherwise it continues ...			// ... only when we are switching subdirectory during the recursion, 			// or changing search mode between dmDirs and dmFiles			if ( !rootSearchFinder_->activeFinder_->goSearchAgain_ ) {				break;			}		}	}	searchHasMoreElements_ = ( NULL != currentElement_ );	return searchHasMoreElements_;}///////////////////////////////////////////////////////////////////////////////// DirectoryDirectory::Directory( const String& fileName ): File( FilePath::makeDirectoryName( fileName ) ){	}Directory::Directory( const FilePath& filePath ): File( FilePath::makeDirectoryName( filePath.getFileName() ) ){	}Directory::~Directory(){}///////////////////////////////////////////////////////////////////////////////// FileSearchFilterStandardFileSearchFilterStandard::FileSearchFilterStandard( const String& basenameFilterList, const String& pathnameFilterList/*=L""*/, const String& separator/*=L";"*/ ){		buildSearchFilters( basenameFilterList, pathnameFilterList, separator );}void FileSearchFilterStandard::buildSearchFilters( const String& basenameFilterList, const String& pathnameFilterList/*=L""*/, const String& separator/*=L";"*/ ){	basenameFilterList_ = basenameFilterList;	pathnameFilterList_ = pathnameFilterList;	separator_          = separator;	searchFiltersBasename_.clear();	if ( !basenameFilterList.empty() ) {		size_t pos = 0, lastpos = 0;		while ( String::npos != pos ) {			pos = basenameFilterList.find( separator_, lastpos );			if ( String::npos != pos ) {				searchFiltersBasename_.push_back( basenameFilterList.substr( lastpos, pos-lastpos ) );				lastpos = pos + 1;			}		};		searchFiltersBasename_.push_back( basenameFilterList.substr( lastpos, basenameFilterList.size() ) );	}	searchFiltersPathname_.clear();	if ( !pathnameFilterList.empty() ) {		String sdir;		size_t pos = 0, lastpos = 0;		while ( String::npos != pos ) {			pos = pathnameFilterList.find( separator_, lastpos );			if ( String::npos != pos ) {				sdir = pathnameFilterList.substr( lastpos, pos );				sdir = FilePath::transformToOSSpecific( sdir );				searchFiltersPathname_.push_back( sdir );				lastpos = pos + 1;			}		};		sdir = pathnameFilterList.substr( lastpos, pathnameFilterList.size() );		sdir = FilePath::transformToOSSpecific( sdir );		searchFiltersPathname_.push_back( sdir );	}}File* FileSearchFilterStandard::passSearchFilter( const File* file, const Directory* subdir, const Directory::Finder* finder ){	/*	* The user is allowed to assume that all these arguments are never NULL.	* this function must return NULL if it does not pass the filter !	* All arguments are const to make sure the user knows what is doing.	*/	if ( 0 == searchFiltersBasename_.size() && 0 == searchFiltersPathname_.size() ) {		return const_cast<File*>( file );	}	// Do not perform any fitering on directories 	// otherwise we cannot recurse into any subdirectories	// Use Finder::dmFiles instead if you want to find only files.	bool isDir = const_cast<File*>(file)->isDirectory();	if ( isDir ) {		return const_cast<File*>( file );	}	String sf;	bool pass = false;	if ( 0 == searchFiltersBasename_.size() ) {		pass = true;	} else {		searchFilterIterator_ = searchFiltersBasename_.begin();		while ( searchFilterIterator_ != searchFiltersBasename_.end() ) {			sf = *searchFilterIterator_ ++;			if ( FilePath::wildCharsMatchName( file->getName(), sf ) ) {				pass = true;				break;			}		}	}	if ( pass ) {		// no filter on path when no recursing		if ( finder->getRecurse() ) {			pass = false;			if ( 0 == searchFiltersPathname_.size() ) {				pass = true;			} else {				String path = subdir->getName();				if ( finder->getKeepOSSpecificFormat() ) {					path = FilePath::transformToOSSpecific( path );				} else {					path = FilePath::transformToNative( path );				}				searchFilterIterator_ = searchFiltersPathname_.begin();				while ( searchFilterIterator_ != searchFiltersPathname_.end() ) {					sf = *searchFilterIterator_ ++;										size_t pos = subdir->getName().find( sf );					if ( String::npos != pos ) {						pass = true;						break;					}				}			}		}	}	if ( pass ) {		return const_cast<File*>( file );	} else {		return NULL;	}	return const_cast<File*>( file );}/***CVS Log info*$Log$*Revision 1.5  2006/04/07 02:35:34  ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.4.2.2  2006/01/22 14:24:12  ddiego*updated to add case insens str compare.**Revision 1.4.2.1  2005/11/10 02:02:38  ddiego*updated the osx build so that it*compiles again on xcode 1.5. this applies to the foundationkit and graphicskit.**Revision 1.4  2005/07/09 23:15:02  ddiego*merging in changes from devmain-0-6-7 branch.**Revision 1.3  2005/01/02 03:04:22  ddiego*merged over some of the changes from the dev branch because they're important resoource loading bug fixes. Also fixes a few other bugs as well.**Revision 1.2.4.5  2005/06/02 15:21:23  marcelloptr*minor fix**Revision 1.2.4.4  2005/03/15 01:51:51  ddiego*added support for Format class to take the place of the*previously used var arg funtions in string utils and system. Also replaced*existing code in the framework that made use of the old style var arg*functions.**Revision 1.2.4.3  2005/02/16 17:08:40  marcelloptr*improved an error message**Revision 1.2.4.1  2004/12/10 22:32:42  ddiego*fixed bug in the Win32 file peer class that was not properly*creating directories.**Revision 1.2  2004/08/07 02:49:13  ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.6  2004/07/23 00:56:37  ddiego*added the latest changes to the File and Directory finder classes.**Revision 1.1.2.5  2004/07/20 02:03:13  ddiego*fixed some miscellaneous bugs in directory search code. Many*thanks to Marcello for helping out on this.**Revision 1.1.2.4  2004/07/19 04:08:53  ddiego*more files and directories integration. Added Marcello's Directories example as well**Revision 1.1.2.3  2004/07/18 14:45:19  ddiego*integrated Marcello's new File/Directory API changes into both*the FoundationKit and the ApplicationKit. Many, many thanks go out*to Marcello for a great job with this. This adds much better file searching*capabilities, with many options for how to use it and extend it in the*future.**Revision 1.1.2.2  2004/04/29 04:07:07  marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1  2004/04/28 03:29:39  ddiego*migration towards new directory structure**Revision 1.7.2.1  2004/04/21 02:17:26  ddiego*checking in change to FoundationKit, GraphicsKit and Application*Kit to support unicode in Win32**Revision 1.7  2004/04/03 15:48:48  ddiego*Merged over code from the 0-6-3 branch.**Revision 1.6.2.1  2004/03/19 21:25:57  ddiego*just some minor noodlin**Revision 1.6  2003/12/18 05:16:02  ddiego*merge from devmain-0-6-2 branch into the stable branch**Revision 1.5.4.3  2003/09/27 14:57:24  marcelloptr*bugfix [813573] Directory ctor adds one separator too much**Revision 1.5.4.2  2003/08/25 03:46:38  ddiego*some fixes to some of the stream impls**Revision 1.5.4.1  2003/08/22 04:39:18  ddiego*minor improvemtn to Diretory constructor, fixed bug in DefaultTableCellItem**Revision 1.5  2003/05/17 20:37:24  ddiego*this is the checkin for the 0.6.1 release - represents the merge over from*the devmain-0-6-0 branch plus a few minor bug fixes**Revision 1.4.16.2  2003/03/23 03:23:56  marcelloptr*3 empty lines at the end of the files**Revision 1.4.16.1  2003/03/12 03:12:09  ddiego*switched all member variable that used the "m_"<name> prefix to* <name>"_" suffix nameing standard.*Also changed all vcf builder files to accomadate this.*Changes were made to the Stream classes to NOT multiple inheritance and to*be a little more correct. Changes include breaking the FileStream into two*distinct classes, one for input and one for output.**Revision 1.4  2002/05/09 03:10:44  ddiego*merged over code from development branch devmain-0-5-1a into the main CVS trunk**Revision 1.3.4.1  2002/03/20 21:56:56  zzack*Changed Include Style of FoundationKit**Revision 1.3  2002/01/24 01:46:49  ddiego*added a cvs "log" comment to the top of all files in vcf/src and vcf/include*to facilitate change tracking**/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -