Bugfix #1262
authorRob Haarsma <phaseIV@zonnet.nl>
Fri, 10 Dec 2004 01:28:28 +0000 (01:28 +0000)
committerRob Haarsma <phaseIV@zonnet.nl>
Fri, 10 Dec 2004 01:28:28 +0000 (01:28 +0000)
Raw fix for the drive letter issue with Quicktime/Windows filenames.
When a drive letter is missing in a filename, it'll use the drive where the executable is.

Fix might be useful for Yafray too, because the extern char bprogname[]; doesn't return
a full path when Blender is started from the console.

source/blender/quicktime/apple/quicktime_export.c
source/blender/quicktime/apple/quicktime_import.c
source/blender/quicktime/quicktime_import.h

index ec9d9a4f1d6a473342e02d0a6b53dda27b582836..a55a6ab3e365b6fa8ff53266f67e6668040acbd2 100644 (file)
@@ -65,9 +65,12 @@ DONE:
 #include "MEM_guardedalloc.h"
 #include "render.h"
 
+#include "quicktime_import.h"
 #include "quicktime_export.h"
 
 #ifdef _WIN32
+#include <stdio.h>
+#include "BLI_winstuff.h"
 #include <FixMath.h>
 #include <QTML.h>
 #include <TextUtils.h> 
@@ -497,6 +500,9 @@ void start_qt(void) {
 #ifdef __APPLE__
        int             myFile;
        FSRef   myRef;
+#else
+       char    *qtname;
+       FILE    *myFile = NULL;
 #endif
 
        if(qte == NULL) qte = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
@@ -522,9 +528,10 @@ void start_qt(void) {
                sframe = (G.scene->r.sfra);
 
                makeqtstring(name);
-               sprintf(theFullPath, "%s", name);
 
 #ifdef __APPLE__
+               sprintf(theFullPath, "%s", name);
+
                /* hack: create an empty file to make FSPathMakeRef() happy */
                myFile = open(theFullPath, O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRUSR|S_IWUSR);
                if (myFile < 0) {
@@ -537,6 +544,10 @@ void start_qt(void) {
                err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &qte->theSpec, NULL);
                CheckError(err, "FsGetCatalogInfoRef error");
 #else
+               qtname = get_valid_qtname(name);
+               sprintf(theFullPath, "%s", qtname);
+               MEM_freeN(qtname);
+               
                CopyCStringToPascal(theFullPath, qte->qtfilename);
                err = FSMakeFSSpec(0, 0L, qte->qtfilename, &qte->theSpec);
 #endif
@@ -549,7 +560,7 @@ void start_qt(void) {
                                                        &qte->theMovie );
                CheckError(err, "CreateMovieFile error");
 
-               printf("Created QuickTime movie: %s\n", name);
+               printf("Created QuickTime movie: %s\n", qtname);
 
                QT_CreateMyVideoTrack();
        }
index 4530921aefe0a3c221fb04edd738dd1e46016d40..e5359a8b4c036f5d9b25cdd08d0b303ab0936ed2 100644 (file)
@@ -37,6 +37,7 @@
 #include "IMB_anim.h"
 #include "BLO_sys_types.h"
 #include "BKE_global.h"
+#include "BLI_dynstr.h"
 
 #ifdef __APPLE__
 #include <QuickTime/Movies.h>
@@ -99,6 +100,37 @@ void quicktime_exit(void)
 }
 
 
+#ifdef _WIN32
+char *get_valid_qtname(char *name)
+{
+       TCHAR Buffer[MAX_PATH];
+       DWORD dwRet;
+       char *qtname;
+       DynStr *ds= BLI_dynstr_new();
+
+       dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
+
+       if(name[1] != ':') {
+               char drive[2];
+
+               drive[0] = Buffer[0];
+               drive[1] = '\0';
+
+               BLI_dynstr_append(ds, drive);
+               BLI_dynstr_append(ds, ":");
+               BLI_dynstr_append(ds, name);
+       } else {
+               BLI_dynstr_append(ds, name);
+       }
+
+       qtname= BLI_dynstr_get_cstring(ds);
+       BLI_dynstr_free(ds);
+
+       return qtname;
+}
+#endif /* _WIN32 */
+
+
 int anim_is_quicktime (char *name)
 {
        FSSpec  theFSSpec;
@@ -111,6 +143,7 @@ int anim_is_quicktime (char *name)
        FInfo                                           myFinderInfo;
        FSRef                                           myRef;
 #else
+       char *qtname;
        Str255  dst;
 #endif
        OSErr                                           err = noErr;
@@ -129,11 +162,16 @@ int anim_is_quicktime (char *name)
 
        if(QTIME_DEBUG) printf("qt: checking as movie\n");
 
-       sprintf(theFullPath, "%s", name);
 #ifdef __APPLE__
+       sprintf(theFullPath, "%s", name);
+
        err = FSPathMakeRef(theFullPath, &myRef, 0);
        err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
 #else
+       qtname = get_valid_qtname(name);
+       sprintf(theFullPath, "%s", qtname);
+       MEM_freeN(qtname);
+
        CopyCStringToPascal(theFullPath, dst);
        err = FSMakeFSSpec(0, 0L, dst, &theFSSpec);
 #endif
@@ -349,6 +387,7 @@ int startquicktime (struct anim *anim)
 #ifdef __APPLE__
        FSRef           myRef;
 #else
+       char            *qtname;
        Str255          dst;
 #endif
 
@@ -361,12 +400,17 @@ int startquicktime (struct anim *anim)
        }
 
        if(QTIME_DEBUG) printf("qt: attempting to load as movie %s\n", anim->name);
-       sprintf(theFullPath, "%s", anim->name);
        
 #ifdef __APPLE__
+       sprintf(theFullPath, "%s", anim->name);
+
        err = FSPathMakeRef(theFullPath, &myRef, 0);
        err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &theFSSpec, NULL);
 #else
+       qtname = get_valid_qtname(anim->name);
+       sprintf(theFullPath, "%s", qtname);
+       MEM_freeN(qtname);
+
        CopyCStringToPascal(theFullPath, dst);
        FSMakeFSSpec(0, 0L, dst, &theFSSpec);
 #endif
index a99827eb2f3ce5fe6b6b12eeac8d6c2023f1df3e..39434a92a852da201eec0f4739f268e893c10c5c 100644 (file)
@@ -85,6 +85,8 @@ typedef struct _QuicktimeMovie {
        int                     have_gw;        //ugly
 } QuicktimeMovie;
 
+char *get_valid_qtname(char *name);
+
 
 // quicktime movie import functions