Hoa central
Public Member Functions | Protected Member Functions | List of all members
Hoa\File\Link\Read Class Reference
Inheritance diagram for Hoa\File\Link\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\Link\Link
 __construct ($streamName, $mode, $context=null, $wait=false)
 
 getStatistic ()
 
 changeGroup ($group)
 
 changeOwner ($user)
 
 getPermissions ()
 
 getTarget ()
 
 getTargetName ()
 
- 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\Link\Link
static create ($name, $target)
 
- 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 50 of file Read.php.

Constructor & Destructor Documentation

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

Open a file.

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

Definition at line 62 of file Read.php.

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

Member Function Documentation

& Hoa\File\Link\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 82 of file Read.php.

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

Here is the call graph for this function:

Hoa\File\Link\Read::eof ( )

Test for end-of-file.

Returns
bool

Implements Hoa\Stream\IStream\In.

Definition at line 117 of file Read.php.

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

Here is the call graph for this function:

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

Read n characters.

Parameters
int$lengthLength.
Returns
string
Exceptions

Implements Hoa\Stream\IStream\In.

Definition at line 129 of file Read.php.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\File\Link\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 223 of file Read.php.

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

Here is the call graph for this function:

Hoa\File\Link\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 202 of file Read.php.

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

Here is the call graph for this function:

Hoa\File\Link\Read::readBoolean ( )

Read a boolean.

Returns
bool

Implements Hoa\Stream\IStream\In.

Definition at line 168 of file Read.php.

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

Here is the call graph for this function:

Hoa\File\Link\Read::readCharacter ( )

Read a character.

Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 158 of file Read.php.

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

Here is the call graph for this function:

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

Read a float.

Parameters
int$lengthLength.
Returns
float

Implements Hoa\Stream\IStream\In.

Definition at line 190 of file Read.php.

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

Here is the call graph for this function:

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

Read an integer.

Parameters
int$lengthLength.
Returns
int

Implements Hoa\Stream\IStream\In.

Definition at line 179 of file Read.php.

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

Here is the call graph for this function:

Hoa\File\Link\Read::readLine ( )

Read a line.

Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 212 of file Read.php.

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

Here is the call graph for this function:

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

Alias of $this->read().

Parameters
int$lengthLength.
Returns
string

Implements Hoa\Stream\IStream\In.

Definition at line 148 of file Read.php.

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

Here is the call graph for this function:

Hoa\File\Link\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 234 of file Read.php.

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

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: