\Sitebill_Filesystem

WordPress Direct Filesystem.

Summary

Methods
Properties
Constants
__construct()
connect()
get_contents()
get_contents_array()
put_contents()
cwd()
chdir()
chgrp()
chmod()
chown()
owner()
getchmod()
group()
copy()
move()
delete()
exists()
is_file()
is_dir()
is_readable()
is_writable()
atime()
mtime()
size()
touch()
mkdir()
rmdir()
dirlist()
gethchmod()
getnumchmodfromh()
is_binary()
$errors
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$errors

$errors : 

Type

Methods

__construct()

__construct() 

constructor

connect()

connect() : boolean

connect filesystem.

Returns

boolean —

Returns true on success or false on failure (always true for WP_Filesystem_Direct).

get_contents()

get_contents(string  $file) : string|boolean

Reads entire file into a string

Parameters

string $file

Name of the file to read.

Returns

string|boolean —

The function returns the read data or false on failure.

get_contents_array()

get_contents_array(string  $file) : array|boolean

Reads entire file into an array

Parameters

string $file

Path to the file.

Returns

array|boolean —

the file contents in an array or false on failure.

put_contents()

put_contents(string  $file, string  $contents, integer  $mode = false) : boolean

Write a string to a file

Parameters

string $file

Remote path to the file where to write the data.

string $contents

The data to write.

integer $mode

(optional) The file permissions as octal number, usually 0644.

Returns

boolean —

False upon failure.

cwd()

cwd() : string|boolean

Gets the current working directory

Returns

string|boolean —

the current working directory on success, or false on failure.

chdir()

chdir(string  $dir) : boolean

Change directory

Parameters

string $dir

The new current directory.

Returns

boolean —

Returns true on success or false on failure.

chgrp()

chgrp(string  $file, mixed  $group, boolean  $recursive = false) : boolean

Changes file group

Parameters

string $file

Path to the file.

mixed $group

A group name or number.

boolean $recursive

(optional) If set True changes file group recursively. Defaults to False.

Returns

boolean —

Returns true on success or false on failure.

chmod()

chmod(string  $file, integer  $mode = false, boolean  $recursive = false) : boolean

Changes filesystem permissions

Parameters

string $file

Path to the file.

integer $mode

(optional) The permissions as octal number, usually 0644 for files, 0755 for dirs.

boolean $recursive

(optional) If set True changes file group recursively. Defaults to False.

Returns

boolean —

Returns true on success or false on failure.

chown()

chown(string  $file, mixed  $owner, boolean  $recursive = false) : boolean

Changes file owner

Parameters

string $file

Path to the file.

mixed $owner

A user name or number.

boolean $recursive

(optional) If set True changes file owner recursively. Defaults to False.

Returns

boolean —

Returns true on success or false on failure.

owner()

owner(string  $file) : string

Gets file owner

Parameters

string $file

Path to the file.

Returns

string —

Username of the user.

getchmod()

getchmod(string  $file) : string

Gets file permissions

FIXME does not handle errors in fileperms()

Parameters

string $file

Path to the file.

Returns

string —

Mode of the file (last 4 digits).

group()

group(  $file) 

Parameters

$file

copy()

copy(  $source,   $destination,   $overwrite = false,   $mode = false) 

Parameters

$source
$destination
$overwrite
$mode

move()

move(  $source,   $destination,   $overwrite = false) 

Parameters

$source
$destination
$overwrite

delete()

delete(  $file,   $recursive = false,   $type = false) 

Parameters

$file
$recursive
$type

exists()

exists(  $file) 

Parameters

$file

is_file()

is_file(  $file) 

Parameters

$file

is_dir()

is_dir(  $path) 

Parameters

$path

is_readable()

is_readable(  $file) 

Parameters

$file

is_writable()

is_writable(  $file) 

Parameters

$file

atime()

atime(  $file) 

Parameters

$file

mtime()

mtime(  $file) 

Parameters

$file

size()

size(  $file) 

Parameters

$file

touch()

touch(  $file,   $time,   $atime) 

Parameters

$file
$time
$atime

mkdir()

mkdir(  $path,   $chmod = false,   $chown = false,   $chgrp = false) 

Parameters

$path
$chmod
$chown
$chgrp

rmdir()

rmdir(  $path,   $recursive = false) 

Parameters

$path
$recursive

dirlist()

dirlist(  $path,   $include_hidden = true,   $recursive = false) 

Parameters

$path
$include_hidden
$recursive

gethchmod()

gethchmod(string  $file) : integer

Returns the *nix style file permissions for a file

From the PHP documentation page for fileperms()

Parameters

string $file

string filename

Returns

integer —

octal representation of permissions

getnumchmodfromh()

getnumchmodfromh(string  $mode) : integer

Converts *nix style file permissions to a octal number.

Converts '-rw-r--r--' to 0644 From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()

Parameters

string $mode

string *nix style file permission

Returns

integer —

octal representation

is_binary()

is_binary(string  $text) : boolean

Determines if the string provided contains binary characters.

Parameters

string $text

String to test against

Returns

boolean —

true if string is binary, false otherwise