properly handle the fate of the directive file

This commit is contained in:
anon 2025-01-24 23:33:57 +01:00
parent 9448bd3b7e
commit fc4553843c
3 changed files with 11 additions and 7 deletions

View File

@ -91,8 +91,10 @@ Vimdir will terminate at the first sign of an error,
but it has no way to roll-back your filesystem,
so be careful.
If Vimdir fails, the directive file is preserved and its path is returned to the user.
You will not be able to manage files which have tab or newline characters in their names.
If you have aforementioned files, please seek the help of a specialist.
The first character of the permission string is simply in formative,
The first character of the permission string is simply informative,
its (changed) value is ignored.

View File

@ -14,3 +14,4 @@
- [X] use `${VIMDIREDITOR}`
- [ ] dry and moist tests
- [ ] stdin / no order
- [X] remove tempfile

View File

@ -52,11 +52,6 @@ int edit(const char * filename) {
return 0;
}
void clean_up(void) {
free(folder);
deinit_directive_c();
}
signed main(int argc, char * * argv) {
#define CHECK(x) do { \
if ((r = x)) { \
@ -99,7 +94,13 @@ signed main(int argc, char * * argv) {
if (tmpfile) {
fclose(tmpfile);
}
clean_up();
if (!r) {
unlink(tmpfile_name);
} else {
notice("the location of the preserved directive file is '%s'", tmpfile_name);
}
free(folder);
deinit_directive_c();
#undef CHECK
return r;