File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed
src/plugins/system/android/com/foxdebug/system Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -691,14 +691,29 @@ private void hasPermission(String permission, CallbackContext callback) {
691691 }
692692
693693 public boolean fileExists (String path , String countSymlinks ) {
694- Path p = new File (path ).toPath ();
694+ boolean followSymlinks = !Boolean .parseBoolean (countSymlinks );
695+ File file = new File (path );
696+
697+ // Android < O does not implement File#toPath(), fall back to legacy checks
698+ if (Build .VERSION .SDK_INT < Build .VERSION_CODES .O ) {
699+ if (!file .exists ()) return false ;
700+ if (followSymlinks ) {
701+ try {
702+ // If canonical and absolute paths differ, it's a symlink
703+ return file .getCanonicalPath ().equals (file .getAbsolutePath ());
704+ } catch (IOException ignored ) {
705+ return false ;
706+ }
707+ }
708+ return true ;
709+ }
710+
711+ Path p = file .toPath ();
695712 try {
696- if (Boolean .parseBoolean (countSymlinks )) {
697- // This will return true even for broken symlinks
698- return Files .exists (p , LinkOption .NOFOLLOW_LINKS );
699- } else {
700- // Check target file, not symlink itself
713+ if (followSymlinks ) {
701714 return Files .exists (p ) && !Files .isSymbolicLink (p );
715+ } else {
716+ return Files .exists (p , LinkOption .NOFOLLOW_LINKS );
702717 }
703718 } catch (Exception e ) {
704719 return false ;
@@ -1301,4 +1316,4 @@ private void setInputType(String type) {
13011316 }
13021317 webView .setInputType (mode );
13031318 }
1304- }
1319+ }
You can’t perform that action at this time.
0 commit comments