X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Ftextfile.c;h=d41464cd8cbd17016cdb2b22e9cf2539e9a13623;hb=75e5efe798c0d0e83c709ff3a802fa48096fc776;hp=42c995396381fd20a40623a31d434582ce4782df;hpb=4cdfe1f65507e3647b37f11c19202c99cce11f77;p=wimlib diff --git a/src/textfile.c b/src/textfile.c index 42c99539..d41464cd 100644 --- a/src/textfile.c +++ b/src/textfile.c @@ -382,3 +382,23 @@ load_text_file(const tchar *path, const void *buf, size_t bufsize, *mem_ret = tstr; return 0; } + +/* API function documented in wimlib.h */ +WIMLIBAPI int +wimlib_load_text_file(const tchar *path, + tchar **tstr_ret, size_t *tstr_nchars_ret) +{ + void *buf; + size_t bufsize; + int ret; + + if (path == NULL || (path[0] == '-' && path[1] == '\0')) + ret = stdin_get_contents(&buf, &bufsize); + else + ret = read_file_contents(path, &buf, &bufsize); + if (ret) + return ret; + ret = translate_text_buffer(buf, bufsize, tstr_ret, tstr_nchars_ret); + FREE(buf); + return ret; +}