]> git.sesse.net Git - mlt/commitdiff
Fix and cleanup profile and preset dirs.
authorDan Dennedy <dan@dennedy.org>
Sun, 25 Sep 2011 21:14:47 +0000 (14:14 -0700)
committerDan Dennedy <dan@dennedy.org>
Sun, 25 Sep 2011 21:14:47 +0000 (14:14 -0700)
src/framework/mlt_profile.c
src/framework/mlt_properties.c
src/framework/mlt_repository.c

index ce93957efff8cee242fb30fa10fdf474dad4fee7..9e3b7ce344fa07a5ac3fbf5cacfbb043275c2fdf 100644 (file)
@@ -57,10 +57,8 @@ static mlt_profile mlt_profile_select( const char *name )
        else if ( prefix == NULL )
        {
                prefix = DATADIR;
-               filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + strlen( name ) + 2 );
+               filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + strlen( name ) + 1 );
                strcpy( filename, prefix );
-               if ( filename[ strlen( filename ) - 1 ] != '/' )
-                       filename[ strlen( filename ) ] = '/';
                strcat( filename, PROFILES_DIR );
        }
        // Use environment variable instead
@@ -357,10 +355,8 @@ mlt_properties mlt_profile_list( )
        if ( prefix == NULL )
        {
                prefix = mlt_environment( "MLT_DATA" );
-               filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + 2 );
+               filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + 1 );
                strcpy( filename, prefix );
-               if ( filename[ strlen( filename ) - 1 ] != '/' )
-                       filename[ strlen( filename ) ] = '/';
                strcat( filename, PROFILES_DIR );
                prefix = filename;
        }
index 39b1339f629abad394c12b12b299f03e3989884c..c381e239a0828a97ed3bbe94ecb74f9f4043d186 100644 (file)
@@ -40,6 +40,8 @@
 #include <errno.h>
 #include <locale.h>
 
+#define PRESETS_DIR "/presets"
+
 /** \brief private implementation of the property list */
 
 typedef struct
@@ -285,9 +287,9 @@ int mlt_properties_preset( mlt_properties self, const char *name )
                }
                else
                {
-                       data = malloc( strlen( mlt_environment( "MLT_DATA" ) ) + 9 );
+                       data = malloc( strlen( mlt_environment( "MLT_DATA" ) ) + strlen( PRESETS_DIR ) + 1 );
                        strcpy( data, mlt_environment( "MLT_DATA" ) );
-                       strcat( data, "/presets" );
+                       strcat( data, PRESETS_DIR );
                }
                if ( data && type && service )
                {
index ffb65daff57db3832420641f8aae61afd42ee50d..acda89cc6272e4e007f75f44c5c9a590951e1ef8 100644 (file)
@@ -495,10 +495,8 @@ mlt_properties mlt_repository_presets( )
        }
        else
        {
-               path = malloc( strlen( mlt_environment( "MLT_DATA" ) ) + 9 );
+               path = malloc( strlen( mlt_environment( "MLT_DATA" ) ) + strlen( PRESETS_DIR ) + 1 );
                strcpy( path, mlt_environment( "MLT_DATA" ) );
-               if ( path[ strlen( path ) - 1 ] != '/' )
-                       path[ strlen( path ) ] = '/';
                strcat( path, PRESETS_DIR );
        }
        list_presets( result, NULL, path );