Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004296 [Quercus] major always 11-16-10 16:15 11-16-10 16:15
Reporter fredo View Status public  
Assigned To
Priority normal Resolution open Platform
Status new   OS
Projection none   OS Version
ETA none Fixed in Version Product Version 4.0.13
  Product Build
Summary 0004296: file_get_contents ignores offset parameter
Description 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
Steps To Reproduce
Additional Information should be fixed like:

  @ReturnNullAsFalse
  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;
    
    if(offset>0)
    {
        is.seek(offset, BinaryInput.SEEK_SET);
    }
    
    StringValue bb = env.createLargeBinaryBuilder();
    bb.appendReadAll(is, maxLen);

    s.close();
    return bb;
  }
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
11-16-10 16:15 fredo New Issue
11-17-10 03:16 kdecherf Issue Monitored: kdecherf


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
28 total queries executed.
25 unique queries executed.
Powered by Mantis Bugtracker