WP_Filesystem_Direct::getchmod() WordPress Method
The WP_Filesystem_Direct::getchmod() function is used to get the permissions of a file or directory. This function is similar to the Unix stat() function. The mode parameter can be one of the following values: • 0 - Returns the permissions as an octal number (e.g. 0644) • 1 - Returns the permissions as a string (e.g. "rw-r--r--") • 2 - Returns the permissions as an array with the keys "owner", "group", and "other" If the file or directory does not exist, WP_Filesystem_Direct::getchmod() will return FALSE.
WP_Filesystem_Direct::getchmod( string $file ) #
Gets the permissions of the specified file or filepath in their octal format.
Description
FIXME does not handle errors in fileperms()
Parameters
- $file
(string)(Required)Path to the file.
Return
(string) Mode of the file (the last 3 digits).
Source
File: wp-admin/includes/class-wp-filesystem-direct.php
public function getchmod( $file ) { return substr( decoct( @fileperms( $file ) ), -3 ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |