-
Notifications
You must be signed in to change notification settings - Fork 1
/
os.ncl
37 lines (28 loc) · 860 Bytes
/
os.ncl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
; Functions for working with the OS
undef("os_path_join")
function os_path_join(segments)
; Joins segments (of varying type) into a path
; Args:
; segments (iterable) : List (or 1D array) of items
; Returns:
; joined (string) : String of joined path
local _segments, i
begin
; 1D array of numerical things
if (isnumeric(segments)) then
return str_join(tostring(segments), "/")
; 1D array of strings
else if (isstring(segments))
return str_join(segments, "/")
; List of mixed items
else if (typeof(segments).eq."list") then
; Need to convert to an array internally
_segments = new(ListCount(segments), string)
do i = 0, ListCount(segments) - 1
_segments(i) = tostring(segments[i])
end do
return os_path_join(_segments)
end if
end if
end if
end