pathDirectory function
URL/Path More: directory from path, base name, path separator, is absolute, etc. Roadmap #336-345.
Implementation
String pathDirectory(String path) {
final String p = path.replaceAll(r'\', '/');
final int i = p.lastIndexOf('/');
return i <= 0 ? (p.startsWith('/') ? '/' : '') : p.replaceRange(i, p.length, '');
}