Esempio n. 1
0
pascal Boolean findImageFilterProc(AEDesc* theItem, void* info, 
                            NavCallBackUserData callBackUD,
                            NavFilterModes filterMode)
{
#pragma unused(filterMode,callBackUD)
    NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*)info;
    
    if (theItem->descriptorType == typeFSRef) {
        char checkSuffix[256],pathName[1024];
        OSErr 	error;
        Boolean check;
		FSRef theFSRef;
		
        if (theInfo->isFolder)
            return true;
            
        if (theInfo->fileAndFolder.fileInfo.finderInfo.fdType == 'STim')
            return true;
            
        error = AEGetDescData(theItem,&theFSRef,sizeof(FSRef));
		if (error != noErr) 
            return true;
		PathToFileViaFSRef(pathName, 1024, &theFSRef,kCFStringEncodingUTF8);
		getLastPathComponentInCurrentEncoding(pathName,checkSuffix,kCFStringEncodingUTF8);        
        check = IsImageName(checkSuffix);

        if (check) 
            return true;
        else {
           return false;
		}
    }
    return true;
}
void resolveWhatTheImageNameIs(char *guess)  
{
	char possibleImageName[DOCUMENT_NAME_SIZE+1],  fullPath [DOCUMENT_NAME_SIZE+1],  lastPath [SHORTIMAGE_NAME_SIZE+1];
	FSRef		theFSRef;
	OSErr		err;
	
	strncpy(possibleImageName, guess,DOCUMENT_NAME_SIZE);
	err = getFSRef(possibleImageName,&theFSRef,kCFStringEncodingUTF8);
	if (err) {
		SetImageNameViaString("",gCurrentVMEncoding);
		SetShortImageNameViaString("",gCurrentVMEncoding);
		return;
	}
	PathToFileViaFSRef(fullPath,DOCUMENT_NAME_SIZE, &theFSRef,gCurrentVMEncoding);
	getLastPathComponentInCurrentEncoding(fullPath,lastPath,gCurrentVMEncoding);
	SetImageNameViaString(fullPath,gCurrentVMEncoding);
	SetShortImageNameViaString(lastPath,gCurrentVMEncoding);
}