Function symbolic_common::split_path_bytes[][src]

pub fn split_path_bytes(path: &[u8]) -> (Option<&[u8]>, &[u8])

Splits off the last component of a path given as bytes.

The path should be a path to a file, and not a directory with a trailing directory separator. If this path is a directory or the root path, the result is undefined.

This attempts to detect Windows or Unix paths and split off the last component of the path accordingly. Note that for paths with mixed slash and backslash separators this might not lead to the desired results.

Note: This is the same as split_path, except that it operates on byte slices.

Examples

Split the last component of a UNIX path:

assert_eq!(
    symbolic_common::split_path_bytes(b"/a/b/c"),
    (Some("/a/b".as_bytes()), "c".as_bytes())
);

Split the last component of a Windows path:

assert_eq!(
    symbolic_common::split_path_bytes(b"C:\\a\\b"),
    (Some("C:\\a".as_bytes()), "b".as_bytes())
);