Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to detect symbolic link and permissions in RemoteFile #155

Open
jpage4500 opened this issue May 9, 2024 · 1 comment
Open

How to detect symbolic link and permissions in RemoteFile #155

jpage4500 opened this issue May 9, 2024 · 1 comment

Comments

@jpage4500
Copy link

jpage4500 commented May 9, 2024

Hi @vidstige,

First off - thanks for this library! It's a huge improvement for me over calling 'adb' from my app in bash scripts.

I wanted to write a simple file explorer with this library and had a couple of questions:

  1. Is there a way to detect a folder link / alias? For example /sdcard on my device is a symbolic link to another folder. But, RemoteFile.isDirectory() returns false.

I imagine there's a way to detect this using the mode but I haven't figured out exactly just yet. Any thoughts?

lrw-r--r--   1 root   root         21 2008-12-31 10:00 sdcard -> /storage/self/primary
    public boolean isDirectory() {
        return (mode & (1 << 14)) == (1 << 14);
    }
  1. Is there a way to detect if a folder is read-only and can't be listed? Or, alternatively if I try to view a folder that doesn't exist I just get back 0 results -- same as an empty folder. I'm looking for some way to know that this isn't a valid folder or isn't one that the user has permission to view (JadbDevice.list())
@vidstige
Copy link
Owner

Hi!
Thanks for your appreciation. It was a long time since I made this so don't really know the answers here, but I'll try

  1. You should be able to figure out if an entry is a symlink by looking at the mode. Don't remember by heart which bit this is, but it should be documented somewhere.
  2. Again, this should be visible from the mode bits. Might be tricky to fully determine as it depends on your group and so on. You should really get a permission denied or similar when trying to list the files in there? Might be some weird behaviour in jadb or in the adb server that needs to be patched in the AOSP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants