We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent db3125f commit 2b5de28Copy full SHA for 2b5de28
+stdlib/filename.m
@@ -2,22 +2,27 @@
2
% filename (including suffix) without directory
3
4
function f = filename(p)
5
-% arguments
6
-% p (1,1) string
7
-% end
+arguments
+ p (1,1) string
+end
8
9
% NOT https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/File.html#getName()
10
% because by our definition, a trailing directory component is not part of the filename
11
% this is like C++17 filesystem::path::filename
12
13
-[~, n, e] = fileparts(p);
+p = stdlib.posix(p);
14
+
15
+i = strfind(p, "/");
16
-if ischar(n)
- f = strcat(n, e);
17
+if isempty(i)
18
+ f = p;
19
+elseif ischar(p)
20
+ f = p(i(end)+1:end);
21
else
- f = n + e;
22
+ f = extractAfter(p, i(end));
23
end
24
25
26
27
28
0 commit comments