1 | module os |
2 | |
3 | // windows_volume returns the volume name from the given `path` on a Windows system. |
4 | // An empty string is returned if no Windows volume is present. |
5 | // Examples (on a Windows system): |
6 | // ```v |
7 | // assert os.windows_volume(r'C:\path\to\file.v') == 'C:' |
8 | // assert os.windows_volume('D:') == 'D:' |
9 | // assert os.windows_volume(r'\\Host\share\files\file.v') == r'\\Host\share' |
10 | // ``` |
11 | pub fn windows_volume(path string) string { |
12 | volume_len := win_volume_len(path) |
13 | if volume_len == 0 { |
14 | return empty_str |
15 | } |
16 | return path[..volume_len] |
17 | } |