ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PHPStreamFunctions.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
4 namespace ILIAS\Filesystem\Util;
5 
19 final class PHPStreamFunctions
20 {
21 
31  public static function ftell($handle)
32  {
33  return ftell($handle);
34  }
35 
36 
44  public static function fclose($handle)
45  {
46  fclose($handle);
47  }
48 
49 
59  public static function fseek($stream, $offset, $whence)
60  {
61  return fseek($stream, $offset, $whence);
62  }
63 
64 
75  public static function fread($handle, $length)
76  {
77  return fread($handle, $length);
78  }
79 
80 
91  public static function stream_get_contents($handle, $length = -1)
92  {
93  return stream_get_contents($handle, $length);
94  }
95 
96 
108  public static function fwrite($handle, $string, $length = null)
109  {
110 
111  //it seems like php juggles the null to 0 and pass it to the function which leads to a write operation of zero length ...
112  if (is_null($length)) {
113  return fwrite($handle, $string);
114  }
115 
116  return fwrite($handle, $string, $length);
117  }
118 }
static fseek($stream, $offset, $whence)
fseek wrapper.
$stream
PHP stream implementation.
static fread($handle, $length)
fread wrapper
static fclose($handle)
fclose wrapper
static fwrite($handle, $string, $length=null)
fwrite wrapper
static stream_get_contents($handle, $length=-1)
stream_get_contents wrapper