File tree Expand file tree Collapse file tree 2 files changed +21
-16
lines changed Expand file tree Collapse file tree 2 files changed +21
-16
lines changed Original file line number Diff line number Diff line change 11function p = parent(pth )
2-
3- f = fullfile(char(pth ));
4- if endsWith(f , {' /' , filesep }) && ~strcmp(f , stdlib .root(f ))
5- f = f(1 : end - 1 );
2+ arguments
3+ pth string
64end
75
6+ f = fullfile(pth );
7+
8+ i = endsWith(f , [" /" , filesep ]) & ~strcmp(f , stdlib .root(f ));
9+
10+ f(i ) = extractBefore(f(i ), strlength(f(i )));
11+
812p = fileparts(f );
913
10- if stdlib .strempty(p )
11- p = ' .' ;
12- elseif ispc() && strcmp(p , stdlib .root_name(pth ))
13- p = strcat(p , filesep );
14- end
14+ i = stdlib .strempty(p );
15+ p(i ) = " ." ;
1516
16- p = string(p );
17+ i = ispc() & strcmp(p(~i ), stdlib .root_name(pth ));
18+ p(i ) = strcat(p(i ), filesep );
1719
1820end
Original file line number Diff line number Diff line change 44% stdlib.parent("a/b/c") == "a/b"
55% stdlib.parent("a/b/c/") == "a/b"
66
7- function p = parent(pth , backend )
7+ function par = parent(file , backend )
88arguments
9- pth { mustBeTextScalar }
10- backend (1 ,: )string = [" java" , " python" , " native" ]
9+ file string
10+ backend (1 ,: ) string = [" java" , " python" , " native" ]
1111end
1212
13- fun = hbackend(backend , " parent" );
14-
15- p = fun(pth );
13+ if isscalar(file )
14+ fun = hbackend(backend , " parent" );
15+ par = fun(file );
16+ else
17+ par = stdlib .native .parent(file );
18+ end
1619
1720end
You can’t perform that action at this time.
0 commit comments