Remove usage of do in core library

This commit is contained in:
gingerBill
2020-09-23 17:17:14 +01:00
parent 4844dd4d96
commit fc4fdd588e
45 changed files with 960 additions and 520 deletions
+15 -5
View File
@@ -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);
+3 -3
View File
@@ -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;
+12 -4
View File
@@ -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);