rm js fns
This commit is contained in:
32
cellfs.cm
32
cellfs.cm
@@ -24,14 +24,14 @@ function normalize_path(path) {
|
||||
function dirname(path) {
|
||||
var idx = path.lastIndexOf("/")
|
||||
if (idx == -1) return ""
|
||||
return path.substring(0, idx)
|
||||
return text(path, 0, idx)
|
||||
}
|
||||
|
||||
// Helper to get basename from path
|
||||
function basename(path) {
|
||||
var idx = path.lastIndexOf("/")
|
||||
if (idx == -1) return path
|
||||
return path.substring(idx + 1)
|
||||
return text(path, idx + 1)
|
||||
}
|
||||
|
||||
// Helper to join paths
|
||||
@@ -102,17 +102,17 @@ function resolve(path, must_exist) {
|
||||
path = normalize_path(path)
|
||||
|
||||
// Check for named mount
|
||||
if (path.startsWith("@")) {
|
||||
if (starts_with(path, "@")) {
|
||||
var idx = path.indexOf("/")
|
||||
var mount_name = ""
|
||||
var rel_path = ""
|
||||
|
||||
if (idx == -1) {
|
||||
mount_name = path.substring(1)
|
||||
mount_name = text(path, 1)
|
||||
rel_path = ""
|
||||
} else {
|
||||
mount_name = path.substring(1, idx)
|
||||
rel_path = path.substring(idx + 1)
|
||||
mount_name = text(path, 1, idx)
|
||||
rel_path = text(path, idx + 1)
|
||||
}
|
||||
|
||||
// Find named mount
|
||||
@@ -229,7 +229,7 @@ function slurpwrite(path, data) {
|
||||
// Check existence
|
||||
function exists(path) {
|
||||
var res = resolve(path, false)
|
||||
if (path.startsWith("@")) {
|
||||
if (starts_with(path, "@")) {
|
||||
return mount_exists(res.mount, res.path)
|
||||
}
|
||||
return res != null
|
||||
@@ -365,14 +365,14 @@ function enumerate(path, recurse) {
|
||||
var seen = {}
|
||||
|
||||
for (var p of all) {
|
||||
if (p.startsWith(prefix)) {
|
||||
var rel = p.substring(prefix_len)
|
||||
if (starts_with(p, prefix)) {
|
||||
var rel = text(p, prefix_len)
|
||||
if (rel.length == 0) continue
|
||||
|
||||
|
||||
if (!recurse) {
|
||||
var slash = rel.indexOf('/')
|
||||
if (slash != -1) {
|
||||
rel = rel.substring(0, slash)
|
||||
rel = text(rel, 0, slash)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,14 +394,14 @@ function globfs(globs, dir) {
|
||||
|
||||
function check_neg(path) {
|
||||
for (var g of globs) {
|
||||
if (g.startsWith("!") && wildstar.match(g.substring(1), path, wildstar.WM_WILDSTAR)) return true;
|
||||
if (starts_with(g, "!") && wildstar.match(text(g, 1), path, wildstar.WM_WILDSTAR)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_pos(path) {
|
||||
for (var g of globs) {
|
||||
if (!g.startsWith("!") && wildstar.match(g, path, wildstar.WM_WILDSTAR)) return true;
|
||||
if (!starts_with(g, "!") && wildstar.match(g, path, wildstar.WM_WILDSTAR)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -442,10 +442,10 @@ function globfs(globs, dir) {
|
||||
var prefix_len = prefix.length
|
||||
|
||||
for (var p of all) {
|
||||
if (p.startsWith(prefix)) {
|
||||
var rel = p.substring(prefix_len)
|
||||
if (starts_with(p, prefix)) {
|
||||
var rel = text(p, prefix_len)
|
||||
if (rel.length == 0) continue
|
||||
|
||||
|
||||
if (!check_neg(rel) && check_pos(rel)) {
|
||||
results.push(rel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user