Elegantly handle missing sdf files

This commit is contained in:
Gareth Evans
2017-02-22 13:39:14 +00:00
parent 3de2bf8f97
commit 1a4f4bd226

View File

@@ -400,18 +400,17 @@ int LoadSDF_SDF(char *name)
strncpy(path_plus_name, sdf_file, 255);
fd = fopen(path_plus_name, "rb");
if (fd == NULL) {
if( (fd = fopen(path_plus_name, "rb")) == NULL ){
/* Next, try loading SDF file from path specified
in $HOME/.ss_path file or by -d argument */
strncpy(path_plus_name, sdf_path, 255);
strncat(path_plus_name, sdf_file, 255);
fd = fopen(path_plus_name, "rb");
if( (fd = fopen(path_plus_name, "rb")) == NULL ){
return -errno;
}
}
if (fd != NULL) {
if (debug == 1) {
fprintf(stderr,
"Loading \"%s\" into page %d...",
@@ -530,10 +529,6 @@ int LoadSDF_SDF(char *name)
return 1;
}
else
return -1;
}
else
return 0;
}
@@ -557,7 +552,7 @@ char LoadSDF(char *name)
/* If neither format can be found, then assume the area is water. */
if (return_value == 0 || return_value == -1) {
if ( return_value == 0 || return_value < 0 ) {
sscanf(name, "%d:%d:%d:%d", &minlat, &maxlat, &minlon,