PHP Class org\bovigo\vfs\vfsStreamWrapper

ファイルを表示 Open project: mikey179/vfsstream Class Usage Examples

Protected Properties

Property Type Description
$content shortcut to file container
$dir shortcut to directory container
$dirIterator shortcut to directory container iterator
$mode file mode: read only, write only, all
$registered switch whether class has already been registered as stream wrapper or not
$root root content

Public Methods

Method Description
dir_closedir ( ) : boolean closes directory
dir_opendir ( string $path, integer $options ) : boolean opens a directory
dir_readdir ( ) : string reads directory contents
dir_rewinddir ( ) : boolean reset directory iteration
getRoot ( ) : org\bovigo\vfs\vfsStreamContainer returns the root content
mkdir ( string $path, integer $mode, integer $options ) : boolean creates a new directory
register ( ) method to register the stream wrapper
rename ( string $path_from, string $path_to ) : boolean rename from one path to another
rmdir ( string $path, integer $options ) : boolean removes a directory
setQuota ( Quota $quota ) sets quota for disk space
setRoot ( org\bovigo\vfs\vfsStreamContainer $root ) : org\bovigo\vfs\vfsStreamContainer sets the root content
stream_cast ( integer $cast_as ) : boolean retrieve the underlaying resource
stream_close ( ) closes the stream
stream_eof ( ) : boolean checks whether stream is at end of file
stream_flush ( ) : boolean flushes unstored data into storage
stream_lock ( integer $operation ) : boolean set lock status for stream
stream_metadata ( string $path, integer $option, mixed $var ) : boolean sets metadata like owner, user or permissions
stream_open ( string $path, string $mode, string $options, string $opened_path ) : boolean open the stream
stream_read ( integer $count ) : string read the stream up to $count bytes
stream_seek ( integer $offset, integer $whence ) : boolean seeks to the given offset
stream_set_option ( integer $option, integer $arg1, integer $arg2 ) : boolean sets options on the stream
stream_stat ( ) : array returns status of stream
stream_tell ( ) : integer returns the current position of the stream
stream_truncate ( integer $size ) : boolean truncates a file to a given length
stream_write ( string $data ) : integer writes data into the stream
unlink ( string $path ) : boolean remove the data under the given path
unregister ( ) Unregisters a previously registered URL wrapper for the vfs scheme.
url_stat ( string $path, integer $flags ) : array returns status of url

Protected Methods

Method Description
calculateMode ( string $mode, boolean $extended ) : integer calculates the file mode
doUnlink ( string $path ) : boolean removes a path
getContent ( string $path ) : org\bovigo\vfs\vfsStreamContent returns content for given path
getContentOfType ( string $path, integer $type ) : org\bovigo\vfs\vfsStreamContent returns content for given path but only when it is of given type
resolvePath ( string $path ) : string helper method to resolve a path from /foo/bar/. to /foo/bar
splitPath ( string $path ) : string[] splits path into its dirname and the basename

Private Methods

Method Description
createFile ( string $path, string $mode = null, string $options = null ) : boolean creates a file at given path
doPermChange ( string $path, vfsStreamAbstractContent $content, Closure $change ) : boolean executes given permission change when necessary rights allow such a change
isInRoot ( string $path ) : boolean helper method to detect whether given path is in root path

Method Details

calculateMode() protected method

calculates the file mode
protected calculateMode ( string $mode, boolean $extended ) : integer
$mode string opening mode: r, w, a or x
$extended boolean true if + was set with opening mode
return integer

dir_closedir() public method

closes directory
public dir_closedir ( ) : boolean
return boolean

dir_opendir() public method

opens a directory
public dir_opendir ( string $path, integer $options ) : boolean
$path string
$options integer
return boolean

dir_readdir() public method

reads directory contents
public dir_readdir ( ) : string
return string

dir_rewinddir() public method

reset directory iteration
public dir_rewinddir ( ) : boolean
return boolean

getContent() protected method

returns content for given path
protected getContent ( string $path ) : org\bovigo\vfs\vfsStreamContent
$path string
return org\bovigo\vfs\vfsStreamContent

getContentOfType() protected method

returns content for given path but only when it is of given type
protected getContentOfType ( string $path, integer $type ) : org\bovigo\vfs\vfsStreamContent
$path string
$type integer
return org\bovigo\vfs\vfsStreamContent

getRoot() public static method

returns the root content
public static getRoot ( ) : org\bovigo\vfs\vfsStreamContainer
return org\bovigo\vfs\vfsStreamContainer

mkdir() public method

