summaryrefslogtreecommitdiff
path: root/str/str.c
diff options
context:
space:
mode:
authorSoikk2025-11-05 20:52:52 +0100
committerSoikk2025-11-05 20:52:52 +0100
commit659e34f07c05e00baf10417503111048cbc634e3 (patch)
tree090d2f1ad6201a71bafe155d354c79af5a4ce393 /str/str.c
parent009e1f2b15c8de452c5c245d99640859a458e86c (diff)
downloadsoikk-libs-659e34f07c05e00baf10417503111048cbc634e3.tar.xz
soikk-libs-659e34f07c05e00baf10417503111048cbc634e3.tar.zst
Added string to file functions
Diffstat (limited to 'str/str.c')
-rwxr-xr-xstr/str.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/str/str.c b/str/str.c
index 145aca9..7767e99 100755
--- a/str/str.c
+++ b/str/str.c
@@ -356,6 +356,12 @@ str file_to_nstr(char *filename, u32 len){
return s;
}
+void str_to_file(str s, char *filename){
+ FILE *fp = fopen(filename, "r");
+ str_to_fp(s, fp);
+ fclose(fp)
+}
+
str map_file(char *filename){
int fd = open(filename, 0);
if(fd == -1){
@@ -397,6 +403,7 @@ void unmap_file(str *s){
s->cap = 0;
}
+// TODO: check if this function is redundant
str fread_str(int fd, int max){
str s = dnstr(max);
s.len = read(fd, s.ptr, s.cap);