Fix perm: int to perm: Permissions

This commit is contained in:
gingerBill
2026-02-19 13:58:02 +00:00
parent d4b2d527d4
commit 26a4b2bfef
6 changed files with 17 additions and 17 deletions

View File

@@ -74,7 +74,7 @@ Make a new directory.
If `path` is relative, it will be relative to the process's current working directory.
*/
make_directory :: proc(name: string, perm: int = 0o755) -> Error {
make_directory :: proc(name: string, perm := Permissions_Default_Directory) -> Error {
return _mkdir(name, perm)
}
@@ -85,7 +85,7 @@ Make a new directory, creating new intervening directories when needed.
If `path` is relative, it will be relative to the process's current working directory.
*/
make_directory_all :: proc(path: string, perm: int = 0o755) -> Error {
make_directory_all :: proc(path: string, perm := Permissions_Default_Directory) -> Error {
return _mkdir_all(path, perm)
}

View File

@@ -16,11 +16,11 @@ _is_path_separator :: proc(c: byte) -> (ok: bool) {
return c == _Path_Separator
}
_mkdir :: proc(name: string, perm: int) -> (err: Error) {
_mkdir :: proc(name: string, perm: Permissions) -> (err: Error) {
return .Unsupported
}
_mkdir_all :: proc(path: string, perm: int) -> (err: Error) {
_mkdir_all :: proc(path: string, perm: Permissions) -> (err: Error) {
return .Unsupported
}

View File

@@ -17,14 +17,14 @@ _is_path_separator :: proc(c: byte) -> bool {
return c == _Path_Separator
}
_mkdir :: proc(path: string, perm: int) -> Error {
_mkdir :: proc(path: string, perm: Permissions) -> Error {
temp_allocator := TEMP_ALLOCATOR_GUARD({})
path_cstr := clone_to_cstring(path, temp_allocator) or_return
return _get_platform_error(linux.mkdir(path_cstr, transmute(linux.Mode)u32(perm)))
return _get_platform_error(linux.mkdir(path_cstr, transmute(linux.Mode)transmute(u32)perm))
}
_mkdir_all :: proc(path: string, perm: int) -> Error {
mkdirat :: proc(dfd: linux.Fd, path: []u8, perm: int, has_created: ^bool) -> Error {
_mkdir_all :: proc(path: string, perm: Permissions) -> Error {
mkdirat :: proc(dfd: linux.Fd, path: []u8, perm: Permissions, has_created: ^bool) -> Error {
i: int
for ; i < len(path) - 1 && path[i] != '/'; i += 1 {}
if i == 0 {
@@ -34,7 +34,7 @@ _mkdir_all :: proc(path: string, perm: int) -> Error {
new_dfd, errno := linux.openat(dfd, cstring(&path[0]), _OPENDIR_FLAGS)
#partial switch errno {
case .ENOENT:
if errno = linux.mkdirat(dfd, cstring(&path[0]), transmute(linux.Mode)u32(perm)); errno != .NONE {
if errno = linux.mkdirat(dfd, cstring(&path[0]), transmute(linux.Mode)transmute(u32)perm); errno != .NONE {
return _get_platform_error(errno)
}
has_created^ = true

View File

@@ -14,16 +14,16 @@ _is_path_separator :: proc(c: byte) -> bool {
return c == _Path_Separator
}
_mkdir :: proc(name: string, perm: int) -> (err: Error) {
_mkdir :: proc(name: string, perm: Permissions) -> (err: Error) {
temp_allocator := TEMP_ALLOCATOR_GUARD({})
cname := clone_to_cstring(name, temp_allocator) or_return
if posix.mkdir(cname, transmute(posix.mode_t)posix._mode_t(perm)) != .OK {
if posix.mkdir(cname, transmute(posix.mode_t)posix._mode_t(transmute(u32)perm)) != .OK {
return _get_platform_error()
}
return nil
}
_mkdir_all :: proc(path: string, perm: int) -> Error {
_mkdir_all :: proc(path: string, perm: Permissions) -> Error {
if path == "" {
return .Invalid_Path
}
@@ -37,7 +37,7 @@ _mkdir_all :: proc(path: string, perm: int) -> Error {
clean_path := clean_path(path, temp_allocator) or_return
return internal_mkdir_all(clean_path, perm)
internal_mkdir_all :: proc(path: string, perm: int) -> Error {
internal_mkdir_all :: proc(path: string, perm: Permissions) -> Error {
dir, file := split_path(path)
if file != path && dir != "/" {
if len(dir) > 1 && dir[len(dir) - 1] == '/' {

View File

@@ -14,7 +14,7 @@ _is_path_separator :: proc(c: byte) -> bool {
return c == _Path_Separator
}
_mkdir :: proc(name: string, perm: int) -> Error {
_mkdir :: proc(name: string, perm: Permissions) -> Error {
dir_fd, relative, ok := match_preopen(name)
if !ok {
return .Invalid_Path
@@ -23,7 +23,7 @@ _mkdir :: proc(name: string, perm: int) -> Error {
return _get_platform_error(wasi.path_create_directory(dir_fd, relative))
}
_mkdir_all :: proc(path: string, perm: int) -> Error {
_mkdir_all :: proc(path: string, perm: Permissions) -> Error {
if path == "" {
return .Invalid_Path
}

View File

@@ -13,7 +13,7 @@ _is_path_separator :: proc(c: byte) -> bool {
return c == '\\' || c == '/'
}
_mkdir :: proc(name: string, perm: int) -> Error {
_mkdir :: proc(name: string, perm: Permissions) -> Error {
temp_allocator := TEMP_ALLOCATOR_GUARD({})
if !win32.CreateDirectoryW(_fix_long_path(name, temp_allocator) or_return, nil) {
return _get_platform_error()
@@ -21,7 +21,7 @@ _mkdir :: proc(name: string, perm: int) -> Error {
return nil
}
_mkdir_all :: proc(path: string, perm: int) -> Error {
_mkdir_all :: proc(path: string, perm: Permissions) -> Error {
fix_root_directory :: proc(p: string) -> (s: string, allocated: bool, err: runtime.Allocator_Error) {
if len(p) == len(`\\?\c:`) {
if is_path_separator(p[0]) && is_path_separator(p[1]) && p[2] == '?' && is_path_separator(p[3]) && p[5] == ':' {