diff options
author | egladil <egladil@openttd.org> | 2007-11-07 21:35:33 +0000 |
---|---|---|
committer | egladil <egladil@openttd.org> | 2007-11-07 21:35:33 +0000 |
commit | 4e518e3cebdbcdf06a9b027d378b41c4aa79d8f6 (patch) | |
tree | be0a6d5de09021779c127a919cfe99eac6421412 /src/music | |
parent | f5024f8c91899fe227483ef329b5998969b6bb23 (diff) | |
download | openttd-4e518e3cebdbcdf06a9b027d378b41c4aa79d8f6.tar.xz |
(svn r11389) -Fix [FS#1386]: Replace calls to deprecated API with newer ones and handle broken iconv declaration in OSX 10.5.
Diffstat (limited to 'src/music')
-rw-r--r-- | src/music/qtmidi.cpp | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/src/music/qtmidi.cpp b/src/music/qtmidi.cpp index 12ec0aa03..88a1b49dd 100644 --- a/src/music/qtmidi.cpp +++ b/src/music/qtmidi.cpp @@ -55,48 +55,24 @@ enum { /** - * Converts a Unix-like pathname to a @c FSSpec structure which may be - * used with functions from several MacOS X frameworks (Carbon, QuickTime, - * etc). The pointed file or directory must exist. - * - * @param *path A string containing a Unix-like path. - * @param *spec Pointer to a @c FSSpec structure where the result will be - * stored. - * @return Wether the conversion was successful. - */ -static bool PathToFSSpec(const char *path, FSSpec *spec) -{ - FSRef ref; - assert(spec != NULL); - assert(path != NULL); - - return - FSPathMakeRef((UInt8*)path, &ref, NULL) == noErr && - FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL) == noErr; -} - - -/** * Sets the @c OSType of a given file to @c 'Midi', but only if it's not * already set. * * @param *spec A @c FSSpec structure referencing a file. */ -static void SetMIDITypeIfNeeded(const FSSpec *spec) +static void SetMIDITypeIfNeeded(const FSRef *ref) { - FSRef ref; FSCatalogInfo catalogInfo; - assert(spec); + assert(ref); - if (noErr != FSpMakeFSRef(spec, &ref)) return; - if (noErr != FSGetCatalogInfo(&ref, kFSCatInfoNodeFlags | kFSCatInfoFinderInfo, &catalogInfo, NULL, NULL, NULL)) 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); + e = FSSetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo); if (e == noErr) { DEBUG(driver, 3, "qtmidi: changed filetype to 'Midi'"); } else { @@ -119,6 +95,7 @@ static bool LoadMovieForMIDIFile(const char *path, Movie *moov) int fd; int ret; char magic[4]; + FSRef fsref; FSSpec fsspec; short refnum = 0; short resid = 0; @@ -144,9 +121,10 @@ static bool LoadMovieForMIDIFile(const char *path, Movie *moov) if (magic[0] != 'M' || magic[1] != 'T' || magic[2] != 'h' || magic[3] != 'd') return false; - if (!PathToFSSpec(path, &fsspec)) return false; - SetMIDITypeIfNeeded(&fsspec); + if (noErr != FSPathMakeRef((const UInt8 *) path, &fsref, NULL)) return false; + SetMIDITypeIfNeeded(&fsref); + if (noErr != FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, &fsspec, NULL)) return false; if (OpenMovieFile(&fsspec, &refnum, fsRdPerm) != noErr) return false; DEBUG(driver, 3, "qtmidi: '%s' successfully opened", path); |