blob: c5ede65a22d7aa37add15fe4bd00da854bdc6020 (
plain)
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
|
//! AFS location utilities
pub fn parent(location: []const u8) []const u8 {
var i: usize = location.len;
while (i > 0) : (i -= 1) {
if (location[i - 1] == '/') {
if (i == 1) return "/";
return location[0 .. i - 1];
}
}
return "/";
}
pub fn identity(location: []const u8) []const u8 {
var i: usize = location.len;
while (i > 0) : (i -= 1) {
if (location[i - 1] == '/') {
return location[i..];
}
}
return location;
}
pub fn is_absolute(location: []const u8) bool {
return location.len > 0 and location[0] == '/';
}
pub fn skip_root(location: []const u8) usize {
return if (is_absolute(location)) 1 else 0;
}
|