Skip to content

Commit

Permalink
std/os: minor improvement for OpenFile
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Feb 19, 2025
1 parent 9a9feae commit c198440
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions std/os/file_unix.jule
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use "std/runtime"
use "std/sys"

fn openFile(path: str, mode: int, perm: FileMode)!: &File {
if path == "" {
error(FSError.NotExist)
}
s := integ::StrToBytes(path)
handle := unsafe { sys::Open(&s[0], mode|sys::O_CLOEXEC, int(syscallMode(perm))) }
if handle == -1 {
Expand Down
3 changes: 3 additions & 0 deletions std/os/file_windows.jule
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use "std/unicode/utf16"
use "std/unicode/utf8"

fn openFile(path: str, mut mode: int, mut perm: FileMode)!: &File {
if path == "" {
error(FSError.NotExist)
}
perm = syscallMode(perm)
mode |= sys::O_CLOEXEC
utf16Path := integ::UTF16FromStr(fixLongPath(path))
Expand Down

0 comments on commit c198440

Please sign in to comment.