File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change
1
+ function mustBeScalarOrEmpty(x )
2
+
3
+ if ~(isempty(x ) || isscalar(x ))
4
+ throwAsCaller(MException(' MATLAB:validators:mustBeScalarOrEmpty' , " must be scalar or empty" ))
5
+ end
6
+
7
+ end
Original file line number Diff line number Diff line change 1
1
function issame = samepath(path1 , path2 )
2
2
%% samepath(path1, path)
3
3
% true if inputs resolve to same path
4
+ % files need not exist
5
+ % %% Inputs
6
+ % * path1, path2: paths to compare
7
+ % %% Outputs
8
+ % issame: logical
4
9
arguments
5
- path1 ( 1 , 1 ) string {mustBeNonzeroLengthText }
6
- path2 ( 1 , 1 ) string {mustBeNonzeroLengthText }
10
+ path1 string {mustBeScalarOrEmpty }
11
+ path2 string {mustBeScalarOrEmpty }
7
12
end
8
13
9
14
import stdlib.fileio.absolute_path
Original file line number Diff line number Diff line change @@ -12,6 +12,16 @@ function test_posix(tc)
12
12
tc .verifyFalse(contains(posix(" c:\foo" ), " \" ))
13
13
tc .verifyFalse(all(contains(posix([" x:\123" , " d:\abc" ]), " \" )))
14
14
end
15
+ end
16
+
17
+ function test_samepath(tc )
18
+ import stdlib .fileio .samepath
19
+
20
+ tc .verifyEmpty(samepath(string .empty , string .empty ))
21
+ tc .verifyTrue(samepath(" " , " " ))
22
+ tc .verifyFalse(samepath(" a" , " b" ))
23
+ tc .verifyTrue(samepath(" a/b/.." , " a/c/.." ))
24
+ tc .verifyTrue(samepath(" ." , " a/.." ))
15
25
16
26
end
17
27
You can’t perform that action at this time.
0 commit comments