Search
lxdream.org :: lxdream :: r891:de9d08282160
lxdream 0.9.1
released Jun 29
Download Now
changeset891:de9d08282160
parent890:a9896953e9a1
child892:126aa7db6162
authornkeynes
dateThu Oct 23 12:39:01 2008 +0000 (11 years ago)
Suppress error messages when loading preview (defer errors from
dreamcast_read_save_state_header to caller). Really needs to be
deferred further back to original UI callsite
src/dreamcast.c
1.1 --- a/src/dreamcast.c Thu Oct 23 08:30:47 2008 +0000
1.2 +++ b/src/dreamcast.c Thu Oct 23 12:39:01 2008 +0000
1.3 @@ -288,22 +288,25 @@
1.4 * file.
1.5 * @return the number of blocks following, or 0 if the file is invalid.
1.6 */
1.7 -int dreamcast_read_save_state_header( FILE *f )
1.8 +int dreamcast_read_save_state_header( FILE *f, char *error, int errorlen )
1.9 {
1.10 struct save_state_header header;
1.11 if( fread( &header, sizeof(header), 1, f ) != 1 ) {
1.12 return 0;
1.13 }
1.14 if( strncmp( header.magic, DREAMCAST_SAVE_MAGIC, 16 ) != 0 ) {
1.15 - ERROR( "Not a %s save state file", APP_NAME );
1.16 + if( error != NULL )
1.17 + snprintf( error, errorlen, _("File is not a %s save state"), APP_NAME );
1.18 return 0;
1.19 }
1.20 if( header.version != DREAMCAST_SAVE_VERSION ) {
1.21 - ERROR( "%s save state version not supported", APP_NAME );
1.22 + if( error != NULL )
1.23 + snprintf( error, errorlen, _("Unsupported %s save state version"), APP_NAME, header.version );
1.24 return 0;
1.25 }
1.26 if( header.module_count > MAX_MODULES ) {
1.27 - ERROR( "%s save state is corrupted (bad module count)", APP_NAME );
1.28 + if( error != NULL )
1.29 + snprintf( error, errorlen, _("%s save state is corrupted (bad module count)"), APP_NAME );
1.30 return 0;
1.31 }
1.32 return header.module_count;
1.33 @@ -327,7 +330,7 @@
1.34 FILE *f = fopen( filename, "r" );
1.35 if( f == NULL ) return NULL;
1.36
1.37 - int module_count = dreamcast_read_save_state_header(f);
1.38 + int module_count = dreamcast_read_save_state_header(f, NULL, 0);
1.39 if( module_count <= 0 ) {
1.40 fclose(f);
1.41 return NULL;
1.42 @@ -365,13 +368,15 @@
1.43 {
1.44 int i,j;
1.45 int module_count;
1.46 + char error[128];
1.47 int have_read[MAX_MODULES];
1.48
1.49 FILE *f = fopen( filename, "r" );
1.50 if( f == NULL ) return errno;
1.51
1.52 - module_count = dreamcast_read_save_state_header(f);
1.53 + module_count = dreamcast_read_save_state_header(f, error, sizeof(error));
1.54 if( module_count <= 0 ) {
1.55 + ERROR( error );
1.56 fclose(f);
1.57 return 1;
1.58 }
.