added file_readWholeText

This commit is contained in:
2025-11-26 23:52:18 +05:00
parent 6a7f0a8715
commit 83091ac707
2 changed files with 25 additions and 3 deletions

View File

@@ -133,10 +133,14 @@ static inline Result(void) file_readBytesArrayExactly(FILE* f, Array(u8) dst){
return file_readStructsExactly(f, dst.data, 1, dst.len);
}
/// @brief allocates array of size equal `file_getSize()` and reads whole file
/// @brief allocates buffer of size `file_getSize(f)` and reads whole file
/// @param out_buf output array allocated on heap
Result(void) file_readWhole(FILE* f, Array(u8)* out_buf);
/// @brief allocates buffer of size `file_getSize(f) + 1` and reads whole file
/// @param out_str output str allocated on heap, null-terminated
Result(void) file_readWholeText(FILE* f, str* out_str);
//////////////////////////////////////////////////////////////////////////////
// DIRECTORY //
//////////////////////////////////////////////////////////////////////////////