forked from ExternalVendorCode/Signal-Server
Elegantly handle missing sdf files
This commit is contained in:
15
inputs.cc
15
inputs.cc
@@ -400,18 +400,17 @@ int LoadSDF_SDF(char *name)
|
|||||||
|
|
||||||
strncpy(path_plus_name, sdf_file, 255);
|
strncpy(path_plus_name, sdf_file, 255);
|
||||||
|
|
||||||
fd = fopen(path_plus_name, "rb");
|
if( (fd = fopen(path_plus_name, "rb")) == NULL ){
|
||||||
|
|
||||||
if (fd == NULL) {
|
|
||||||
/* Next, try loading SDF file from path specified
|
/* Next, try loading SDF file from path specified
|
||||||
in $HOME/.ss_path file or by -d argument */
|
in $HOME/.ss_path file or by -d argument */
|
||||||
|
|
||||||
strncpy(path_plus_name, sdf_path, 255);
|
strncpy(path_plus_name, sdf_path, 255);
|
||||||
strncat(path_plus_name, sdf_file, 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) {
|
if (debug == 1) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Loading \"%s\" into page %d...",
|
"Loading \"%s\" into page %d...",
|
||||||
@@ -530,10 +529,6 @@ int LoadSDF_SDF(char *name)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -557,7 +552,7 @@ char LoadSDF(char *name)
|
|||||||
|
|
||||||
/* If neither format can be found, then assume the area is water. */
|
/* 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,
|
sscanf(name, "%d:%d:%d:%d", &minlat, &maxlat, &minlon,
|
||||||
|
Reference in New Issue
Block a user