From 8203eb49d6707a70333873bada42712f06eb33fb Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Sun, 25 Sep 2011 16:14:23 -0700 Subject: [PATCH] Fix build on win32 --- src/framework/Makefile | 2 +- src/framework/mlt_factory.c | 15 +++++++++------ src/framework/mlt_profile.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/framework/Makefile b/src/framework/Makefile index e487c9aa..004d3e5a 100644 --- a/src/framework/Makefile +++ b/src/framework/Makefile @@ -78,7 +78,7 @@ OBJS += ../win32/win32.o SRCS += ../win32/win32.c endif -CFLAGS += $(RDYNAMIC) -DPREFIX="\"$(prefix)\"" -DLIBDIR="\"$(libdir)\"" -DDATADIR="\"$(datadir)\"" +CFLAGS += $(RDYNAMIC) -DPREFIX="\"$(prefix)\"" -DLIBDIR="\"$(libdir)\"" -DMLTDATADIR="\"$(datadir)\"" LDFLAGS += $(LIBDL) -lpthread diff --git a/src/framework/mlt_factory.c b/src/framework/mlt_factory.c index 76f3f5c6..cd298bc7 100644 --- a/src/framework/mlt_factory.c +++ b/src/framework/mlt_factory.c @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef WIN32 #include @@ -36,7 +37,6 @@ #define PREFIX_DATA "\\share\\mlt" #elif defined(__DARWIN__) && defined(RELOCATABLE) #include -#include /** the default subdirectory of the libdir for holding modules (plugins) */ #define PREFIX_LIB "/lib/mlt" /** the default subdirectory of the install prefix for holding module (plugin) data */ @@ -45,7 +45,7 @@ /** the default subdirectory of the libdir for holding modules (plugins) */ #define PREFIX_LIB LIBDIR "/mlt" /** the default subdirectory of the install prefix for holding module (plugin) data */ -#define PREFIX_DATA DATADIR "/mlt" +#define PREFIX_DATA MLTDATADIR "/mlt" #endif /** holds the full path to the modules directory - initialized and retained for the entire session */ @@ -141,9 +141,9 @@ mlt_repository mlt_factory_init( const char *directory ) // Store the prefix for later retrieval #if defined(WIN32) - LPTSTR path[1024]; + char path[1024]; DWORD size = sizeof( path ); - GetModuleFileName( NULL, path, &size ); + GetModuleFileName( NULL, path, size ); #elif defined(__DARWIN__) && defined(RELOCATABLE) char path[1024]; uint32_t size = sizeof( path ); @@ -152,17 +152,20 @@ mlt_repository mlt_factory_init( const char *directory ) mlt_directory = strdup( directory ); #endif #if defined(WIN32) || (defined(__DARWIN__) && defined(RELOCATABLE)) + char *path2 = strdup( path ); + char *exedir = dirname( path2 ); if ( global_properties && !getenv( "MLT_DATA" ) ) { mlt_directory = calloc( 1, size + strlen( PREFIX_DATA ) + 1 ); - strcpy( mlt_directory, dirname( path ) ); + strcpy( mlt_directory, exedir ); strcat( mlt_directory, PREFIX_DATA ); mlt_properties_set( global_properties, "MLT_DATA", mlt_directory ); free( mlt_directory ); } mlt_directory = calloc( 1, size + strlen( directory ) + 1 ); - strcpy( mlt_directory, dirname( path ) ); + strcpy( mlt_directory, exedir ); strcat( mlt_directory, directory ); + free( path2 ); #endif // Initialise the pool diff --git a/src/framework/mlt_profile.c b/src/framework/mlt_profile.c index 9e3b7ce3..f0fc02c5 100644 --- a/src/framework/mlt_profile.c +++ b/src/framework/mlt_profile.c @@ -56,7 +56,7 @@ static mlt_profile mlt_profile_select( const char *name ) // Load from $datadir/mlt/profiles else if ( prefix == NULL ) { - prefix = DATADIR; + prefix = MLTDATADIR; filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + strlen( name ) + 1 ); strcpy( filename, prefix ); strcat( filename, PROFILES_DIR ); -- 2.39.2