Hoa central
Public Member Functions | Protected Member Functions | List of all members
Hoa\File\Read Class Reference
Inheritance diagram for Hoa\File\Read:

Public Member Functions

 __construct ($streamName, $mode=parent::MODE_READ, $context=null, $wait=false)
 
 eof ()
 
 read ($length)
 
 readString ($length)
 
 readCharacter ()
 
 readBoolean ()
 
 readInteger ($length=1)
 
 readFloat ($length=1)
 
 readArray ($format=null)
 
 readLine ()
 
 readAll ($offset=0)
 
 scanf ($format)
 
- Public Member Functions inherited from Hoa\File\File
 __construct ($streamName, $mode, $context=null, $wait=false)
 
 newBuffer ($callable=null, $size=null)
 
 flush ()
 
 deleteBuffer ()
 
 getBufferLevel ()
 
 getBufferSize ()
 
 lock ($operation)
 
 rewind ()
 
 seek ($offset, $whence=Stream\IStream\Pointable::SEEK_SET)
 
 tell ()
 
- Public Member Functions inherited from Hoa\File\Generic
 getBasename ()
 
 getDirname ()
 
 getSize ()
 
 getStatistic ()
 
 getATime ()
 
 getCTime ()
 
 getMTime ()
 
 getGroup ()
 
 getOwner ()
 
 getPermissions ()
 
 getReadablePermissions ()
 
 isReadable ()
 
 isWritable ()
 
 isExecutable ()
 
 clearStatisticCache ()
 
 touch ($time=-1, $atime=-1)
 
 copy ($to, $force=Stream\IStream\Touchable::DO_NOT_OVERWRITE)
 
 move ($name, $force=Stream\IStream\Touchable::DO_NOT_OVERWRITE, $mkdir=Stream\IStream\Touchable::DO_NOT_MAKE_DIRECTORY)
 
 delete ()
 
 changeGroup ($group)
 
 changeMode ($mode)
 
 changeOwner ($user)
 
 isFile ()
 
 isLink ()
 
 isDirectory ()
 
 isSocket ()
 
 isFIFOPipe ()
 
 isCharacterSpecial ()
 
 isBlockSpecial ()
 
 isUnknown ()
 
 getMode ()
 
 getINode ()
 
 getRealPath ()
 
 getExtension ()
 
 getFilename ()
 
- Public Member Functions inherited from Hoa\Stream\Stream
 __construct ($streamName, $context=null, $wait=false)
 
 open ()
 
 close ()
 
 getStreamName ()
 
 getStreamContext ()
 
 _setStream ($stream)
 
 isOpened ()
 
 setStreamTimeout ($seconds, $microseconds=0)
 
 setStreamBlocking ($mode)
 
 setStreamBuffer ($buffer)
 
 disableStreamBuffer ()
 
 getStreamBufferSize ()
 
 getStreamWrapperName ()
 
 getStreamMetaData ()
 
 isBorrowing ()
 
 on ($listenerId, $callable)
 
 _notify ($ncode, $severity, $message, $code, $transferred, $max)
 
 __toString ()
 
 __destruct ()
 

Protected Member Functions

_open ($streamName, Stream\Context $context=null)
 
- Protected Member Functions inherited from Hoa\File\File
_open ($streamName, Stream\Context $context=null)
 
 _close ()
 
- Protected Member Functions inherited from Hoa\File\Generic
 setMode ($mode)
 
- Protected Member Functions inherited from Hoa\Stream\Stream
_open ($streamName, Context $context=null)
 
 _close ()
 
 getStream ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Hoa\File\File
static create ($name, $dummy)
 
- Static Public Member Functions inherited from Hoa\File\Generic
static clearAllStatisticCaches ()
 
static umask ($umask=null)
 
static isCaseSensitive ()
 
- Static Public Member Functions inherited from Hoa\Stream\Stream
static getStreamHandler ($streamName)
 
static _Hoa_Stream ()
 
- Public Attributes inherited from Hoa\File\File
const MODE_READ = 'rb'
 
const MODE_READ_WRITE = 'r+b'
 
const MODE_TRUNCATE_WRITE = 'wb'
 
const MODE_TRUNCATE_READ_WRITE = 'w+b'
 
const MODE_APPEND_WRITE = 'ab'
 
const MODE_APPEND_READ_WRITE = 'a+b'
 
const MODE_CREATE_WRITE = 'xb'
 
const MODE_CREATE_READ_WRITE = 'x+b'
 
- Public Attributes inherited from Hoa\Stream\Stream
const NAME = 0
 
const HANDLER = 1
 
const RESOURCE = 2
 
const CONTEXT = 3
 
- Public Attributes inherited from Hoa\Stream\IStream\Statable
const SIZE_UNDEFINED = -1
 
- Public Attributes inherited from Hoa\Stream\IStream\Touchable
const OVERWRITE = true
 
const DO_NOT_OVERWRITE = false
 
const MAKE_DIRECTORY = true
 
const DO_NOT_MAKE_DIRECTORY = false
 
- Public Attributes inherited from Hoa\Stream\IStream\Lockable
const LOCK_SHARED = LOCK_SH
 
const LOCK_EXCLUSIVE = LOCK_EX
 
const LOCK_RELEASE = LOCK_UN
 
const LOCK_NO_BLOCK = LOCK_NB
 
- Public Attributes inherited from Hoa\Stream\IStream\Pointable
const SEEK_SET = SEEK_SET
 
