Skip to content

Commit 86de75c

Browse files
committed
filename: no posix
1 parent e0385be commit 86de75c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

+stdlib/filename.m

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414
% because by our definition, a trailing directory component is not part of the filename
1515
% this is like C++17 filesystem::path::filename
1616

17-
parts = strsplit(stdlib.posix(p), '/');
17+
if isunix()
18+
pat = '[^/]*$';
19+
else
20+
pat = ['[^/\\]*$'];
21+
end
1822

19-
f = parts{end};
23+
m = regexp(p, pat, 'match', 'once');
2024

21-
if isstring(p)
22-
f = string(f);
25+
if isstring(p) && ismissing(m)
26+
f = "";
27+
else
28+
f = m;
2329
end
2430

2531
end

0 commit comments

Comments
 (0)