File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ function p = filename(path )
2
+ % FILENAME filename (including suffix) without directory
3
+ arguments
4
+ path string
5
+ end
6
+
7
+ [~ , n , e ] = fileparts(path );
8
+
9
+ p = n + e ;
10
+
11
+ end
Original file line number Diff line number Diff line change @@ -14,6 +14,20 @@ function test_posix(tc)
14
14
end
15
15
16
16
17
+ function test_filename(tc )
18
+
19
+ tc .verifyEmpty(stdlib .fileio .filename(string .empty ))
20
+ tc .verifyEqual(stdlib .fileio .filename(" " ), " " )
21
+
22
+ tc .verifyEqual(stdlib .fileio .filename(" /foo/bar/baz" ), " baz" )
23
+ tc .verifyEqual(stdlib .fileio .filename(" /foo/bar/baz/" ), " " )
24
+
25
+ tc .verifyEqual(stdlib .fileio .filename(" foo/bar/baz.txt" ), " baz.txt" )
26
+ tc .verifyEqual(stdlib .fileio .filename(" foo/bar/baz.txt.gz" ), " baz.txt.gz" )
27
+
28
+ end
29
+
30
+
17
31
function test_parent(tc )
18
32
19
33
tc .verifyEmpty(stdlib .fileio .parent(string .empty ))
Original file line number Diff line number Diff line change
1
+ function p = filename(path )
2
+ % FILENAME filename (including suffix) without directory
3
+ arguments
4
+ path string
5
+ end
6
+
7
+ p = stdlib .fileio .filename(path );
8
+
9
+ end
You can’t perform that action at this time.
0 commit comments