mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-28 18:30:06 +00:00
Remove usage of do in core library
This commit is contained in:
+15
-5
@@ -6,7 +6,9 @@ import "core:unicode/utf8"
|
||||
|
||||
// returns everything preceding the last path element
|
||||
dir :: proc(path: string, new := false, allocator := context.allocator) -> string {
|
||||
if path == "" do return "";
|
||||
if path == "" {
|
||||
return "";
|
||||
}
|
||||
|
||||
for i := len(path) - 1; i >= 0; i -= 1 {
|
||||
if path[i] == '/' || path[i] == '\\' {
|
||||
@@ -25,7 +27,9 @@ dir :: proc(path: string, new := false, allocator := context.allocator) -> strin
|
||||
|
||||
// returns the final path element
|
||||
base :: proc(path: string, new := false, allocator := context.allocator) -> string {
|
||||
if path == "" do return "";
|
||||
if path == "" {
|
||||
return "";
|
||||
}
|
||||
|
||||
end := len(path) - 1;
|
||||
|
||||
@@ -46,7 +50,9 @@ base :: proc(path: string, new := false, allocator := context.allocator) -> stri
|
||||
|
||||
// returns the final path element, excluding the file extension if there is one
|
||||
name :: proc(path: string, new := false, allocator := context.allocator) -> string {
|
||||
if path == "" do return "";
|
||||
if path == "" {
|
||||
return "";
|
||||
}
|
||||
|
||||
end := len(path) - 1;
|
||||
dot := end;
|
||||
@@ -64,7 +70,9 @@ name :: proc(path: string, new := false, allocator := context.allocator) -> stri
|
||||
|
||||
// returns the file extension, if there is one
|
||||
ext :: proc(path: string, new := false, allocator := context.allocator) -> string {
|
||||
if path == "" do return "";
|
||||
if path == "" {
|
||||
return "";
|
||||
}
|
||||
|
||||
for i := len(path)-1; i >= 0; i -= 1 {
|
||||
switch path[i] {
|
||||
@@ -82,7 +90,9 @@ rel :: proc{rel_between, rel_current};
|
||||
|
||||
// returns the relative path from one path to another
|
||||
rel_between :: proc(from, to: string, allocator := context.allocator) -> string {
|
||||
if from == "" || to == "" do return "";
|
||||
if from == "" || to == "" {
|
||||
return "";
|
||||
}
|
||||
|
||||
from, to := from, to;
|
||||
from = full(from, context.temp_allocator);
|
||||
|
||||
@@ -60,21 +60,21 @@ current :: proc(allocator := context.temp_allocator) -> string {
|
||||
|
||||
|
||||
exists :: proc(path: string) -> bool {
|
||||
if _, ok := os.stat(path); ok {
|
||||
if _, err := os.stat(path); err != 0 {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
is_dir :: proc(path: string) -> bool {
|
||||
if stat, ok := os.stat(path); ok {
|
||||
if stat, err := os.stat(path); err != 0 {
|
||||
return os.S_ISDIR(u32(stat.mode));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
is_file :: proc(path: string) -> bool {
|
||||
if stat, ok := os.stat(path); ok {
|
||||
if stat, err := os.stat(path); err != 0 {
|
||||
return os.S_ISREG(u32(stat.mode));
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -23,7 +23,9 @@ long :: proc(path: string, allocator := context.temp_allocator) -> string {
|
||||
c_path := win32.utf8_to_wstring(path, context.temp_allocator);
|
||||
length := win32.GetLongPathNameW(c_path, nil, 0);
|
||||
|
||||
if length == 0 do return "";
|
||||
if length == 0 {
|
||||
return "";
|
||||
}
|
||||
|
||||
buf := make([]u16, length, context.temp_allocator);
|
||||
|
||||
@@ -38,7 +40,9 @@ short :: proc(path: string, allocator := context.temp_allocator) -> string {
|
||||
c_path := win32.utf8_to_wstring(path, context.temp_allocator);
|
||||
length := win32.GetShortPathNameW(c_path, nil, 0);
|
||||
|
||||
if length == 0 do return "";
|
||||
if length == 0 {
|
||||
return "";
|
||||
}
|
||||
|
||||
buf := make([]u16, length, context.temp_allocator);
|
||||
|
||||
@@ -53,7 +57,9 @@ full :: proc(path: string, allocator := context.temp_allocator) -> string {
|
||||
c_path := win32.utf8_to_wstring(path, context.temp_allocator);
|
||||
length := win32.GetFullPathNameW(c_path, 0, nil, nil);
|
||||
|
||||
if length == 0 do return "";
|
||||
if length == 0 {
|
||||
return "";
|
||||
}
|
||||
|
||||
buf := make([]u16, length, context.temp_allocator);
|
||||
|
||||
@@ -67,7 +73,9 @@ full :: proc(path: string, allocator := context.temp_allocator) -> string {
|
||||
current :: proc(allocator := context.temp_allocator) -> string {
|
||||
length := win32.GetCurrentDirectoryW(0, nil);
|
||||
|
||||
if length == 0 do return "";
|
||||
if length == 0 {
|
||||
return "";
|
||||
}
|
||||
|
||||
buf := make([]u16, length, context.temp_allocator);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user