File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change 11%% JAVA.SAMEPATH are inputs the same path
22
33function y = samepath(path1 , path2 )
4- arguments
5- path1 (1 ,1 ) string
6- path2 (1 ,1 ) string
7- end
84
9- if stdlib .exists(path1 ) && stdlib .exists(path2 )
10- j1 = javaPathObject(stdlib .absolute(path1 ));
11- j2 = javaPathObject(stdlib .absolute(path2 ));
5+ f1 = java .io .File(path1 );
6+ f2 = java .io .File(path2 );
127
13- y = java .nio .file .Files .isSameFile(j1 , j2 );
8+ if f1 .exists() && f2 .exists()
9+ p1 = file2absPath(f1 );
10+ p2 = file2absPath(f2 );
11+ y = java .nio .file .Files .isSameFile(p1 , p2 );
1412else
1513 y = false ;
1614end
1715
1816end
17+
18+
19+ function jpath = file2absPath(jfile )
20+ % java.lang.System.getProperty('user.path') is stuck to where Java started
21+
22+ jpath = jfile .toPath();
23+
24+ if ~jfile .isAbsolute()
25+ jpath = javaPathObject(pwd()).resolve(jpath );
26+ end
27+
28+ end
You can’t perform that action at this time.
0 commit comments