File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change
1
+ function p = stem(path )
2
+ % STEM filename without directory or suffix
3
+ arguments
4
+ path string
5
+ end
6
+
7
+ [~ , p ] = fileparts(path );
8
+
9
+ end
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ function test_posix(tc)
16
16
17
17
function test_parent(tc )
18
18
19
- tc .assertEmpty (stdlib .fileio .parent(string .empty ))
19
+ tc .verifyEmpty (stdlib .fileio .parent(string .empty ))
20
20
tc .verifyEqual(stdlib .fileio .parent(" " ), " " )
21
21
22
22
tc .verifyEqual(stdlib .fileio .parent(" /foo/bar/baz" ), " /foo/bar" )
@@ -27,6 +27,22 @@ function test_parent(tc)
27
27
end
28
28
29
29
30
+ function test_stem(tc )
31
+
32
+ tc .verifyEmpty(stdlib .fileio .stem(string .empty ))
33
+ tc .verifyEqual(stdlib .fileio .stem(" " ), " " )
34
+
35
+ tc .verifyEqual(stdlib .fileio .stem(" /foo/bar/baz" ), " baz" )
36
+ tc .verifyEqual(stdlib .fileio .stem(" /foo/bar/baz/" ), " " )
37
+
38
+ tc .verifyEqual(stdlib .fileio .stem(" foo/bar/baz/" ), " " )
39
+
40
+ tc .verifyEqual(stdlib .fileio .stem(" foo/bar/baz.txt" ), " baz" )
41
+ tc .verifyEqual(stdlib .fileio .stem(" foo/bar/baz.txt.gz" ), " baz.txt" )
42
+
43
+ end
44
+
45
+
30
46
function test_path_tail(tc )
31
47
32
48
import stdlib.path_tail
Original file line number Diff line number Diff line change
1
+ function p = stem(path )
2
+ % STEM filename without directory or suffix
3
+ arguments
4
+ path string
5
+ end
6
+
7
+ p = stdlib .fileio .stem(path );
8
+
9
+ end
You can’t perform that action at this time.
0 commit comments