creates a new directory
public mkdir ( string $path, integer $mode, integer $options ) : boolean
$path string
$mode integer
$options integer
return boolean

register() public static method

Please be aware that a call to this method will reset the root element to null. If the stream is already registered the method returns silently. If there is already another stream wrapper registered for the scheme used by vfsStream a vfsStreamException will be thrown.
public static register ( )

rename() public method

rename from one path to another
Author: Benoit Aubuchon
public rename ( string $path_from, string $path_to ) : boolean
$path_from string
$path_to string
return boolean

resolvePath() protected method

helper method to resolve a path from /foo/bar/. to /foo/bar
protected resolvePath ( string $path ) : string
$path string
return string

rmdir() public method

removes a directory
public rmdir ( string $path, integer $options ) : boolean
$path string
$options integer
return boolean

setQuota() public static method

sets quota for disk space
Since: 1.1.0
public static setQuota ( Quota $quota )
$quota Quota

setRoot() public static method

sets the root content
public static setRoot ( org\bovigo\vfs\vfsStreamContainer $root ) : org\bovigo\vfs\vfsStreamContainer
$root org\bovigo\vfs\vfsStreamContainer
return org\bovigo\vfs\vfsStreamContainer

splitPath() protected method

splits path into its dirname and the basename
protected splitPath ( string $path ) : string[]
$path string
return string[]

stream_cast() public method

Please note that this method always returns false as there is no underlaying resource to return.
See also: https://github.com/mikey179/vfsStream/issues/3
Since: 0.9.0
public stream_cast ( integer $cast_as ) : boolean
$cast_as integer
return boolean

stream_close() public method

closes the stream
See also: https://github.com/mikey179/vfsStream/issues/40
public stream_close ( )

stream_eof() public method

checks whether stream is at end of file
public stream_eof ( ) : boolean
return boolean

stream_flush() public method

flushes unstored data into storage
public stream_flush ( ) : boolean
return boolean

stream_lock() public method

set lock status for stream
See also: https://github.com/mikey179/vfsStream/issues/6
See also: https://github.com/mikey179/vfsStream/issues/31
See also: https://github.com/mikey179/vfsStream/issues/40
Since: 0.10.0
public stream_lock ( integer $operation ) : boolean
$operation integer
return boolean

stream_metadata() public method

sets metadata like owner, user or permissions
Since: 1.1.0
public stream_metadata ( string $path, integer $option, mixed $var ) : boolean
$path string
$option integer
$var mixed
return boolean

stream_open() public method

open the stream
public stream_open ( string $path, string $mode, string $options, string $opened_path ) : boolean
$path string the path to open
$mode string mode for opening
$options string options for opening
$opened_path string full path that was actually opened
return boolean

stream_read() public method

read the stream up to $count bytes
public stream_read ( integer $count ) : string
$count integer amount of bytes to read
return string

stream_seek() public method

seeks to the given offset
public stream_seek ( integer $offset, integer $whence ) : boolean
$offset integer
$whence integer
return boolean

stream_set_option() public method

sets options on the stream
See also: https://github.com/mikey179/vfsStream/issues/15
See also: http://www.php.net/manual/streamwrapper.stream-set-option.php
Since: 0.10.0
public stream_set_option ( integer $option, integer $arg1, integer $arg2 ) : boolean
$option integer key of option to set
$arg1 integer
$arg2 integer
return boolean

stream_stat() public method

returns status of stream
public stream_stat ( ) : array
return array

stream_tell() public method

returns the current position of the stream
public stream_tell ( ) : integer
return integer

stream_truncate() public method

truncates a file to a given length
Since: 1.1.0
public stream_truncate ( integer $size ) : boolean
$size integer length to truncate file to
return boolean

stream_write() public method

writes data into the stream
public stream_write ( string $data ) : integer
$data string
return integer amount of bytes written

unregister() public static method

If this stream wrapper wasn't registered, the method returns silently. If unregistering fails, or if the URL wrapper for vfs:// was not registered with this class, a vfsStreamException will be thrown.
Since: 1.6.0
public static unregister ( )

url_stat() public method

returns status of url
public url_stat ( string $path, integer $flags ) : array
$path string path of url to return status for
$flags integer flags set by the stream API
return array

Property Details

$content protected_oe property

shortcut to file container
protected $content

$dir protected_oe property

shortcut to directory container
protected $dir

$dirIterator protected_oe property

shortcut to directory container iterator
protected $dirIterator

$mode protected_oe property

file mode: read only, write only, all
protected $mode

$registered protected_oe static_oe property

switch whether class has already been registered as stream wrapper or not
protected static $registered

$root protected_oe static_oe property

root content
protected static $root