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()


Top ↑

Parameters

$file

(string)(Required)Path to the file.


Top ↑

Return

(string) Mode of the file (the last 3 digits).


Top ↑

Source

File: wp-admin/includes/class-wp-filesystem-direct.php

	public function getchmod( $file ) {
		return substr( decoct( @fileperms( $file ) ), -3 );
	}

Top ↑

Changelog

Changelog
VersionDescription
2.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.