Ejemplo n.º 1
0
        public static PhpString fgets(PhpResource handle)
        {
            PhpStream stream = PhpStream.GetValid(handle);

            if (stream == null)
            {
                return(default(PhpString));
            }

            // Use the default accessor to the stream breaking at \n, no superfluous conversion.
            //return Core.Convert.Quote(stream.ReadData(-1, true), ScriptContext.CurrentContext);
            return(stream.ReadData(-1, true).ToPhpString());
        }
Ejemplo n.º 2
0
        public static PhpString fgets(PhpResource handle, int length)
        {
            if (length <= 0)
            {
                //PhpException.Throw(PhpError.Warning, LibResources.GetString("arg_negative", "Length"));
                //return null;
                throw new ArgumentOutOfRangeException(nameof(length));
            }

            PhpStream stream = PhpStream.GetValid(handle);

            if (stream == null)
            {
                return(default(PhpString));
            }

            // Use the default accessor to the stream breaking at \n, no superfluous conversion.
            //return Core.Convert.Quote(stream.ReadData(length, true), ScriptContext.CurrentContext);
            return(stream.ReadData(length, true).ToPhpString());
        }
Ejemplo n.º 3
0
        public static PhpArray GzFile(ScriptContext context, string filename, int use_include_path)
        {
            PhpStream fs = (PhpStream)GzOpen(filename, "r", use_include_path);

            if (fs == null)
            {
                return(null);
            }

            PhpArray returnValue = new PhpArray();
            int      blockLength = 8192;

            while (!fs.Eof)
            {
                string value = PhpStream.AsText(fs.ReadData(blockLength, true));

                returnValue.Add(Core.Convert.Quote(value, context));
            }

            return(returnValue);
        }