HPCloud-PHP  1.2.0
PHP bindings for HPCloud and OpenStack services.
 All Classes Namespaces Files Functions Variables Pages
StreamWrapperFS.php File Reference

Contains the stream wrapper for swiftfs:// URLs. More...

Go to the source code of this file.

Classes

class  StreamWrapperFS
 Provides stream wrapping for Swift like a file system. More...

Namespaces

namespace  HPCloud\Storage\ObjectStorage
 Classes specific to ObjectStorage.

Detailed Description

Contains the stream wrapper for swiftfs:// URLs.

Note, this stream wrapper is in early testing.

The stream wrapper implemented in HPCloud only supports the elements of a stream that are implemented by object storage. This is how the PHP documentation states a stream wrapper should be created. Because some features do not exist, attempting to treat a stream wrapper as if it were a file system will not entirely work. For example, while there are not directories objects have pathy names (with / separators). Directory calls to object storage with the default stream wrappers will not operate how they would for a file system.

StreamWrapperFS is an attempt to make a filesystem like stream wrapper. Hence the protocol is swiftfs standing for swift file system.

To understand how this stream wrapper works start by first reading the documentation on the HPCloud::Storage::ObjectStorage::StreamWrapper.

DIRECTORIES

Because OpenStack Swift does not support directories the swift:// stream wrapper does not support them. This stream wrapper attempts to fake them by faking directory stats, mkdir, and rmdir. By default (see the options below for how to change these) directories have permissions of 777, timestamps close to that of the request, and the user and group called by php. We mock these on the fly though information is stored in the PHP stat cache.

In addition to the parameters supported by StreamWrapper, the following parameters may be set either in the stream context or through HPCloud::Bootstrap::setConfiguration():

  • swiftfs_fake_stat_mode: Directories don't exist in swift. When stat() is is called on a directory we mock the stat information so functions like is_dir will work. The default file permissions is 0777. Though this parameter you can pass is a different set of file permissions to use for these mock stats.
  • swiftfs_fake_isdir_true: Directory functions like mkdir and is_dir (stat) check to see if there are objects with the the passed in directory as a prefix to see if it already exists. If you want is_dir to always return true even if it is not an existing prefix set this to TRUE. Defaults to FALSE.

Definition in file StreamWrapperFS.php.