diff options
| author | ftphikari <ftphikari@gmail.com> | 2022-06-08 19:55:42 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-08 19:55:42 +0300 |
| commit | 5d4291d9fa5921ebfcaf7be6bc1dbb18197c02ec (patch) | |
| tree | 6d6d6668795b59b0ddbdd947359d2900b4fda6c8 /core/sys | |
| parent | b70cd03e9ef2445d35dc5da9d58f2c79c3f4f7f5 (diff) | |
| parent | bfcb527b42832868ce0edf9817b3a00a933dcde8 (diff) | |
Merge branch 'odin-lang:master' into master
Diffstat (limited to 'core/sys')
| -rw-r--r-- | core/sys/windows/comdlg32.odin | 5 | ||||
| -rw-r--r-- | core/sys/windows/util.odin | 17 |
2 files changed, 19 insertions, 3 deletions
diff --git a/core/sys/windows/comdlg32.odin b/core/sys/windows/comdlg32.odin index 0f5b29789..8284050f1 100644 --- a/core/sys/windows/comdlg32.odin +++ b/core/sys/windows/comdlg32.odin @@ -2,7 +2,6 @@ package sys_windows foreign import "system:Comdlg32.lib" -import "core:strings" LPOFNHOOKPROC :: #type proc "stdcall" (hdlg: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> UINT_PTR @@ -47,6 +46,9 @@ SAVE_TITLE :: "Select file to save" SAVE_FLAGS :: u32(OFN_OVERWRITEPROMPT | OFN_EXPLORER) SAVE_EXT :: "txt" +/* +import "core:strings" + Open_Save_Mode :: enum { Open = 0, Save = 1, @@ -119,6 +121,7 @@ select_file_to_save :: proc(title := SAVE_TITLE, dir := ".", path, ok = _open_file_dialog(title, dir, filters, default_filter, flags, default_ext, Open_Save_Mode.Save, allocator) return } +*/ // TODO: Implement convenience function for select_file_to_open with ALLOW_MULTI_SELECT that takes // it output of the form "path\u0000\file1u\0000file2" and turns it into []string with the path + file pre-concatenated for you. diff --git a/core/sys/windows/util.odin b/core/sys/windows/util.odin index 1c8b9175b..c350032f0 100644 --- a/core/sys/windows/util.odin +++ b/core/sys/windows/util.odin @@ -1,7 +1,6 @@ // +build windows package sys_windows -import "core:strings" import "core:runtime" import "core:intrinsics" @@ -100,6 +99,20 @@ utf16_to_utf8 :: proc(s: []u16, allocator := context.temp_allocator) -> (res: st // AdvAPI32, NetAPI32 and UserENV helpers. allowed_username :: proc(username: string) -> bool { + contains_any :: proc(s, chars: string) -> bool { + if chars == "" { + return false + } + for c in transmute([]byte)s { + for b in transmute([]byte)chars { + if c == b { + return true + } + } + } + return false + } + /* User account names are limited to 20 characters and group names are limited to 256 characters. In addition, account names cannot be terminated by a period and they cannot include commas or any of the following printable characters: @@ -120,7 +133,7 @@ allowed_username :: proc(username: string) -> bool { return false } } - if strings.contains_any(username, _DISALLOWED) { + if contains_any(username, _DISALLOWED) { return false } |