-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfiguration.odin
More file actions
63 lines (48 loc) · 1.2 KB
/
configuration.odin
File metadata and controls
63 lines (48 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package eitr
import "core:fmt"
import "core:os"
init_config :: proc() -> Eitr_Errors {
has_eitr := os.exists("./eitr.json")
// has_ols := os.exists("./ols.json")
// has_odinfmt := os.exists("./odinfmt.json")
if has_eitr {
cwd := os.get_current_directory()
fmt.eprintf(
"[EITR][init_config] EITR configuration already exists at %s/eitr.json\n",
cwd,
)
return .Configuration_Already_Exists
}
return .None
}
@(private = "file")
copy_default :: proc(source: string, destination: string) -> Eitr_Errors {
src_fd, open_err := os.open(source)
if open_err != 0 {
fmt.eprintf(
"[eitr][copy_default] Failed to open %s: %v",
source,
open_err,
)
return .IO_Error
}
data, read_success := os.read_entire_file_from_handle(
src_fd,
context.temp_allocator,
)
if !read_success {
fmt.eprintf("[eitr] Failed to read %s", source)
return .IO_Error
}
src_close_err := os.close(src_fd)
if src_close_err != 0 {
fmt.eprintf("[eitr] Failed to close %s: %v", source, src_close_err)
return .IO_Error
}
write_success := os.write_entire_file(destination, data)
if !write_success {
fmt.eprintf("[eitr] Failed to copy %s to %s", source, destination)
return .IO_Error
}
return .None
}