rawfile.c, no premature exit if directory not available, if just file name without path, simply hand it back.

This commit is contained in:
h_vogt 2017-02-26 11:42:01 +01:00 committed by rlar
parent d0607f5524
commit 629000f039
1 changed files with 13 additions and 12 deletions

View File

@ -847,19 +847,20 @@ set_output_path(char *filename)
if(!dirloc)
dirloc = strrchr(ret, DIR_TERM_LINUX);
#endif
if (dirloc)
if (dirloc) {
fpath = copy_substring(ret, dirloc);
/* test if path exists */
if (stat(fpath, &st) == 0) {
tfree(fpath);
return ret;
}
else {
fprintf(cp_err, "Error: Output path %s does not exist\n", fpath);
tfree(fpath);
return ret; /* fopen will catch this error */
}
}
/* no path, just use the file name */
else
fpath = copy(ret);
/* test if path exists */
if (stat(fpath, &st) == 0) {
tfree(fpath);
return ret;
}
else {
fprintf(cp_err, "Error: Output path %s does not exist\n", fpath);
tfree(ret);
tfree(fpath);
controlled_exit(1);
}
}