Permalink
Browse files

Adding basic stream support for various storage mechanisms.

  • Loading branch information...
1 parent 52682f6 commit 13d98a588daf0590d7cdbe196fecf44e61c13114 @LouisLandry committed Nov 13, 2011
@@ -0,0 +1,69 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Stream
+ *
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die();
+
+/**
+ * Joomla Stream Directory Interface. This interface adds directory functionality to a userland
+ * stream wrapper which is used to read a directory.
+ *
+ * @package Joomla.Platform
+ * @subpackage Stream
+ * @since 11.3
+ */
+interface JStreamDirectory
+{
+ /**
+ * Method to close a directory handle. This method is called in response to closedir(). Any
+ * resources which were locked, or allocated, during opening and use of the directory stream
+ * should be released.
+ *
+ * @return boolean True on success.
+ *
+ * @see closedir()
+ * @since 11.3
+ */
+ public function dir_closedir();
+
+ /**
+ * Method to open a directory handle. This method is called in response to opendir().
+ *
+ * @param string $path The URL for the resource to be opened as a directory handle.
+ * @param integer $options A bitwise mask of options for the directory handle.
+ *
+ * @return boolean True on success.
+ *
+ * @see opendir()
+ * @since 11.3
+ */
+ public function dir_opendir($path, $options);
+
+ /**
+ * Method to read the next entry from a directory handle. This method is called in response
+ * to readdir().
+ *
+ * @return mixed String representing the next filename or boolean false if there is no next file.
+ *
+ * @see readdir()
+ * @since 11.3
+ */
+ public function dir_readdir();
+
+ /**
+ * Method to rewind a directory handle. This method is called in response to rewinddir(). Should
+ * reset the output generated by self::dir_readdir(). i.e.: The next call to self::dir_readdir()
+ * should return the first entry in the location returned by self::dir_opendir().
+ *
+ * @return boolean True on success.
+ *
+ * @see rewinddir()
+ * @since 11.3
+ */
+ public function dir_rewinddir();
+}
@@ -0,0 +1,48 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Stream
+ *
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die();
+
+/**
+ * Joomla Stream Writeable Directory Interface. This interface adds rmdir() and mkdir() functionality
+ * for the userland stream wrapper.
+ *
+ * @package Joomla.Platform
+ * @subpackage Stream
+ * @since 11.3
+ */
+interface JStreamDirectoryWriteable extends JStreamDirectory
+{
+ /**
+ * Method to create a directory. This method is called in response to mkdir().
+ *
+ * @param string $path URL for the directory which should be created.
+ * @param integer $mode The value passed to mkdir().
+ * @param integer $options A bitwise mask of options for creating the directory.
+ *
+ * @return boolean True on success.
+ *
+ * @see mkdir()
+ * @since 11.3
+ */
+ public function mkdir($path, $mode, $options);
+
+ /**
+ * Method to remove a directory. This method is called in response to rmdir().
+ *
+ * @param string $path URL for the directory which should be removed.
+ * @param integer $options A bitwise mask of options for removing the directory.
+ *
+ * @return boolean True on success.
+ *
+ * @see rmdir()
+ * @since 11.3
+ */
+ public function rmdir($path, $options);
+}
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Stream
+ *
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die();
+
+/**
+ * Joomla Stream Flush Interface. This interface should be implemented if at all possible as it
+ * adds support for writing cached data to the stream.
+ *
+ * @package Joomla.Platform
+ * @subpackage Stream
+ * @since 11.3
+ */
+interface JStreamFlush
+{
+ /**
+ * Method to flush stream output. This method is called in response to fflush(). If you have
+ * cached data in your stream but not yet stored it into the underlying storage, you should
+ * do so now.
+ *
+ * @return boolean Boolean true if the cached data was successfully stored (or if there was
+ * no data to store).
+ *
+ * @see fflush()
+ * @since 11.3
+ */
+ public function stream_flush();
+}
@@ -0,0 +1,40 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Stream
+ *
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die();
+
+/**
+ * Joomla Stream Lock Interface. This interface adds locking support to userland stream wrappers.
+ *
+ * @package Joomla.Platform
+ * @subpackage Stream
+ * @since 11.3
+ */
+interface JStreamLock
+{
+ /**
+ * Method to set locking for the resource. This method is called in response to flock(),
+ * when file_put_contents() (when flags contains LOCK_EX), stream_set_blocking() and when
+ * closing the stream (LOCK_UN).
+ *
+ * @param integer $option One of the following advisories:
+ * LOCK_SH to acquire a shared lock (reader).
+ * LOCK_EX to acquire an exclusive lock (writer).
+ * LOCK_UN to release a lock (shared or exclusive).
+ * LOCK_NB if you don't want flock() to block while locking.
+ *
+ * @return boolean True on success.
+ *
+ * @see flock()
+ * @see file_put_contents()
+ * @see stream_set_blocking()
+ * @since 11.3
+ */
+ public function stream_lock($option);
+}
@@ -0,0 +1,47 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Stream
+ *
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die();
+
+/**
+ * Joomla Stream Options Interface. This interface adds the ability to set timeout, blocking and
+ * write buffer size options for the userland stream wrapper.
+ *
+ * @package Joomla.Platform
+ * @subpackage Stream
+ * @since 11.3
+ */
+interface JStreamOptions
+{
+ /**
+ * Method to set options for the stream resource.
+ * Note: PHP 5.3+
+ *
+ * @param integer $option The option to set for the stream. One of the following:
+ * STREAM_OPTION_BLOCKING: In response to stream_set_blocking().
+ * STREAM_OPTION_READ_TIMEOUT: In response to stream_set_timeout();
+ * STREAM_OPTION_WRITE_BUFFER: In response to stream_set_write_buffer();
+ * @param integer $arg1 First argument to the option. If the option is:
+ * STREAM_OPTION_BLOCKING: Blocking mode [1 = block or 0 = non-blocking].
+ * STREAM_OPTION_READ_TIMEOUT: Timeout in seconds.
+ * STREAM_OPTION_WRITE_BUFFER: Buffer mode [STREAM_BUFFER_NONE or STREAM_BUFFER_FULL].
+ * @param integer $arg2 Second argument to the option. If the option is:
+ * STREAM_OPTION_BLOCKING: Not used.
+ * STREAM_OPTION_READ_TIMEOUT: Timeout in microseconds.
+ * STREAM_OPTION_WRITE_BUFFER: Buffer size.
+ *
+ * @return boolean True on success.
+ *
+ * @see stream_set_blocking()
+ * @see stream_set_timeout()
+ * @see stream_set_write_buffer()
+ * @since 11.3
+ */
+ public function stream_set_option($option, $arg1, $arg2);
+}
@@ -0,0 +1,51 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Stream
+ *
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die();
+
+/**
+ * Joomla Stream Permissions Interface. This interface adds the ability for the userland stream
+ * wrapper to support changing of ownership and permissions. This is only supported in PHP 5.4+
+ *
+ * @package Joomla.Platform
+ * @subpackage Stream
+ * @since 11.3
+ */
+interface JStreamPermissions
+{
+ /**
+ * Method to create a directory. This method is called in response to mkdir().
+ * Note: PHP 5.4+
+ *
+ * @param string $path URL for the file or folder for which stream metadata should be set.
+ * @param integer $option One of the following metadata types:
+ * PHP_STREAM_META_TOUCH
+ * PHP_STREAM_META_OWNER_NAME
+ * PHP_STREAM_META_OWNER
+ * PHP_STREAM_META_GROUP_NAME
+ * PHP_STREAM_META_GROUP
+ * PHP_STREAM_META_ACCESS
+ * @param integer $args If the $option is:
+ * PHP_STREAM_META_TOUCH: array of arguments to the touch() function.
+ * PHP_STREAM_META_OWNER_NAME: string name of the owner.
+ * PHP_STREAM_META_GROUP_NAME: string name of the group.
+ * PHP_STREAM_META_OWNER: integer value of the owner.
+ * PHP_STREAM_META_GROUP: integer value of the group.
+ * PHP_STREAM_META_ACCESS: integer value of the chmod() function.
+ *
+ * @return boolean True on success.
+ *
+ * @see touch()
+ * @see chmod()
+ * @see chown()
+ * @see chgrp()
+ * @since 11.3
+ */
+ public function stream_metadata($path, $option, $args);
+}
@@ -0,0 +1,50 @@
+<?php
+/**
+ * @package Joomla.Platform
+ * @subpackage Stream
+ *
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+defined('JPATH_PLATFORM') or die();
+
+/**
+ * Joomla Stream Seek Interface. This interface adds the ability for the userland stream wrapper
+ * to move forward in the data.
+ *
+ * @package Joomla.Platform
+ * @subpackage Stream
+ * @since 11.3
+ */
+interface JStreamSeek
+{
+ /**
+ * Method to seek to a specific position in the stream resource. This method is called in
+ * response to fseek(). The read/write position of the stream should be updated according to
+ * the offset and whence.
+ *
+ * @param integer $offset The byte offset within the stream to seek to.
+ * @param integer $whence How to set the offset. Possibilities are:
+ * SEEK_SET: Set position equal to offset bytes.
+ * SEEK_CUR: Set position to current location plus offset.
+ * SEEK_END: Set position to end-of-file plus offset.
+ *
+ * @return boolean True on success
+ *
+ * @see fseek()
+ * @since 11.3
+ */
+ public function stream_seek($offset, $whence = SEEK_SET);
+
+ /**
+ * Method to retrieve the current position of a stream. This method is called in response to
+ * fseek() to determine the current position.
+ *
+ * @return integer The current position of the stream.
+ *
+ * @see fseek()
+ * @since 11.3
+ */
+ public function stream_tell();
+}
Oops, something went wrong.

0 comments on commit 13d98a5

Please sign in to comment.