Mantis - Quercus
Viewing Issue Advanced Details
4296 major always 11-16-10 16:15 11-16-10 16:15
new 4.0.13  
0004296: file_get_contents ignores offset parameter
php docs say:

string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] )

This function is similar to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.

BUT the implementation in Quercus will always return the file-contents from the start of the file
should be fixed like:

  public static StringValue
    file_get_contents(Env env,
                      StringValue filename,
                      @Optional boolean useIncludePath,
                      @Optional Value context,
                      @Optional("-1") long offset,
                      @Optional("4294967296") long maxLen)
    if (filename.length() == 0) {
      env.warning(L.l("file name must not be null"));
      return null;

    BinaryStream s = fopen(env, filename, "r", useIncludePath, context);

    if (! (s instanceof BinaryInput))
      return null;

    BinaryInput is = (BinaryInput) s;
    {, BinaryInput.SEEK_SET);
    StringValue bb = env.createLargeBinaryBuilder();
    bb.appendReadAll(is, maxLen);

    return bb;

There are no notes attached to this issue.