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

Public Member Functions

 __construct ($streamName, $mode=parent::MODE_APPEND_WRITE, $context=null, $wait=false)
 
 write ($string, $length)
 
 writeString ($string)
 
 writeCharacter ($char)
 
 writeBoolean ($boolean)
 
 writeInteger ($integer)
 
 writeFloat ($float)
 
 writeArray (Array $array)
 
 writeLine ($line)
 
 writeAll ($string)
 
 truncate ($size)
 
- Public Member Functions inherited from Hoa\File\Temporary\Temporary
 __construct ($streamName, $mode, $context=null, $wait=false)
 
- 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\Temporary\Temporary
_open ($streamName,\Hoa\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\Temporary\Temporary
static create ($directory=null, $prefix= '__hoa_')
 
static getTemporaryDirectory ()
 
- 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 .

Write into a temporary file.

Definition at line 50 of file Write.php.

Constructor & Destructor Documentation

Hoa\File\Temporary\Write::__construct (   $streamName,
  $mode = parent::MODE_APPEND_WRITE,
  $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 Write.php.

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

Member Function Documentation

& Hoa\File\Temporary\Write::_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 Write.php.

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

Here is the call graph for this function:

Hoa\File\Temporary\Write::truncate (   $size)

Truncate a file to a given length.

Parameters
int$sizeSize.
Returns
bool

Implements Hoa\Stream\IStream\Out.

Definition at line 243 of file Write.php.

244  {
245  return ftruncate($this->getStream(), $size);
246  }

Here is the call graph for this function:

Hoa\File\Temporary\Write::write (   $string,
  $length 
)

Write n characters.

Parameters
string$stringString.
int$lengthLength.
Returns
mixed
Exceptions

Implements Hoa\Stream\IStream\Out.

Definition at line 122 of file Write.php.

123  {
124  if (0 > $length) {
125  throw new File\Exception(
126  'Length must be greater than 0, given %d.',
127  2,
128  $length
129  );
130  }
131 
132  return fwrite($this->getStream(), $string, $length);
133  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\File\Temporary\Write::writeAll (   $string)

Write all, i.e. as much as possible.

Parameters
string$stringString.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 232 of file Write.php.

233  {
234  return $this->write($string, strlen($string));
235  }
write($string, $length)
Definition: Write.php:122

Here is the call graph for this function:

Hoa\File\Temporary\Write::writeArray ( Array  $array)

Write an array.

Parameters
array$arrayArray.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 202 of file Write.php.

203  {
204  $array = var_export($array, true);
205 
206  return $this->write($array, strlen($array));
207  }
write($string, $length)
Definition: Write.php:122

Here is the call graph for this function:

Hoa\File\Temporary\Write::writeBoolean (   $boolean)

Write a boolean.

Parameters
bool$booleanBoolean.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 165 of file Write.php.

166  {
167  return $this->write((string) (bool) $boolean, 1);
168  }
write($string, $length)
Definition: Write.php:122

Here is the call graph for this function:

Hoa\File\Temporary\Write::writeCharacter (   $char)

Write a character.

Parameters
string$charCharacter.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 154 of file Write.php.

155  {
156  return $this->write((string) $char[0], 1);
157  }
write($string, $length)
Definition: Write.php:122

Here is the call graph for this function:

Hoa\File\Temporary\Write::writeFloat (   $float)

Write a float.

Parameters
float$floatFloat.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 189 of file Write.php.

190  {
191  $float = (string) (float) $float;
192 
193  return $this->write($float, strlen($float));
194  }
write($string, $length)
Definition: Write.php:122

Here is the call graph for this function:

Hoa\File\Temporary\Write::writeInteger (   $integer)

Write an integer.

Parameters
int$integerInteger.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 176 of file Write.php.

177  {
178  $integer = (string) (int) $integer;
179 
180  return $this->write($integer, strlen($integer));
181  }
write($string, $length)
Definition: Write.php:122

Here is the call graph for this function:

Hoa\File\Temporary\Write::writeLine (   $line)

Write a line.

Parameters
string$lineLine.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 215 of file Write.php.

216  {
217  if (false === $n = strpos($line, "\n")) {
218  return $this->write($line . "\n", strlen($line) + 1);
219  }
220 
221  ++$n;
222 
223  return $this->write(substr($line, 0, $n), $n);
224  }
write($string, $length)
Definition: Write.php:122

Here is the call graph for this function:

Hoa\File\Temporary\Write::writeString (   $string)

Write a string.

Parameters
string$stringString.
Returns
mixed

Implements Hoa\Stream\IStream\Out.

Definition at line 141 of file Write.php.

142  {
143  $string = (string) $string;
144 
145  return $this->write($string, strlen($string));
146  }
write($string, $length)
Definition: Write.php:122

Here is the call graph for this function:


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