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

Public Member Functions

 __construct ($streamName, $mode=self::MODE_READ, $context=null, $wait=false)
 
 copy ($to, $force=Stream\IStream\Touchable::DO_NOT_OVERWRITE)
 
 delete ()
 
- 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 ()
 

Static Public Member Functions

static create ($name, $mode=self::MODE_CREATE_RECURSIVE, $context=null)
 
- 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

const MODE_READ = 'rb'
 
const MODE_CREATE = 'xb'
 
const MODE_CREATE_RECURSIVE = 'xrb'
 
- 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
 

Protected Member Functions

_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

- 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 .

Directory handler.

Definition at line 49 of file Directory.php.

Constructor & Destructor Documentation

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

Open a directory.

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 86 of file Directory.php.

91  {
92  $this->setMode($mode);
93  parent::__construct($streamName, $context, $wait);
94 
95  return;
96  }
setMode($mode)
Definition: Generic.php:517

Here is the call graph for this function:

Member Function Documentation

Hoa\File\Directory::_close ( )
protected

Close the current stream.

Returns
bool

Definition at line 137 of file Directory.php.

138  {
139  return true;
140  }
& Hoa\File\Directory::_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 107 of file Directory.php.

108  {
109  if (false === is_dir($streamName)) {
110  if ($this->getMode() == self::MODE_READ) {
111  throw new Exception\FileDoesNotExist(
112  'Directory %s does not exist.',
113  0,
114  $streamName
115  );
116  } else {
117  self::create(
118  $streamName,
119  $this->getMode(),
120  null !== $context
121  ? $context->getContext()
122  : null
123  );
124  }
125  }
126 
127  $out = null;
128 
129  return $out;
130  }

Here is the call graph for this function:

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

Copy file. Return the destination directory 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
Exceptions

Implements Hoa\Stream\IStream\Touchable.

Definition at line 153 of file Directory.php.

154  {
155  if (empty($to)) {
156  throw new Exception(
157  'The destination path (to copy) is empty.',
158  1
159  );
160  }
161 
162  $from = $this->getStreamName();
163  $fromLength = strlen($from) + 1;
164  $finder = new Finder();
165  $finder->in($from);
166 
167  self::create($to, self::MODE_CREATE_RECURSIVE);
168 
169  foreach ($finder as $file) {
170  $relative = substr($file->getPathname(), $fromLength);
171  $_to = $to . DS . $relative;
172 
173  if (true === $file->isDir()) {
174  self::create($_to, self::MODE_CREATE);
175 
176  continue;
177  }
178 
179  $file->open()->copy($_to, $force);
180  $file->close();
181  }
182 
183  return true;
184  }

Here is the call graph for this function:

static Hoa\File\Directory::create (   $name,
  $mode = self::MODE_CREATE_RECURSIVE,
  $context = null 
)
static

Create a directory.

Parameters
string$nameDirectory name.
string$modeCreate mode. Please, see the self::MODE_CREATE* constants.
string$contextContext ID (please, see the class).
Returns
bool
Exceptions

Definition at line 221 of file Directory.php.

225  {
226  if (true === is_dir($name)) {
227  return true;
228  }
229 
230  if (empty($name)) {
231  return false;
232  }
233 
234  if (null !== $context) {
235  if (false === Stream\Context::contextExists($context)) {
236  throw new Exception(
237  'Context %s was not previously declared, cannot retrieve ' .
238  'this context.',
239  2,
240  $context
241  );
242  } else {
243  $context = Stream\Context::getInstance($context);
244  }
245  }
246 
247  if (null === $context) {
248  return @mkdir(
249  $name,
250  0755,
251  self::MODE_CREATE_RECURSIVE === $mode
252  );
253  }
254 
255  return @mkdir(
256  $name,
257  0755,
258  self::MODE_CREATE_RECURSIVE === $mode,
259  $context->getContext()
260  );
261  }
static contextExists($id)
Definition: Context.php:114
static getInstance($id)
Definition: Context.php:85

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\File\Directory::delete ( )

Delete a directory.

Returns
bool

Implements Hoa\Stream\IStream\Touchable.

Definition at line 191 of file Directory.php.

192  {
193  $from = $this->getStreamName();
194  $finder = new Finder();
195  $finder->in($from)
196  ->childFirst();
197 
198  foreach ($finder as $file) {
199  $file->open()->delete();
200  $file->close();
201  }
202 
203  if (null === $this->getStreamContext()) {
204  return @rmdir($from);
205  }
206 
207  return @rmdir($from, $this->getStreamContext()->getContext());
208  }

Here is the call graph for this function:

Member Data Documentation

const Hoa\File\Directory::MODE_CREATE = 'xb'

Open for reading and writing. If the directory does not exist, attempt to create it.

string

Definition at line 64 of file Directory.php.

const Hoa\File\Directory::MODE_CREATE_RECURSIVE = 'xrb'

Open for reading and writing. If the directory does not exist, attempt to create it recursively.

string

Definition at line 72 of file Directory.php.

const Hoa\File\Directory::MODE_READ = 'rb'

Open for reading.

string

Definition at line 56 of file Directory.php.


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