(svn r7639) -Fix: FS#487 Changed music/qtmidi.c to not use functions deprecated by Apple (pvz)
authorbjarni
Sat, 30 Dec 2006 11:28:26 +0000
changeset 5684 ce630c33116d
parent 5683 dca046ba7aa3
child 5685 b88aca81aa7b
(svn r7639) -Fix: FS#487 Changed music/qtmidi.c to not use functions deprecated by Apple (pvz)
music/qtmidi.c
--- a/music/qtmidi.c	Sat Dec 30 01:52:09 2006 +0000
+++ b/music/qtmidi.c	Sat Dec 30 11:28:26 2006 +0000
@@ -83,16 +83,25 @@
  */
 static void SetMIDITypeIfNeeded(const FSSpec *spec)
 {
-	FInfo info;
+	FSRef ref;
+	FSCatalogInfo catalogInfo;
+
 	assert(spec);
 
-	if (noErr != FSpGetFInfo(spec, &info)) return;
-
-	/* Set file type to 'Midi' if the file is _not_ an alias. */
-	if (info.fdType != midiType && !(info.fdFlags & kIsAlias)) {
-		info.fdType = midiType;
-		FSpSetFInfo(spec, &info);
-		DEBUG(driver, 3, "qtmidi: changed filetype to 'Midi'");
+	if (noErr != FSpMakeFSRef(spec, &ref)) return;
+	if (noErr != FSGetCatalogInfo(&ref, kFSCatInfoNodeFlags | kFSCatInfoFinderInfo, &catalogInfo, NULL, NULL, NULL)) return;
+	if (!(catalogInfo.nodeFlags & kFSNodeIsDirectoryMask)) {
+		FileInfo * const info = (FileInfo *) catalogInfo.finderInfo;
+		if (info->fileType != midiType && !(info->finderFlags & kIsAlias)) {
+			OSErr e;
+			info->fileType = midiType;
+			e = FSSetCatalogInfo(&ref, kFSCatInfoFinderInfo, &catalogInfo);
+			if (e == noErr) {
+				DEBUG(driver, 3, "qtmidi: changed filetype to 'Midi'");
+			} else {
+				DEBUG(driver, 0, "qtmidi: changing filetype to 'Midi' failed - error %d", e);
+			}
+		}
 	}
 }