Skip to content

Commit 2963737

Browse files
committed
lexical is_subdir
1 parent 12a4ca1 commit 2963737

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

+stdlib/is_subdir.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
dir (1,1) string
77
end
88

9-
r = stdlib.relative_to(dir, subdir);
10-
11-
if stdlib.len(r) == 0 || r == "."
12-
s = false;
13-
elseif ischar(r)
14-
s = ~strncmp(r, '..', 2);
9+
if ischar(subdir)
10+
s = strfind(subdir, dir) == 1 && (length(subdir) > length(dir)); %#ok<UNRCH>
1511
else
16-
s = ~startsWith(r, "..");
12+
s = startsWith(subdir, dir) && (strlength(subdir) > strlength(dir));
1713
end
1814

1915
end

0 commit comments

Comments
 (0)