rootPrefix method
Returns the root of path
if it's absolute, or an empty string if it's
relative.
// Unix
context.rootPrefix('path/to/foo'); // -> ''
context.rootPrefix('/path/to/foo'); // -> '/'
// Windows
context.rootPrefix(r'path\to\foo'); // -> ''
context.rootPrefix(r'C:\path\to\foo'); // -> r'C:\'
// URL
context.rootPrefix('path/to/foo'); // -> ''
context.rootPrefix('http://dartlang.org/path/to/foo');
// -> 'http://dartlang.org'
Implementation
String rootPrefix(String path) => path.substring(0, style.rootLength(path));