Skip to content

Commit

Permalink
lexical is_subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Dec 9, 2024
1 parent 12a4ca1 commit 2963737
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions +stdlib/is_subdir.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
dir (1,1) string
end

r = stdlib.relative_to(dir, subdir);

if stdlib.len(r) == 0 || r == "."
s = false;
elseif ischar(r)
s = ~strncmp(r, '..', 2);
if ischar(subdir)
s = strfind(subdir, dir) == 1 && (length(subdir) > length(dir)); %#ok<UNRCH>
else
s = ~startsWith(r, "..");
s = startsWith(subdir, dir) && (strlength(subdir) > strlength(dir));
end

end
Expand Down

0 comments on commit 2963737

Please sign in to comment.