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

Public Member Functions

 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 ()
 

Static Public Member Functions

static clearAllStatisticCaches ()
 
static umask ($umask=null)
 
static isCaseSensitive ()
 
- Static Public Member Functions inherited from Hoa\Stream\Stream
static getStreamHandler ($streamName)
 
static _Hoa_Stream ()
 

Protected Member Functions

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

Protected Attributes

 $_mode = null
 
- Protected Attributes inherited from Hoa\Stream\Stream
 $_bucket = []
 
 $_bufferSize = 8192
 
 $_streamName = null
 
 $_context = null
 
 $_hasBeenDiffered = false
 
 $_on = null
 
 $_borrowed = false
 

Additional Inherited Members

- 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
 

Detailed Description

Class .

Describe a super-file.

Definition at line 49 of file Generic.php.

Member Function Documentation

Hoa\File\Generic::changeGroup (   $group)

Change file group.

Parameters
mixed$groupGroup name or number.
Returns
bool

Implements Hoa\Stream\IStream\Touchable.

Definition at line 387 of file Generic.php.

388  {
389  return chgrp($this->getStreamName(), $group);
390  }

Here is the call graph for this function:

Hoa\File\Generic::changeMode (   $mode)

Change file mode.

Parameters
int$modeMode (in octal!).
Returns
bool

Implements Hoa\Stream\IStream\Touchable.

Definition at line 398 of file Generic.php.

399  {
400  return chmod($this->getStreamName(), $mode);
401  }

Here is the call graph for this function:

Hoa\File\Generic::changeOwner (   $user)

Change file owner.

Parameters
mixed$userUser.
Returns
bool

Implements Hoa\Stream\IStream\Touchable.

Definition at line 409 of file Generic.php.

410  {
411  return chown($this->getStreamName(), $user);
412  }

Here is the call graph for this function:

static Hoa\File\Generic::clearAllStatisticCaches ( )
static

Clear all files status cache.

Returns
void

Implements Hoa\Stream\IStream\Statable.

Definition at line 271 of file Generic.php.

272  {
273  clearstatcache();
274 
275  return;
276  }
Hoa\File\Generic::clearStatisticCache ( )

Clear file status cache.

Returns
void

Implements Hoa\Stream\IStream\Statable.

Definition at line 259 of file Generic.php.

260  {
261  clearstatcache(true, $this->getStreamName());
262 
263  return;
264  }

Here is the call graph for this function:

Hoa\File\Generic::copy (   $to,
  $force = Stream\IStream\Touchable::DO_NOT_OVERWRITE 
)

Copy file. Return the destination file path if succeed, false otherwise.

Parameters
string$toDestination path.
bool$forceForce to copy if the file $to already exists. Use the ::*OVERWRITE constants.
Returns
bool

Implements Hoa\Stream\IStream\Touchable.

Definition at line 309 of file Generic.php.

310  {
311  $from = $this->getStreamName();
312 
313  if ($force === Stream\IStream\Touchable::DO_NOT_OVERWRITE &&
314  true === file_exists($to)) {
315  return true;
316  }
317 
318  if (null === $this->getStreamContext()) {
319  return @copy($from, $to);
320  }
321 
322  return @copy($from, $to, $this->getStreamContext()->getContext());
323  }
copy($to, $force=Stream\IStream\Touchable::DO_NOT_OVERWRITE)
Definition: Generic.php:309

Here is the call graph for this function:

Hoa\File\Generic::delete ( )

Delete a file.

Returns
bool

Implements Hoa\Stream\IStream\Touchable.

Definition at line 369 of file Generic.php.

370  {
371  if (null === $this->getStreamContext()) {
372  return @unlink($this->getStreamName());
373  }
374 
375  return @unlink(
376  $this->getStreamName(),
377  $this->getStreamContext()->getContext()
378  );
379  }

Here is the call graph for this function:

Hoa\File\Generic::getATime ( )

Get last access time of file.

Returns
int

Implements Hoa\Stream\IStream\Statable.

Definition at line 113 of file Generic.php.

