| 9 | | #include <osg/ref_ptr> |
| 10 | | #include <osg/Referenced> |
| 11 | | #include <osg/Notify> |
| 12 | | #include "QTUtils.h" |
| 13 | | #include "osgDB/Registry" |
| 14 | | |
| 15 | | |
| 16 | | using namespace std; |
| 17 | | |
| 18 | | |
| 19 | | // --------------------------------------------------------------------------- |
| 20 | | // MakeFSSPecFromPath |
| 21 | | // wandelt einen Posix-Pfad in ein FSSpec um. |
| 22 | | // --------------------------------------------------------------------------- |
| 23 | | OSStatus MakeFSSpecFromPath(const char* path, FSSpec* spec) { |
| 24 | | #ifdef __APPLE__ |
| 25 | | OSStatus err; |
| 26 | | FSRef fsref; |
| 27 | | Boolean isdir; |
| 28 | | /* |
| 29 | | FSPathMakeRef is only available in Carbon. It takes a POSIX path and |
| 30 | | tries to convert it into a MacOS FSRef object. |
| 31 | | We don't want folders, only files, so we'll fail here if we got a |
| 32 | | directory. |
| 33 | | */ |
| 34 | | err = FSPathMakeRef((const UInt8*)path, &fsref, &isdir); |
| 35 | | if (err!=0) return err; |
| 36 | | if (isdir) return 1; |
| 37 | | // Ditto |
| 38 | | err = FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, spec, NULL); |
| 39 | | return err; |
| 40 | | #else |
| 41 | | return -1; |
| 42 | | #endif |
| 43 | | } |
| 44 | | |
| 45 | | // --------------------------------------------------------------------------- |
| 46 | | // MakeMovieFromPath |
| 47 | | // --------------------------------------------------------------------------- |
| 48 | | OSStatus MakeMovieFromPath(const char* path, Movie* movie, short& resref) { |
| 49 | | OSStatus err; |
| 50 | | FSSpec spec; |
| 51 | | #ifdef __APPLE__ |
| 52 | | MakeFSSpecFromPath(path, &spec); |
| 53 | | #else |
| 54 | | err = NativePathNameToFSSpec((char*)path, &spec, 0 /* flags */); |
| 55 | | #endif |
| 56 | | err = OpenMovieFile(&spec, &resref, fsRdPerm); |
| 57 | | if (err!=0) return err; |
| 58 | | err = NewMovieFromFile(movie, resref, NULL, NULL, 0, NULL); |
| 59 | | if (err==0) err=GetMoviesError(); |
| 60 | | return err; |
| 61 | | } |
| 62 | | |
| 63 | | |
| 64 | | |