]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-wp-filesystem-direct.php
WordPress 4.0
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-filesystem-direct.php
index d07305bc1dda3cd7ddb13dd93d4cca78a763e51d..a426bd273fd54430f4069899c690f18c13c5ce60 100644 (file)
@@ -9,7 +9,7 @@
 /**
  * WordPress Filesystem Class for direct PHP file and folder manipulation.
  *
 /**
  * WordPress Filesystem Class for direct PHP file and folder manipulation.
  *
- * @since 2.5
+ * @since 2.5.0
  * @package WordPress
  * @subpackage Filesystem
  * @uses WP_Filesystem_Base Extends class
  * @package WordPress
  * @subpackage Filesystem
  * @uses WP_Filesystem_Base Extends class
@@ -21,7 +21,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         *
         * @param mixed $arg ignored argument
         */
         *
         * @param mixed $arg ignored argument
         */
-       function __construct($arg) {
+       public function __construct($arg) {
                $this->method = 'direct';
                $this->errors = new WP_Error();
        }
                $this->method = 'direct';
                $this->errors = new WP_Error();
        }
@@ -32,7 +32,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         * @param string $file Name of the file to read.
         * @return string|bool The function returns the read data or false on failure.
         */
         * @param string $file Name of the file to read.
         * @return string|bool The function returns the read data or false on failure.
         */
-       function get_contents($file) {
+       public function get_contents($file) {
                return @file_get_contents($file);
        }
 
                return @file_get_contents($file);
        }
 
@@ -42,7 +42,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         * @param string $file Path to the file.
         * @return array|bool the file contents in an array or false on failure.
         */
         * @param string $file Path to the file.
         * @return array|bool the file contents in an array or false on failure.
         */
-       function get_contents_array($file) {
+       public function get_contents_array($file) {
                return @file($file);
        }
 
                return @file($file);
        }
 
@@ -54,7 +54,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         * @param int $mode (optional) The file permissions as octal number, usually 0644.
         * @return bool False upon failure.
         */
         * @param int $mode (optional) The file permissions as octal number, usually 0644.
         * @return bool False upon failure.
         */
