music/qtmidi.c
changeset 5684 ce630c33116d
parent 5577 0386cf0d8226
equal deleted inserted replaced
5683:dca046ba7aa3 5684:ce630c33116d
    81  *
    81  *
    82  * @param *spec A @c FSSpec structure referencing a file.
    82  * @param *spec A @c FSSpec structure referencing a file.
    83  */
    83  */
    84 static void SetMIDITypeIfNeeded(const FSSpec *spec)
    84 static void SetMIDITypeIfNeeded(const FSSpec *spec)
    85 {
    85 {
    86 	FInfo info;
    86 	FSRef ref;
       
    87 	FSCatalogInfo catalogInfo;
       
    88 
    87 	assert(spec);
    89 	assert(spec);
    88 
    90 
    89 	if (noErr != FSpGetFInfo(spec, &info)) return;
    91 	if (noErr != FSpMakeFSRef(spec, &ref)) return;
    90 
    92 	if (noErr != FSGetCatalogInfo(&ref, kFSCatInfoNodeFlags | kFSCatInfoFinderInfo, &catalogInfo, NULL, NULL, NULL)) return;
    91 	/* Set file type to 'Midi' if the file is _not_ an alias. */
    93 	if (!(catalogInfo.nodeFlags & kFSNodeIsDirectoryMask)) {
    92 	if (info.fdType != midiType && !(info.fdFlags & kIsAlias)) {
    94 		FileInfo * const info = (FileInfo *) catalogInfo.finderInfo;
    93 		info.fdType = midiType;
    95 		if (info->fileType != midiType && !(info->finderFlags & kIsAlias)) {
    94 		FSpSetFInfo(spec, &info);
    96 			OSErr e;
    95 		DEBUG(driver, 3, "qtmidi: changed filetype to 'Midi'");
    97 			info->fileType = midiType;
       
    98 			e = FSSetCatalogInfo(&ref, kFSCatInfoFinderInfo, &catalogInfo);
       
    99 			if (e == noErr) {
       
   100 				DEBUG(driver, 3, "qtmidi: changed filetype to 'Midi'");
       
   101 			} else {
       
   102 				DEBUG(driver, 0, "qtmidi: changing filetype to 'Midi' failed - error %d", e);
       
   103 			}
       
   104 		}
    96 	}
   105 	}
    97 }
   106 }
    98 
   107 
    99 
   108 
   100 /**
   109 /**