aboutsummaryrefslogtreecommitdiff
path: root/text-io.c
diff options
context:
space:
mode:
authorRandy Palamar <randy@rnpnr.xyz>2025-11-23 20:05:59 -0700
committerRandy Palamar <randy@rnpnr.xyz>2025-11-24 05:25:54 -0700
commit5df02c199959b9da42baff0c876bf87125178ca0 (patch)
treea9f3be8b405006d3a92292bc1db3722c7279ec3e /text-io.c
parent1953c287ace801a6606abd6c3ead0ff345645bec (diff)
downloadvis-5df02c199959b9da42baff0c876bf87125178ca0.tar.gz
vis-5df02c199959b9da42baff0c876bf87125178ca0.tar.xz
text: remove a bunch of unused save functions
These functions were only used for testing the text system. One of them was moved to text-test.c to continue to facilitate this. Otherwise these functions are just cluttering up the code and making it hard to modify.
Diffstat (limited to 'text-io.c')
-rw-r--r--text-io.c42
1 files changed, 1 insertions, 41 deletions
diff --git a/text-io.c b/text-io.c
index 94654ae..bbd1f8d 100644
--- a/text-io.c
+++ b/text-io.c
@@ -166,10 +166,6 @@ Text *text_load(const char *filename) {
return text_load_method(filename, TEXT_LOAD_AUTO);
}
-Text *text_loadat(int dirfd, const char *filename) {
- return text_loadat_method(dirfd, filename, TEXT_LOAD_AUTO);
-}
-
Text *text_load_method(const char *filename, enum TextLoadMethod method) {
return text_loadat_method(AT_FDCWD, filename, method);
}
@@ -453,48 +449,12 @@ bool text_save_commit(TextSave *ctx) {
return result;
}
-/* First try to save the file atomically using rename(2) if this does not
- * work overwrite the file in place. However if something goes wrong during
- * this overwrite the original file is permanently damaged.
- */
-bool text_save(Text *txt, const char *filename) {
- return text_saveat(txt, AT_FDCWD, filename);
-}
-
-bool text_saveat(Text *txt, int dirfd, const char *filename) {
- return text_saveat_method(txt, dirfd, filename, TEXT_SAVE_AUTO);
-}
-
-bool text_save_method(Text *txt, const char *filename, enum TextSaveMethod method) {
- return text_saveat_method(txt, AT_FDCWD, filename, method);
-}
-
-bool text_saveat_method(Text *txt, int dirfd, const char *filename, enum TextSaveMethod method) {
- if (!filename) {
- text_saved(txt, NULL);
- return true;
- }
- TextSave ctx = text_save_default(.txt = txt, .dirfd = dirfd, .filename = filename, .method = method);
- if (!text_save_begin(&ctx))
- return false;
- Filerange range = (Filerange){ .start = 0, .end = text_size(txt) };
- ssize_t written = text_save_write_range(&ctx, &range);
- if (written == -1 || (size_t)written != text_range_size(&range)) {
- text_save_cancel(&ctx);
- return false;
- }
- return text_save_commit(&ctx);
-}
+void text_mark_current_revision(Text *txt) { text_saved(txt, 0); }
ssize_t text_save_write_range(TextSave *ctx, const Filerange *range) {
return text_write_range(ctx->txt, range, ctx->fd);
}
-ssize_t text_write(const Text *txt, int fd) {
- Filerange r = (Filerange){ .start = 0, .end = text_size(txt) };
- return text_write_range(txt, &r, fd);
-}
-
ssize_t text_write_range(const Text *txt, const Filerange *range, int fd) {
size_t size = text_range_size(range), rem = size;
for (Iterator it = text_iterator_get(txt, range->start);