-       function put_contents( $file, $contents, $mode = false ) {
+       public function put_contents( $file, $contents, $mode = false ) {
                $fp = @fopen( $file, 'wb' );
                if ( ! $fp )
                        return false;
                $fp = @fopen( $file, 'wb' );
                if ( ! $fp )
                        return false;
@@ -82,7 +82,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         *
         * @return string|bool the current working directory on success, or false on failure.
         */
         *
         * @return string|bool the current working directory on success, or false on failure.
         */
-       function cwd() {
+       public function cwd() {
                return @getcwd();
        }
 
                return @getcwd();
        }
 
@@ -92,7 +92,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         * @param string $dir The new current directory.
         * @return bool Returns true on success or false on failure.
         */
         * @param string $dir The new current directory.
         * @return bool Returns true on success or false on failure.
         */
-       function chdir($dir) {
+       public function chdir($dir) {
                return @chdir($dir);
        }
 
                return @chdir($dir);
        }
 
@@ -104,7 +104,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         * @param bool $recursive (optional) If set True changes file group recursively. Defaults to False.
         * @return bool Returns true on success or false on failure.
         */
         * @param bool $recursive (optional) If set True changes file group recursively. Defaults to False.
         * @return bool Returns true on success or false on failure.
         */
-       function chgrp($file, $group, $recursive = false) {
+       public function chgrp($file, $group, $recursive = false) {
                if ( ! $this->exists($file) )
                        return false;
                if ( ! $recursive )
                if ( ! $this->exists($file) )
                        return false;
                if ( ! $recursive )
@@ -128,7 +128,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         * @param bool $recursive (optional) If set True changes file group recursively. Defaults to False.
         * @return bool Returns true on success or false on failure.
         */
         * @param bool $recursive (optional) If set True changes file group recursively. Defaults to False.
         * @return bool Returns true on success or false on failure.
         */
-       function chmod($file, $mode = false, $recursive = false) {
+       public function chmod($file, $mode = false, $recursive = false) {
                if ( ! $mode ) {
                        if ( $this->is_file($file) )
                                $mode = FS_CHMOD_FILE;
                if ( ! $mode ) {
                        if ( $this->is_file($file) )
                                $mode = FS_CHMOD_FILE;
@@ -157,7 +157,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         * @param bool $recursive (optional) If set True changes file owner recursively. Defaults to False.
         * @return bool Returns true on success or false on failure.
         */
         * @param bool $recursive (optional) If set True changes file owner recursively. Defaults to False.
         * @return bool Returns true on success or false on failure.
         */
-       function chown($file, $owner, $recursive = false) {
+       public function chown($file, $owner, $recursive = false) {
                if ( ! $this->exists($file) )
                        return false;
                if ( ! $recursive )
                if ( ! $this->exists($file) )
                        return false;
                if ( ! $recursive )
@@ -178,7 +178,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         * @param string $file Path to the file.
         * @return string|bool Username of the user or false on error.
         */
         * @param string $file Path to the file.
         * @return string|bool Username of the user or false on error.
         */
-       function owner($file) {
+       public function owner($file) {
                $owneruid = @fileowner($file);
                if ( ! $owneruid )
                        return false;
                $owneruid = @fileowner($file);
                if ( ! $owneruid )
                        return false;
@@ -194,13 +194,13 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
         * FIXME does not handle errors in fileperms()
         *
         * @param string $file Path to the file.
         * FIXME does not handle errors in fileperms()
         *
         * @param string $file Path to the file.
-        * @return string Mode of the file (last 4 digits).
+        * @return string Mode of the file (last 3 digits).
         */
         */
-       function getchmod($file) {
-               return substr(decoct(@fileperms($file)),3);
+       public function getchmod($file) {
+               return substr( decoct( @fileperms( $file ) ), -3 );
        }
 
        }
 
-       function group($file) {
+       public function group($file) {
                $gid = @filegroup($file);
                if ( ! $gid )
                        return false;
                $gid = @filegroup($file);
                if ( ! $gid )
                        return false;
@@ -210,7 +210,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
                return $grouparray['name'];
        }
 
                return $grouparray['name'];
        }
 
-       function copy($source, $destination, $overwrite = false, $mode = false) {
+       public function copy($source, $destination, $overwrite = false, $mode = false) {
                if ( ! $overwrite && $this->exists($destination) )
                        return false;
 
                if ( ! $overwrite && $this->exists($destination) )
                        return false;
 
@@ -220,11 +220,11 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
                return $rtval;
        }
 
                return $rtval;
        }
 
-       function move($source, $destination, $overwrite = false) {
+       public function move($source, $destination, $overwrite = false) {
                if ( ! $overwrite && $this->exists($destination) )
                        return false;
 
                if ( ! $overwrite && $this->exists($destination) )
                        return false;
 
-               // try using rename first. if that fails (for example, source is read only) try copy
+               // Try using rename first. if that fails (for example, source is read only) try copy.
                if ( @rename($source, $destination) )
                        return true;
 
                if ( @rename($source, $destination) )
                        return true;
 
@@ -236,7 +236,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
                }
        }
 
                }
        }
 
-       function delete($file, $recursive = false, $type = false) {
+       public function delete($file, $recursive = false, $type = false) {
                if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
                        return false;
                $file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise
                if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
                        return false;
                $file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise
@@ -264,39 +264,39 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
                return $retval;
        }
 
                return $retval;
        }
 
-       function exists($file) {
+       public function exists($file) {
                return @file_exists($file);
        }
 
                return @file_exists($file);
        }
 
-       function is_file($file) {
+       public function is_file($file) {
                return @is_file($file);
        }
 
                return @is_file($file);
        }
 
-       function is_dir($path) {
+       public function is_dir($path) {
                return @is_dir($path);
        }
 
                return @is_dir($path);
        }
 
-       function is_readable($file) {
+       public function is_readable($file) {
                return @is_readable($file);
        }
 
                return @is_readable($file);
        }
 
-       function is_writable($file) {
+       public function is_writable($file) {
                return @is_writable($file);
        }
 
                return @is_writable($file);
        }
 
-       function atime($file) {
+       public function atime($file) {
                return @fileatime($file);
        }
 
                return @fileatime($file);
        }
 
-       function mtime($file) {
+       public function mtime($file) {
                return @filemtime($file);
        }
 
                return @filemtime($file);
        }
 
-       function size($file) {
+       public function size($file) {
                return @filesize($file);
        }
 
                return @filesize($file);
        }
 
-       function touch($file, $time = 0, $atime = 0) {
+       public function touch($file, $time = 0, $atime = 0) {
                if ($time == 0)
                        $time = time();
                if ($atime == 0)
                if ($time == 0)
                        $time = time();
                if ($atime == 0)
@@ -304,8 +304,8 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
                return @touch($file, $time, $atime);
        }
 
                return @touch($file, $time, $atime);
        }
 
-       function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
-               // safe mode fails with a trailing slash under certain PHP versions.
+       public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
+               // Safe mode fails with a trailing slash under certain PHP versions.
                $path = untrailingslashit($path);
                if ( empty($path) )
                        return false;
                $path = untrailingslashit($path);
                if ( empty($path) )
                        return false;
@@ -323,11 +323,11 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
                return true;
        }
 
                return true;
        }
 
-       function rmdir($path, $recursive = false) {
+       public function rmdir($path, $recursive = false) {
                return $this->delete($path, $recursive);
        }
 
                return $this->delete($path, $recursive);
        }
 
-       function dirlist($path, $include_hidden = true, $recursive = false) {
+       public function dirlist($path, $include_hidden = true, $recursive = false) {
                if ( $this->is_file($path) ) {
                        $limit_file = basename($path);
                        $path = dirname($path);
                if ( $this->is_file($path) ) {
                        $limit_file = basename($path);
                        $path = dirname($path);