File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ function s = suffix(path )
2
+ % SUFFIX last suffix of filename
3
+ arguments
4
+ path string
5
+ end
6
+
7
+ [~ , ~ , s ] = fileparts(path );
8
+
9
+ end
Original file line number Diff line number Diff line change @@ -40,6 +40,19 @@ function test_parent(tc)
40
40
41
41
end
42
42
43
+ function test_suffix(tc )
44
+
45
+ tc .verifyEmpty(stdlib .fileio .suffix(string .empty ))
46
+ tc .verifyEqual(stdlib .fileio .suffix(" " ), " " )
47
+
48
+ tc .verifyEqual(stdlib .fileio .suffix(" /foo/bar/baz" ), " " )
49
+ tc .verifyEqual(stdlib .fileio .suffix(" /foo/bar/baz/" ), " " )
50
+
51
+ tc .verifyEqual(stdlib .fileio .suffix(" foo/bar/baz.txt" ), " .txt" )
52
+ tc .verifyEqual(stdlib .fileio .suffix(" foo/bar/baz.txt.gz" ), " .gz" )
53
+
54
+ end
55
+
43
56
44
57
function test_stem(tc )
45
58
Original file line number Diff line number Diff line change
1
+ function s = suffix(p )
2
+ %% suffix(p)
3
+
4
+ arguments
5
+ p string
6
+ end
7
+
8
+ s = stdlib .fileio .suffix(p );
9
+
10
+ end
You can’t perform that action at this time.
0 commit comments