Add @(require_results) everywhere in os2

This commit is contained in:
gingerBill
2024-05-14 18:25:15 +01:00
parent 48c1822709
commit 450b9ceaec
13 changed files with 85 additions and 39 deletions
+4 -1
View File
@@ -13,6 +13,7 @@ MAX_ATTEMPTS :: 1<<13 // Should be enough for everyone, right?
// If `dir` is an empty tring, `temp_directory()` will be used.
//
// The caller must `close` the file once finished with.
@(require_results)
create_temp_file :: proc(dir, pattern: string) -> (f: ^File, err: Error) {
TEMP_ALLOCATOR_GUARD()
dir := dir if dir != "" else temp_directory(temp_allocator()) or_return
@@ -44,6 +45,7 @@ mkdir_temp :: make_directory_temp
// The directory name is generated by taking a pattern, and adding a randomized string to the end.
// If the pattern includes an "*", the randm string replaces the last "*".
// If `dir` is an empty tring, `temp_directory()` will be used.
@(require_results)
make_directory_temp :: proc(dir, pattern: string, allocator: runtime.Allocator) -> (temp_path: string, err: Error) {
TEMP_ALLOCATOR_GUARD()
dir := dir if dir != "" else temp_directory(temp_allocator()) or_return
@@ -58,7 +60,7 @@ make_directory_temp :: proc(dir, pattern: string, allocator: runtime.Allocator)
name := concatenate_strings_from_buffer(name_buf[:], prefix, random_string(rand_buf[:]), suffix)
err = make_directory(name, 0o700)
if err == nil {
return clone_string(name, allocator), nil
return clone_string(name, allocator)
}
if err == .Exist {
attempts += 1
@@ -78,6 +80,7 @@ make_directory_temp :: proc(dir, pattern: string, allocator: runtime.Allocator)
}
temp_dir :: temp_directory
@(require_results)
temp_directory :: proc(allocator: runtime.Allocator) -> (string, Error) {
return _temp_dir(allocator)
}