示例#1
0
IFile *VirtualFileSystemComponent::GetFile( const wchar_t *logicalPath ) const
{
	if ( !logicalPath ) return _root;

	IFile *node = _root;

	wchar_t *context = 0;
	size_t destinationLength = wcslen( logicalPath ) + 1;
	wchar_t *copy = new wchar_t[destinationLength];
	wcscpy_s( copy, destinationLength, logicalPath );
	wchar_t *components = wcstok_s( copy, L"/", &context );

	while ( components ) {
		node = node->GetChild( components );
		if ( !node ) break;
		components = wcstok_s( 0, L"/", &context );
	}

	delete[] copy;
	return node;//return the node found (if any)
}