const SEEK_CURRENT = SEEK_CUR
 
const SEEK_END = SEEK_END
 
- Protected Attributes inherited from Hoa\File\Generic
 $_mode = null
 
- Protected Attributes inherited from Hoa\Stream\Stream
 $_bucket = []
 
 $_bufferSize = 8192
 
 $_streamName = null
 
 $_context = null
 
 $_hasBeenDiffered = false
 
 $_on = null
 
 $_borrowed = false
 

Detailed Description

Class .

File handler.

Definition at line 49 of file Read.php.

Constructor & Destructor Documentation

Hoa\File\Read::__construct (   $streamName,
  $mode = parent::MODE_READ,
  $context = null,
  $wait = false 
)

Open a file.

Parameters
string$streamNameStream name.
string$modeOpen mode, see the self::MODE_* constants.
string$contextContext ID (please, see the class).
bool$waitDiffer opening or not.
Returns
void

Definition at line 61 of file Read.php.

66  {
67  parent::__construct($streamName, $mode, $context, $wait);
68 
69  return;
70  }

Member Function Documentation

& Hoa\File\Read::_open (   $streamName,
Stream\Context  $context = null 
)
protected

Open the stream and return the associated resource.

Parameters
string$streamNameStream name (e.g. path or URL).
\Hoa\Stream\Context$contextContext.
Returns
resource
Exceptions

Definition at line 81 of file Read.php.

82  {
83  static $createModes = [
84  parent::MODE_READ
85  ];
86 
87  if (!in_array($this->getMode(), $createModes)) {
88  throw new Exception(
89  'Open mode are not supported; given %d. Only %s are supported.',
90  0,
91  [$this->getMode(), implode(', ', $createModes)]
92  );
93  }
94 
95  preg_match('#^(\w+)://#', $streamName, $match);
96 
97  if (((isset($match[1]) && $match[1] == 'file') || !isset($match[1])) &&
98  !file_exists($streamName)) {
99  throw new Exception\FileDoesNotExist(
100  'File %s does not exist.',
101  1,
102  $streamName
103  );
104  }
105 
106  $out = parent::_open($streamName, $context);
107 
108  return $out;
109  }

Here is the call graph for this function:

Hoa\File\Read::eof ( )

Test for end-of-file.

Returns
bool

Implements Hoa\Stream\IStream\In.

Definition at line 116 of file Read.php.

117  {
118  return feof($this->getStream());
119  }

Here is the call graph for this function:

Hoa\File\Read::read (   $length)

Read n characters.

Parameters
int$lengthLength.
Returns
string
Exceptions

Implements Hoa\Stream\IStream\In.

Definition at line 128 of file Read.php.

129  {
130  if (0 > $length) {
131  throw new Exception(
132  'Length must be greater than 0, given %d.',
133  2,
134  $length
135  );
136  }
137 
138  return fread($this->getStream(), $length);
139  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\File\Read::readAll (   $offset = 0)

Read all, i.e. read as much as possible.

Parameters
int$offsetOffset.
Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 222 of file Read.php.

223  {
224  return stream_get_contents($this->getStream(), -1, $offset);
225  }

Here is the call graph for this function:

Hoa\File\Read::readArray (   $format = null)

Read an array. Alias of the $this->scanf() method.

Parameters
string$formatFormat (see printf's formats).
Returns
array

Implements Hoa\Stream\IStream\In.

Definition at line 201 of file Read.php.

202  {
203  return $this->scanf($format);
204  }
scanf($format)
Definition: Read.php:233

Here is the call graph for this function:

Hoa\File\Read::readBoolean ( )

Read a boolean.

Returns
bool

Implements Hoa\Stream\IStream\In.

Definition at line 167 of file Read.php.

168  {
169  return (bool) $this->read(1);
170  }
read($length)
Definition: Read.php:128

Here is the call graph for this function:

Hoa\File\Read::readCharacter ( )

Read a character.

Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 157 of file Read.php.

158  {
159  return fgetc($this->getStream());
160  }

Here is the call graph for this function:

Hoa\File\Read::readFloat (   $length = 1)

Read a float.

Parameters
int$lengthLength.
Returns
float

Implements Hoa\Stream\IStream\In.

Definition at line 189 of file Read.php.

190  {
191  return (float) $this->read($length);
192  }
read($length)
Definition: Read.php:128

Here is the call graph for this function:

Hoa\File\Read::readInteger (   $length = 1)

Read an integer.

Parameters
int$lengthLength.
Returns
int

Implements Hoa\Stream\IStream\In.

Definition at line 178 of file Read.php.

179  {
180  return (int) $this->read($length);
181  }
read($length)
Definition: Read.php:128

Here is the call graph for this function:

Hoa\File\Read::readLine ( )

Read a line.

Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 211 of file Read.php.

212  {
213  return fgets($this->getStream());
214  }

Here is the call graph for this function:

Hoa\File\Read::readString (   $length)

Alias of $this->read().

Parameters
int$lengthLength.
Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 147 of file Read.php.

148  {
149  return $this->read($length);
150  }
read($length)
Definition: Read.php:128

Here is the call graph for this function:

Hoa\File\Read::scanf (   $format)

Parse input from a stream according to a format.

Parameters
string$formatFormat (see printf's formats).
Returns
array

Implements Hoa\Stream\IStream\In.

Definition at line 233 of file Read.php.

234  {
235  return fscanf($this->getStream(), $format);
236  }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: