Пример #1
0
static bool MatchAlias(const char *s, const char *t, Vector<String>& a)
{
	while(*t)
		switch(*t++)
		{
		case '*':
			{
				const char *b = s;
				do
				{
					a.Add(String(b, s));
					if(MatchAlias(s, t, a))
						return true;
					a.Drop();
				}
				while(*s++);
				return false;
			}

		default:
			if(t[-1] != *s++)
				return false;
			break;
		}
	return !*s;
}
Пример #2
0
	static PGPError
sImportProc(
	PFLFileSpecRef		ref,
	PGPByte const *		data,
	PGPSize				dataSize )
{
	const ExportedFileSpec *	exportedData;
	MyData *					newData	= NULL;
	PGPError					err	= kPGPError_NoErr;

	(void) dataSize;
	
	exportedData	= (const ExportedFileSpec *)data;
	newData			= GetMyData( ref );
	
	err	= PGPReallocData( ref->memoryMgr,
			&newData, sizeof( *newData ), 0 );
	if ( IsntPGPError( err ) )
	{
		MyData *		myData	= (MyData *)newData;
		
		ref->data		= (PGPByte *)newData;
		ref->dataSize	= sizeof( *newData );
		
		myData->specIsValid 	= FALSE;
		
		CopyPString( exportedData->name, myData->spec.name );
		
		if( exportedData->aliasDataSize != 0 )
		{
			AliasHandle	alias;
			
			if( PtrToHand( &exportedData->aliasData[0], (Handle *) &alias,
						exportedData->aliasDataSize ) == noErr )
			{
				FSSpec	spec;
				short	aliasCount = 1;
				Boolean	needsUpdate;
				
				if( MatchAlias( NULL, kARMNoUI | kARMSearch,
						alias, &aliasCount, &spec, &needsUpdate, NULL, NULL ) == noErr )
				{
					CInfoPBRec	cpb;
					
					if( FSpGetCatInfo( &spec, &cpb ) == noErr )
					{
						myData->specIsValid = TRUE;
					
						myData->spec.vRefNum 	= spec.vRefNum;
						myData->spec.parID 		= cpb.dirInfo.ioDrDirID;
					}
				}
				
				DisposeHandle( (Handle) alias );
			}
		}
	}
	
	return( err );
}
Пример #3
0
String AliasMap::Convert(const String& name) const
{
	for(int i = 0; i < obj_source.GetCount(); i++)
	{
		Vector<String> args;
		if(MatchAlias(name, obj_source[i], args))
		{
			const char *s = obj_dest[i];
			String out;
			while(*s)
				if(*s == '@' && (s[1] >= '1' && s[1] < '1' + min(args.GetCount(), 10)))
				{
					s += 2;
					out.Cat(args[s[-1] - '1']);
				}
				else
					out.Cat(*s++);
			return out;
		}
	}
	return name;
}