|
22 | 22 |
|
23 | 23 |
|
24 | 24 | if expand_tilde |
25 | | - c = stdlib.expanduser(p, use_java); |
| 25 | + e = stdlib.expanduser(p, use_java); |
26 | 26 | else |
27 | | - c = p; |
| 27 | + e = p; |
28 | 28 | end |
29 | 29 |
|
30 | | -if ispc && (startsWith(c, "\\") || startsWith(c, "//")) |
| 30 | +c = ""; |
| 31 | + |
| 32 | +if ~stdlib.len(e), return, end |
| 33 | + |
| 34 | +if ispc && (startsWith(e, "\\") || startsWith(e, "//")) |
31 | 35 | % UNC path is not canonicalized |
32 | 36 | return |
33 | 37 | end |
34 | 38 |
|
35 | | -if stdlib.exists(c, use_java) |
36 | | - if stdlib.isoctave() |
37 | | - % empty if any component of path does not exist |
38 | | - c = canonicalize_file_name(c); |
39 | | - elseif use_java |
40 | | - % incorrect result if any component of path does not exist |
41 | | - c = javaFileObject(c).getCanonicalPath(); |
42 | | - else |
43 | | - % errors if any component of path does not exist. |
44 | | - c = builtin('_canonicalizepath', c); |
| 39 | +if stdlib.isoctave() |
| 40 | +% empty if any component of path does not exist |
| 41 | + c = canonicalize_file_name(e); |
| 42 | +elseif use_java && stdlib.is_absolute(e, true) |
| 43 | +% incorrect result if relative path and any component of path does not exist |
| 44 | +% disp("java") |
| 45 | + c = javaFileObject(e).getCanonicalPath(); |
| 46 | +else |
| 47 | +% errors if any component of path does not exist. |
| 48 | +% disp("builtin") |
| 49 | + try %#ok<TRYNC> |
| 50 | + c = builtin('_canonicalizepath', e); |
45 | 51 | end |
46 | | -elseif stdlib.len(c) |
47 | | - c = stdlib.normalize(c, use_java); |
| 52 | +end |
| 53 | + |
| 54 | +if ~stdlib.len(c) |
| 55 | + c = stdlib.normalize(e, use_java); |
48 | 56 | end |
49 | 57 |
|
50 | 58 | c = stdlib.posix(c); |
|
0 commit comments