public static int fpassthru(Context ctx, PhpResource handle) { PhpStream stream = PhpStream.GetValid(handle); if (stream == null) { return(-1); } if (stream.IsText) { // Use the text output buffers. int rv = 0; while (!stream.Eof) { string str = stream.ReadMaximumString(); ctx.Output.Write(str); rv += str.Length; } return(rv); } else { // Write directly to the binary output buffers. return(stream_copy_to_stream(stream, InputOutputStreamWrapper.ScriptOutput(ctx))); } }
/// <summary> /// Reads a file, decompresses it and writes it to standard output. /// </summary> /// <param name="ctx">Runtime context.</param> /// <param name="filename"> /// The file name. This file will be opened from the filesystem and its contents written to standard output. /// </param> /// <param name="use_include_path"> /// You can set this optional parameter to 1, if you want to search for the file in the include_path too. /// </param> /// <returns> /// Returns the number of (uncompressed) bytes read from the file. If an error occurs, FALSE is returned and /// unless the function was called as @readgzfile, an error message is printed. /// </returns> public static int readgzfile(Context ctx, string filename, int use_include_path = 0) { var fs = (PhpStream)gzopen(ctx, filename, "r", use_include_path); return(PhpStreams.stream_copy_to_stream(fs, InputOutputStreamWrapper.ScriptOutput(ctx))); }