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

File::isAccessable #60

Open
tristanlins opened this issue Jan 10, 2013 · 3 comments
Open

File::isAccessable #60

tristanlins opened this issue Jan 10, 2013 · 3 comments

Comments

@tristanlins
Copy link
Member

@see #60 (comment)

The accessability differ between files and directories (in a unix permission environment).

A file is accessable if it is readable.
A directory is accessable if it is executeable and readable (for content listing).

How about add a convenience method File::isAccessable:

class File::isAccessable {
    public function isAccessable() {
        if ($this->isFile()) {
            return $this->isReadable();
        }
        else if ($this->isDirectory()) {
            return $this->isExecuteable() && $this->isReadable();
        }
    }
}

According to #49 this may be extracted to the permission interface, to allow the permission manager check the accessablility.

@ghost ghost assigned tristanlins Jan 10, 2013
@backbone87
Copy link
Member

What is the behavior in unix for:

  • Directories that are only readable
  • Directories that are only executeable

Without the answers for mentioned questions my current point would be to let be "isReadable" and "isExecuteable" to be synonymous for directories.

@tristanlins
Copy link
Member Author

Directories that are only readable are not accessable -> false
Directories that are only executeable can be accessed, but not readed -> false

In other word, isAccessable will only return true if the target can be read. For directories this means, it have also be executeable.

@discordier
Copy link
Member

IMO we should drop this method altogether in favor of:

class File {
    public function isListable() {
        if ($this->isFile()) {
            return false;
        }
        else if ($this->isDirectory()) {
            return $this->isExecuteable() && $this->isReadable();
        }
    }
}

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

No branches or pull requests

3 participants