114  {
115  return fileatime($this->getStreamName());
116  }

Here is the call graph for this function:

Hoa\File\Generic::getBasename ( )

Get filename component of path.

Returns
string

Implements Hoa\Stream\IStream\Pathable.

Definition at line 69 of file Generic.php.

70  {
71  return basename($this->getStreamName());
72  }

Here is the call graph for this function:

Hoa\File\Generic::getCTime ( )

Get inode change time of file.

Returns
int

Implements Hoa\Stream\IStream\Statable.

Definition at line 123 of file Generic.php.

124  {
125  return filectime($this->getStreamName());
126  }

Here is the call graph for this function:

Hoa\File\Generic::getDirname ( )

Get directory name component of path.

Returns
string

Implements Hoa\Stream\IStream\Pathable.

Definition at line 79 of file Generic.php.

80  {
81  return dirname($this->getStreamName());
82  }

Here is the call graph for this function:

Hoa\File\Generic::getExtension ( )

Get file extension (if exists).

Returns
string

Definition at line 577 of file Generic.php.

578  {
579  return pathinfo(
580  $this->getStreamName(),
581  PATHINFO_EXTENSION
582  );
583  }

Here is the call graph for this function:

Hoa\File\Generic::getFilename ( )

Get filename without extension.

Returns
string

Definition at line 590 of file Generic.php.

591  {
592  $file = basename($this->getStreamName());
593 
594  if (defined('PATHINFO_FILENAME')) {
595  return pathinfo($file, PATHINFO_FILENAME);
596  }
597 
598  if (strstr($file, '.')) {
599  return substr($file, 0, strrpos($file, '.'));
600  }
601 
602  return $file;
603  }

Here is the call graph for this function:

Hoa\File\Generic::getGroup ( )

Get file group.

Returns
int

Implements Hoa\Stream\IStream\Statable.

Definition at line 143 of file Generic.php.

144  {
145  return filegroup($this->getStreamName());
146  }

Here is the call graph for this function:

Hoa\File\Generic::getINode ( )

Get inode.

Returns
int

Definition at line 540 of file Generic.php.

541  {
542  return fileinode($this->getStreamName());
543  }

Here is the call graph for this function:

Hoa\File\Generic::getMode ( )

Get the open mode.

Returns
string

Definition at line 530 of file Generic.php.

531  {
532  return $this->_mode;
533  }

Here is the caller graph for this function:

Hoa\File\Generic::getMTime ( )

Get file modification time.

Returns
int

Implements Hoa\Stream\IStream\Statable.

Definition at line 133 of file Generic.php.

134  {
135  return filemtime($this->getStreamName());
136  }

Here is the call graph for this function:

Hoa\File\Generic::getOwner ( )

Get file owner.

Returns
int

Implements Hoa\Stream\IStream\Statable.

Definition at line 153 of file Generic.php.

154  {
155  return fileowner($this->getStreamName());
156  }

Here is the call graph for this function:

Hoa\File\Generic::getPermissions ( )

Get file permissions.

Returns
int

Implements Hoa\Stream\IStream\Statable.

Definition at line 163 of file Generic.php.

