summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/main.c b/main.c
index 40d861e..988935d 100644
--- a/main.c
+++ b/main.c
@@ -391,13 +391,13 @@ void ensure_dotbink_exists(Arena *temp) {
void new_post(Arena *temp) {
struct timespec ts;
- if (clock_gettime(CLOCK_REALTIME, &ts)) {
- err(1, "clock_gettime failure");
- }
- Str t = str_fmt(temp, "%U%09U", (uint64_t)ts.tv_sec, (uint64_t)ts.tv_nsec);
- const char *tmpf = cstr_fmt(temp, "/tmp/cbink_%s_%S.txt", getlogin(), t);
- const char *outf = cstr_fmt(temp, "/home/%s/.bink/%S", getlogin(), t);
+ /* create and edit post in a temp file */
+
+ if (clock_gettime(CLOCK_REALTIME, &ts)) err(1, "clock_gettime failure");
+
+ const char *tmpf = cstr_fmt(temp, "/tmp/cbink_%s_%U%09u.txt", getlogin(),
+ (uint64_t)ts.tv_sec, (uint32_t)ts.tv_nsec);
if (system(cstr_fmt(temp, "%s %s", get_editor(), tmpf))) return;
Str body = { 0 };
@@ -413,6 +413,12 @@ void new_post(Arena *temp) {
body = str_trim(body);
if (body.n < 1) return;
+ /* write it to .bink (with updated timestamp) */
+
+ if (clock_gettime(CLOCK_REALTIME, &ts)) err(1, "clock_gettime failure");
+
+ const char *outf = cstr_fmt(temp, "/home/%s/.bink/%U%09u", getlogin(),
+ (uint64_t)ts.tv_sec, (uint32_t)ts.tv_nsec);
f = fopen(outf, "w/o");
if (!f) {
log_warn("failed to open %s", outf);