Add loc := #caller_location to read_entire_file

This commit is contained in:
Jeroen van Rijn
2025-10-28 11:13:34 +01:00
parent 6088acd510
commit 22ebe06ebf
2 changed files with 7 additions and 4 deletions

View File

@@ -14,10 +14,10 @@ Read_Error :: enum {
read_from_file :: proc(filename: string, print_error := false, allocator := context.allocator, loc := #caller_location) -> (file: File, err: Read_Error) {
context.allocator = allocator
data, data_err := os.read_entire_file(filename, allocator)
data, data_err := os.read_entire_file(filename, allocator, loc)
if data_err != nil {
err = .Unable_To_Read_File
delete(data, allocator, loc)
delete(data, allocator)
return
}
file, err = read(data, filename, print_error, allocator)

View File

@@ -156,9 +156,12 @@ read_entire_file :: proc{
*/
@(require_results)
read_entire_file_from_path :: proc(name: string, allocator: runtime.Allocator, loc := #caller_location) -> (data: []byte, err: Error) {
f := open(name) or_return
f, ferr := open(name)
if ferr != nil {
return nil, ferr
}
defer close(f)
return read_entire_file_from_file(f, allocator, loc)
return read_entire_file_from_file(f=f, allocator=allocator, loc=loc)
}
/*