C# Class Pchp.Library.Streams.StreamWrapper

Abstract base class for PHP stream wrappers. Descendants define methods implementing fopen, stat, unlink, rename, opendir, mkdir and rmdir for different stream types.
Each script has its own copy of registeredWrappers stored in the context.

PhpStream is created by a StreamWrapper on a call to fopen(). Wrappers are stateless: they provide an instance of PhpStream on fopen() and an instance of DirectoryListing on opendir().

Inheritance: IDisposable
Mostrar archivo Open project: iolevel/peachpie Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Release wrapper resources

GetSystemWrapperSchemes ( ) : ICollection

Gets the list of built-in stream wrapper schemes.

GetWrapper ( Context ctx, string scheme, StreamOptions options ) : StreamWrapper

Retreive the corresponding StreamWrapper respectind the scheme portion of the given path. If no scheme is specified, an instance of FileStreamWrapper is returned.

Listing ( string path, StreamListingOptions options, StreamContext context ) : string[]
MakeDirectory ( string path, int accessMode, StreamMakeDirectoryOptions options, StreamContext context ) : bool StreamMakeDirectoryOptions for the list of additional options.
OnClose ( PhpStream stream ) : void

Wrapper may be notified of closing a stream using this method.

OnStat ( PhpStream stream ) : PhpArray

Wrapper may override the stat()ing of a stream using this method.

Open ( Context ctx, string &path, string mode, StreamOpenOptions options, StreamContext context ) : PhpStream
ParseMode ( string mode, StreamOpenOptions options, FileMode &fileMode, FileAccess &fileAccess, StreamAccessOptions &accessOptions ) : bool

Parse the mode argument passed to fopen() and make the appropriate FileMode and FileAccess combination. Integrate the relevant options from StreamOpenOptions too.

RegisterSystemWrapper ( StreamWrapper wrapper ) : bool

Register a new system wrapper

RemoveDirectory ( string path, StreamRemoveDirectoryOptions options, StreamContext context ) : bool
Rename ( string fromPath, string toPath, StreamRenameOptions options, StreamContext context ) : bool
Stat ( string path, StreamStatOptions options, StreamContext context, bool streamStat ) : StatStruct
Unlink ( string path, StreamUnlinkOptions options, StreamContext context ) : bool StreamUnlinkOptions for the list of additional options.

Private Methods

Method Description
CheckOptions ( StreamAccessOptions accessOptions, FileAccess supportedAccess, string path ) : bool

Checks whether the supported read/write access matches the reqiured one.

GetWrapperInternal ( Context ctx, string scheme ) : StreamWrapper

Search the lists of registered StreamWrappers to find the appropriate wrapper for a given scheme. When the scheme is empty, the FileStreamWrapper is returned.

ParseMode ( string mode, StreamOpenOptions options, StreamAccessOptions &accessOptions ) : bool

Overload of ParseMode(string, StreamOpenOptions, out FileMode, out FileAccess, out StreamAccessOptions) without the out arguments.

StatUnsupported ( ) : StatStruct

Reports warning and creates invalid stat.

Method Details

Dispose() public method

Release wrapper resources
public Dispose ( ) : void
return void

GetSystemWrapperSchemes() public static method

Gets the list of built-in stream wrapper schemes.
public static GetSystemWrapperSchemes ( ) : ICollection
return ICollection

GetWrapper() public static method

Retreive the corresponding StreamWrapper respectind the scheme portion of the given path. If no scheme is specified, an instance of FileStreamWrapper is returned.
In case when the required wrapper can not be found.
public static GetWrapper ( Context ctx, string scheme, StreamOptions options ) : StreamWrapper
ctx Pchp.Core.Context Current runtime context.
scheme string The scheme portion of an URL.
options StreamOptions Additional having effect on the wrapper retreival.
return StreamWrapper

Listing() public method

public Listing ( string path, StreamListingOptions options, StreamContext context ) : string[]
path string
options StreamListingOptions
context StreamContext
return string[]

MakeDirectory() public method

StreamMakeDirectoryOptions for the list of additional options.
public MakeDirectory ( string path, int accessMode, StreamMakeDirectoryOptions options, StreamContext context ) : bool
path string
accessMode int
options StreamMakeDirectoryOptions
context StreamContext
return bool

OnClose() public method

Wrapper may be notified of closing a stream using this method.
public OnClose ( PhpStream stream ) : void
stream PhpStream
return void

OnStat() public method

Wrapper may override the stat()ing of a stream using this method.
public OnStat ( PhpStream stream ) : PhpArray
stream PhpStream The Wrapper-opened stream to be stat()ed.
return Pchp.Core.PhpArray

Open() public abstract method

public abstract Open ( Context ctx, string &path, string mode, StreamOpenOptions options, StreamContext context ) : PhpStream
ctx Pchp.Core.Context
path string
mode string
options StreamOpenOptions
context StreamContext
return PhpStream

ParseMode() public method

Parse the mode argument passed to fopen() and make the appropriate FileMode and FileAccess combination. Integrate the relevant options from StreamOpenOptions too.
public ParseMode ( string mode, StreamOpenOptions options, FileMode &fileMode, FileAccess &fileAccess, StreamAccessOptions &accessOptions ) : bool
mode string Mode as passed to fopen().
options StreamOpenOptions The passed to fopen().
fileMode FileMode Resulting specifying opening mode.
fileAccess FileAccess Resulting specifying read/write access options.
accessOptions StreamAccessOptions Resulting giving /// additional information to the stream opener.
return bool

RegisterSystemWrapper() public static method

Register a new system wrapper
public static RegisterSystemWrapper ( StreamWrapper wrapper ) : bool
wrapper StreamWrapper An instance of the corresponding StreamWrapper descendant.
return bool

RemoveDirectory() public method

public RemoveDirectory ( string path, StreamRemoveDirectoryOptions options, StreamContext context ) : bool
path string
options StreamRemoveDirectoryOptions
context StreamContext
return bool

Rename() public method

public Rename ( string fromPath, string toPath, StreamRenameOptions options, StreamContext context ) : bool
fromPath string
toPath string
options StreamRenameOptions
context StreamContext
return bool

Stat() public method

public Stat ( string path, StreamStatOptions options, StreamContext context, bool streamStat ) : StatStruct
path string
options StreamStatOptions
context StreamContext
streamStat bool
return StatStruct

Unlink() public method

StreamUnlinkOptions for the list of additional options.
public Unlink ( string path, StreamUnlinkOptions options, StreamContext context ) : bool
path string
options StreamUnlinkOptions
context StreamContext
return bool