164  {
165  return fileperms($this->getStreamName());
166  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\File\Generic::getReadablePermissions ( )

Get file permissions as a string. Result sould be interpreted like this:

  • s: socket;
  • l: symbolic link;
  • -: regular;
  • b: block special;
  • d: directory;
  • c: character special;
  • p: FIFO pipe;
  • u: unknown.
Returns
string

Definition at line 182 of file Generic.php.

183  {
184  $p = $this->getPermissions();
185 
186  if (($p & 0xC000) == 0xC000) {
187  $out = 's';
188  } elseif (($p & 0xA000) == 0xA000) {
189  $out = 'l';
190  } elseif (($p & 0x8000) == 0x8000) {
191  $out = '-';
192  } elseif (($p & 0x6000) == 0x6000) {
193  $out = 'b';
194  } elseif (($p & 0x4000) == 0x4000) {
195  $out = 'd';
196  } elseif (($p & 0x2000) == 0x2000) {
197  $out = 'c';
198  } elseif (($p & 0x1000) == 0x1000) {
199  $out = 'p';
200  } else {
201  $out = 'u';
202  }
203 
204  $out .=
205  (($p & 0x0100) ? 'r' : '-') .
206  (($p & 0x0080) ? 'w' : '-') .
207  (($p & 0x0040) ?
208  (($p & 0x0800) ? 's' : 'x') :
209  (($p & 0x0800) ? 'S' : '-')) .
210  (($p & 0x0020) ? 'r' : '-') .
211  (($p & 0x0010) ? 'w' : '-') .
212  (($p & 0x0008) ?
213  (($p & 0x0400) ? 's' : 'x') :
214  (($p & 0x0400) ? 'S' : '-')) .
215  (($p & 0x0004) ? 'r' : '-') .
216  (($p & 0x0002) ? 'w' : '-') .
217  (($p & 0x0001) ?
218  (($p & 0x0200) ? 't' : 'x') :
219  (($p & 0x0200) ? 'T' : '-'));
220 
221  return $out;
222  }

Here is the call graph for this function:

Hoa\File\Generic::getRealPath ( )

Get a canonicalized absolute pathname.

Returns
string

Definition at line 563 of file Generic.php.

564  {
565  if (false === $out = realpath($this->getStreamName())) {
566  return $this->getStreamName();
567  }
568 
569  return $out;
570  }

Here is the call graph for this function:

Hoa\File\Generic::getSize ( )

Get size.

Returns
int

Implements Hoa\Stream\IStream\Statable.

Definition at line 89 of file Generic.php.

90  {
91  if (false === $this->getStatistic()) {
92  return false;
93  }
94 
95  return filesize($this->getStreamName());
96  }

Here is the call graph for this function:

Hoa\File\Generic::getStatistic ( )

Get informations about a file.

Returns
array

Implements Hoa\Stream\IStream\Statable.

Definition at line 103 of file Generic.php.

104  {
105  return fstat($this->getStream());
106  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\File\Generic::isBlockSpecial ( )

Check if it is block special.

Returns
bool

Definition at line 495 of file Generic.php.

496  {
497  return filetype($this->getStreamName()) == 'block';
498  }

Here is the call graph for this function:

static Hoa\File\Generic::isCaseSensitive ( )
static

Check if the system is case sensitive or not.

Returns
bool

Definition at line 550 of file Generic.php.

551  {
552  return !(
553  file_exists(mb_strtolower(__FILE__)) &&
554  file_exists(mb_strtoupper(__FILE__))
555  );
556  }
Hoa\File\Generic::isCharacterSpecial ( )

Check if it is character special file.

Returns
bool

Definition at line 485 of file Generic.php.

486  {
487  return filetype($this->getStreamName()) == 'char';
488  }

Here is the call graph for this function:

Hoa\File\Generic::isDirectory ( )

Check if it is a directory.

Returns
bool

Definition at line 455 of file Generic.php.

456  {
457  return is_dir($this->getStreamName());
458  }

Here is the call graph for this function:

Hoa\File\Generic::isExecutable ( )

Check if the file is executable.

Returns
bool

Implements Hoa\Stream\IStream\Statable.

Definition at line 249 of file Generic.php.

250  {
251  return is_executable($this->getStreamName());
252  }

Here is the call graph for this function:

Hoa\File\Generic::isFIFOPipe ( )

Check if it is a FIFO pipe.

Returns
bool

Definition at line 475 of file Generic.php.

476  {
477  return filetype($this->getStreamName()) == 'fifo';
478  }

Here is the call graph for this function:

Hoa\File\Generic::isFile ( )

Check if it is a file.

Returns
bool

Definition at line 435 of file Generic.php.

436  {
437  return is_file($this->getStreamName());
438  }

Here is the call graph for this function:

Hoa\File\Generic::isLink ( )

Check if it is a link.

Returns
bool

Definition at line 445 of file Generic.php.

446  {
447  return is_link($this->getStreamName());
448  }

Here is the call graph for this function:

Hoa\File\Generic::isReadable ( )

Check if the file is readable.

Returns
bool

Implements Hoa\Stream\IStream\Statable.

Definition at line 229 of file Generic.php.

230  {
231  return is_readable($this->getStreamName());
232  }

Here is the call graph for this function:

Hoa\File\Generic::isSocket ( )

Check if it is a socket.

Returns
bool

Definition at line 465 of file Generic.php.

466  {
467  return filetype($this->getStreamName()) == 'socket';
468  }

Here is the call graph for this function:

Hoa\File\Generic::isUnknown ( )

Check if it is an unknown type.

Returns
bool

Definition at line 505 of file Generic.php.

506  {
507  return filetype($this->getStreamName()) == 'unknown';
508  }

Here is the call graph for this function:

Hoa\File\Generic::isWritable ( )

Check if the file is writable.

Returns
bool

Implements Hoa\Stream\IStream\Statable.

Definition at line 239 of file Generic.php.

240  {
241  return is_writable($this->getStreamName());
242  }

Here is the call graph for this function:

Hoa\File\Generic::move (   $name,
  $force = Stream\IStream\Touchable::DO_NOT_OVERWRITE,
  $mkdir = Stream\IStream\Touchable::DO_NOT_MAKE_DIRECTORY 
)

Move a file.

Parameters
string$nameNew name.
bool$forceForce to move if the file $name already exists. Use the ::*OVERWRITE constants.
bool$mkdirForce to make directory if does not exist. Use the ::*DIRECTORY constants.
Returns
bool

Implements Hoa\Stream\IStream\Touchable.

Definition at line 338 of file Generic.php.

342  {
343  $from = $this->getStreamName();
344 
345  if ($force === Stream\IStream\Touchable::DO_NOT_OVERWRITE &&
346  true === file_exists($name)) {
347  return false;
348  }
349 
350  if (Stream\IStream\Touchable::MAKE_DIRECTORY === $mkdir) {
352  dirname($name),
354  );
355  }
356 
357  if (null === $this->getStreamContext()) {
358  return @rename($from, $name);
359  }
360 
361  return @rename($from, $name, $this->getStreamContext()->getContext());
362  }
const MODE_CREATE_RECURSIVE
Definition: Directory.php:72
static create($name, $mode=self::MODE_CREATE_RECURSIVE, $context=null)
Definition: Directory.php:221

Here is the call graph for this function:

Hoa\File\Generic::setMode (   $mode)
protected

Set the open mode.

Parameters
string$modeOpen mode. Please, see the child::MODE_* constants.
Returns
string

Definition at line 517 of file Generic.php.

518  {
519  $old = $this->_mode;
520  $this->_mode = $mode;
521 
522  return $old;
523  }

Here is the caller graph for this function:

Hoa\File\Generic::touch (   $time = -1,
  $atime = -1 
)

Set access and modification time of file.

Parameters
int$timeTime. If equals to -1, time() should be used.
int$atimeAccess time. If equals to -1, $time should be used.
Returns
bool

Implements Hoa\Stream\IStream\Touchable.

Definition at line 286 of file Generic.php.

287  {
288  if ($time == -1) {
289  $time = time();
290  }
291 
292  if ($atime == -1) {
293  $atime = $time;
294  }
295 
296  return touch($this->getStreamName(), $time, $atime);
297  }
touch($time=-1, $atime=-1)
Definition: Generic.php:286

Here is the call graph for this function:

Here is the caller graph for this function:

static Hoa\File\Generic::umask (   $umask = null)
static

Change the current umask.

Parameters
int$umaskUmask (in octal!). If null, given the current umask value.
Returns
int

Implements Hoa\Stream\IStream\Touchable.

Definition at line 421 of file Generic.php.

422  {
423  if (null === $umask) {
424  return umask();
425  }
426 
427  return umask($umask);
428  }
static umask($umask=null)
Definition: Generic.php:421

Member Data Documentation

Hoa\File\Generic::$_mode = null
protected

Definition at line 60 of file Generic.php.


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