From b222abc4e1d96bc6a8733ac8a3332d0ecf06a044 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Tue, 26 Jan 2010 22:36:24 -0600 Subject: [PATCH] Prevent Timeline and Mixer from attempting to open each other's project formats. --- Mixer/Project.C | 11 +++++++++-- Mixer/Project.H | 2 +- Timeline/Project.C | 11 +++++++++-- Timeline/Project.H | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Mixer/Project.C b/Mixer/Project.C index e58e5e9..8836803 100644 --- a/Mixer/Project.C +++ b/Mixer/Project.C @@ -117,7 +117,7 @@ Project::write_info ( void ) } bool -Project::read_info ( int *version, char **creation_date ) +Project::read_info ( int *version, char **creation_date, char **created_by ) { FILE *fp; @@ -129,6 +129,7 @@ Project::read_info ( int *version, char **creation_date ) *version = 0; *creation_date = 0; + *created_by = 0; char *name, *value; @@ -140,6 +141,8 @@ Project::read_info ( int *version, char **creation_date ) *version = atoi( value ); else if ( ! strcmp( name, "created on" ) ) *creation_date = strdup( value ); + else if ( ! strcmp( name, "created by" ) ) + *created_by = strdup( value ); free( name ); free( value ); @@ -237,8 +240,12 @@ Project::open ( const char *name ) int version; char *creation_date; + char *created_by; - if ( ! read_info( &version, &creation_date ) ) + if ( ! read_info( &version, &creation_date, &created_by ) ) + return E_INVALID; + + if ( strncmp( created_by, APP_TITLE, strlen( APP_TITLE ) ) ) return E_INVALID; if ( version != PROJECT_VERSION ) diff --git a/Mixer/Project.H b/Mixer/Project.H index 2ea2b24..2fed316 100644 --- a/Mixer/Project.H +++ b/Mixer/Project.H @@ -32,7 +32,7 @@ class Project static char _created_on[40]; static bool write_info ( void ); - static bool read_info ( int *version, char **creation_date ); + static bool read_info ( int *version, char **creation_date, char **created_by ); static void set_name ( const char *name ); static const char *_errstr[]; diff --git a/Timeline/Project.C b/Timeline/Project.C index d2f5b7c..72e5ea5 100644 --- a/Timeline/Project.C +++ b/Timeline/Project.C @@ -124,7 +124,7 @@ Project::write_info ( void ) } bool -Project::read_info ( int *version, nframes_t *sample_rate, char **creation_date ) +Project::read_info ( int *version, nframes_t *sample_rate, char **creation_date, char **created_by ) { FILE *fp; @@ -137,6 +137,7 @@ Project::read_info ( int *version, nframes_t *sample_rate, char **creation_date *version = 0; *sample_rate = 0; *creation_date = 0; + *created_by = 0; char *name, *value; @@ -150,6 +151,8 @@ Project::read_info ( int *version, nframes_t *sample_rate, char **creation_date *version = atoi( value ); else if ( ! strcmp( name, "created on" ) ) *creation_date = strdup( value ); + else if ( ! strcmp( name, "created by" ) ) + *created_by = strdup( value ); free( name ); free( value ); @@ -248,8 +251,12 @@ Project::open ( const char *name ) int version; nframes_t rate; char *creation_date; + char *created_by; - if ( ! read_info( &version, &rate, &creation_date ) ) + if ( ! read_info( &version, &rate, &creation_date, &created_by ) ) + return E_INVALID; + + if ( strncmp( created_by, APP_TITLE, strlen( APP_TITLE ) ) ) return E_INVALID; if ( version != PROJECT_VERSION ) diff --git a/Timeline/Project.H b/Timeline/Project.H index da14b67..b3860db 100644 --- a/Timeline/Project.H +++ b/Timeline/Project.H @@ -32,7 +32,7 @@ class Project static char _created_on[40]; static bool write_info ( void ); - static bool read_info ( int *version, nframes_t *sample_rate, char **creation_date ); + static bool read_info ( int *version, nframes_t *sample_rate, char **creation_date, char **created_by ); static void set_name ( const char *name ); static const char *_errstr[];