/// <summary>
/// Registers a user-wrapper specified by the name of a defining user-class.
/// </summary>
/// <param name="ctx">Runtime context.</param>
/// <param name="protocol">The schema to be associated with the given wrapper.</param>
/// <param name="classname">Name of the user class implementing the wrapper functions.</param>
/// <param name="flags">Should be set to STREAM_IS_URL if protocol is a URL protocol. Default is 0, local stream.</param>
/// <returns>False in case of failure (ex. schema already occupied).</returns>
public static bool stream_wrapper_register(Context ctx, string protocol, string classname, StreamWrapperRegisterFlags flags = StreamWrapperRegisterFlags.Default)
{
// check if the scheme is already registered:
if (string.IsNullOrEmpty(protocol) || StreamWrapper.GetWrapperInternal(ctx, protocol) == null)
{
// TODO: Warning?
return(false);
}
var wrapperClass = ctx.GetDeclaredTypeOrThrow(classname, true);
if (wrapperClass == null)
{
return(false);
}
// EX: [stream_wrapper_register]: create the user wrapper
var wrapper = new UserStreamWrapper(ctx, protocol, wrapperClass, flags == StreamWrapperRegisterFlags.IsUrl);
return(StreamWrapper.RegisterUserWrapper(ctx, protocol, wrapper));
}