12 lines
410 B
JavaScript
12 lines
410 B
JavaScript
function dirname(p/*:string*/)/*:string*/ {
|
|
if(p.charAt(p.length - 1) == "/") return (p.slice(0,-1).indexOf("/") === -1) ? p : dirname(p.slice(0, -1));
|
|
var c = p.lastIndexOf("/");
|
|
return (c === -1) ? p : p.slice(0, c+1);
|
|
}
|
|
|
|
function filename(p/*:string*/)/*:string*/ {
|
|
if(p.charAt(p.length - 1) == "/") return filename(p.slice(0, -1));
|
|
var c = p.lastIndexOf("/");
|
|
return (c === -1) ? p : p.slice(c+1);
|
|
}
|