File tree Expand file tree Collapse file tree 4 files changed +38
-32
lines changed Expand file tree Collapse file tree 4 files changed +38
-32
lines changed Original file line number Diff line number Diff line change 1+ function c = canonical(file , strict )
2+
3+ if stdlib .strempty(file )
4+ c = " " ;
5+ return
6+ end
7+
8+ p = matlab .io .internal .filesystem .resolvePath(file );
9+ c = p .ResolvedPath ;
10+
11+ if ~strict && stdlib .strempty(c )
12+ c = string(stdlib .normalize(file ));
13+ end
14+
15+ end
Original file line number Diff line number Diff line change 1+ function c = canonical_legacy(file , strict )
2+
3+ c = " " ;
4+
5+ if stdlib .strempty(file ), return , end
6+
7+ [s , r ] = fileattrib(file );
8+
9+ if s == 1
10+ c = r .Name ;
11+ elseif ~strict
12+ c = stdlib .normalize(file );
13+ end
14+
15+ c = string(c );
16+
17+ end
Original file line number Diff line number Diff line change 1515function c = canonical(p , strict )
1616arguments
1717 p {mustBeTextScalar }
18- strict logical = false
18+ strict ( 1 , 1 ) logical = false
1919end
2020
21- if stdlib .strempty(p )
22- c = " " ;
23- return
24- end
2521
2622if isMATLABReleaseOlderThan(' R2024a' )
27- c = acanon (p , strict );
23+ c = stdlib . native .canonical_legacy (p , strict );
2824else
29- pth = matlab .io .internal .filesystem .resolvePath(p );
30- c = pth .ResolvedPath ;
31- if ~strict && stdlib .strempty(c )
32- c = stdlib .normalize(p );
33- end
34- end
35-
36- c = string(c );
37-
38- end
39-
40-
41- function c = acanon(p , strict )
42-
43- c = " " ;
44-
45- if stdlib .strempty(p ), return , end
46-
47- [s , r ] = fileattrib(p );
48-
49- if s == 1
50- c = r .Name ;
51- elseif ~strict
52- c = stdlib .normalize(p );
25+ c = stdlib .native .canonical(p , strict );
5326end
5427
5528end
Original file line number Diff line number Diff line change 99{" not-exist/a/.." , " not-exist" }, ...
1010{" ./not-exist" , " not-exist" }
1111};
12+ fun = {@stdlib.canonical, @stdlib.native.canonical, @stdlib.native.canonical_legacy}
1213end
1314
1415methods (TestClassSetup )
@@ -21,8 +22,8 @@ function pkg_path(tc)
2122
2223methods (Test , TestTags = " impure" )
2324
24- function test_canonical(tc , p )
25- tc .verifyEqual(stdlib .canonical (p{1 }), p{2 })
25+ function test_canonical(tc , p , fun )
26+ tc .verifyEqual(fun (p{1 }, false ), p{2 })
2627end
2728
2829end
You can’t perform that action at this time.
0 commit comments