mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-06 06:38:20 +00:00
Make map_file_from_path use the open flags
map_file_from_path now passes the appropriate flags on to os.open instead of always calling it with os.O_RDWR. It will no longer try to open a file with write permissions if the user didn't request write access to the file mapping (or vice-versa).
This commit is contained in:
@@ -10,7 +10,14 @@ map_file :: proc{
|
||||
}
|
||||
|
||||
map_file_from_path :: proc(filename: string, flags: Map_File_Flags) -> (data: []byte, error: Map_File_Error) {
|
||||
f, err := os.open(filename, os.O_RDWR)
|
||||
open_flags : os.File_Flags
|
||||
if .Read in flags {
|
||||
open_flags += {.Read}
|
||||
}
|
||||
if .Write in flags {
|
||||
open_flags += {.Write}
|
||||
}
|
||||
f, err := os.open(filename, open_flags)
|
||||
if err != nil {
|
||||
return nil, .Open_Failure
|
||||
}
|
||||
@@ -37,4 +44,4 @@ unmap_file :: proc(data: []byte) {
|
||||
if raw_data(data) != nil {
|
||||
_unmap_file(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user