|
@ -288,35 +288,25 @@ Conf_save_start_error conf_save_start(Conf_save *p, |
|
|
err = Conf_save_start_no_home; |
|
|
err = Conf_save_start_no_home; |
|
|
goto cleanup; |
|
|
goto cleanup; |
|
|
} |
|
|
} |
|
|
if (!dir) { |
|
|
if (!dir) |
|
|
err = Conf_save_start_alloc_failed; |
|
|
goto allocfail; |
|
|
goto cleanup; |
|
|
|
|
|
} |
|
|
|
|
|
osoputoso(&p->canonpath, dir); |
|
|
osoputoso(&p->canonpath, dir); |
|
|
if (!p->canonpath) { |
|
|
if (!p->canonpath) |
|
|
err = Conf_save_start_alloc_failed; |
|
|
goto allocfail; |
|
|
goto cleanup; |
|
|
|
|
|
} |
|
|
|
|
|
size_t namelen = strlen(conf_file_name); |
|
|
size_t namelen = strlen(conf_file_name); |
|
|
if (namelen == 0) { |
|
|
if (namelen == 0) { |
|
|
err = Conf_save_start_bad_conf_name; |
|
|
err = Conf_save_start_bad_conf_name; |
|
|
goto cleanup; |
|
|
goto cleanup; |
|
|
} |
|
|
} |
|
|
conf_impl_catconfpath(&p->canonpath, conf_file_name, namelen); |
|
|
conf_impl_catconfpath(&p->canonpath, conf_file_name, namelen); |
|
|
if (!p->canonpath) { |
|
|
if (!p->canonpath) |
|
|
err = Conf_save_start_alloc_failed; |
|
|
goto allocfail; |
|
|
goto cleanup; |
|
|
|
|
|
} |
|
|
|
|
|
osoputoso(&p->temppath, p->canonpath); |
|
|
osoputoso(&p->temppath, p->canonpath); |
|
|
if (!p->temppath) { |
|
|
if (!p->temppath) |
|
|
err = Conf_save_start_alloc_failed; |
|
|
goto allocfail; |
|
|
goto cleanup; |
|
|
|
|
|
} |
|
|
|
|
|
osocat(&p->temppath, ".tmp"); |
|
|
osocat(&p->temppath, ".tmp"); |
|
|
if (!p->temppath) { |
|
|
if (!p->temppath) |
|
|
err = Conf_save_start_alloc_failed; |
|
|
goto allocfail; |
|
|
goto cleanup; |
|
|
|
|
|
} |
|
|
|
|
|
// Remove old temp file if it exists. If it exists and we can't remove it,
|
|
|
// Remove old temp file if it exists. If it exists and we can't remove it,
|
|
|
// error.
|
|
|
// error.
|
|
|
if (unlink(osoc(p->temppath)) == -1 && errno != ENOENT) { |
|
|
if (unlink(osoc(p->temppath)) == -1 && errno != ENOENT) { |
|
@ -350,6 +340,8 @@ Conf_save_start_error conf_save_start(Conf_save *p, |
|
|
osofree(dir); |
|
|
osofree(dir); |
|
|
return Conf_save_start_ok; |
|
|
return Conf_save_start_ok; |
|
|
|
|
|
|
|
|
|
|
|
allocfail: |
|
|
|
|
|
err = Conf_save_start_alloc_failed; |
|
|
cleanup: |
|
|
cleanup: |
|
|
osofree(dir); |
|
|
osofree(dir); |
|
|
conf_save_cancel(p); |
|
|
conf_save_cancel(p); |
|
|