Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ElggDiskFilestore Class Reference
Inheritance diagram for ElggDiskFilestore:
ElggFilestore

Public Member Functions

 __construct ($directory_root="")
 Construct a disk filestore using the given directory root. More...
 
 open (\ElggFile $file, $mode)
 Open a file for reading, writing, or both. More...
 
 write ($f, $data)
 Write data to a file. More...
 
 read ($f, $length, $offset=0)
 Read data from a file. More...
 
 close ($f)
 Close a file pointer. More...
 
 delete (\ElggFile $file, $follow_symlinks=true)
 Delete an file. More...
 
 seek ($f, $position)
 Seek to the specified position. More...
 
 tell ($f)
 Return the current location of the internal pointer. More...
 
 eof ($f)
 Tests for end of file on a file pointer. More...
 
 getFileSize (\ElggFile $file)
 Returns the file size of an file. More...
 
 getFilenameOnFilestore (\ElggFile $file)
 Get the filename as saved on disk for an object. More...
 
 grabFile (\ElggFile $file)
 Returns the contents of the file. More...
 
 exists (\ElggFile $file)
 Tests if an file exists. More...
 
 getSize ($prefix, $container_guid)
 Returns the size of all data stored under a directory in the disk store. More...
 
 getParameters ()
 Returns a list of attributes to save to the database when saving the object using this file store. More...
 
 setParameters (array $parameters)
 Sets parameters that should be saved to database. More...
 
- Public Member Functions inherited from ElggFilestore
 open (\ElggFile $file, $mode)
 Attempt to open the file $file for storage or writing. More...
 
 write ($f, $data)
 Write data to a given file handle. More...
 
 read ($f, $length, $offset=0)
 Read data from a filestore. More...
 
 seek ($f, $position)
 Seek a given position within a file handle. More...
 
 eof ($f)
 Return a whether the end of a file has been reached. More...
 
 tell ($f)
 Return the current position in an open file. More...
 
 close ($f)
 Close a given file handle. More...
 
 delete (\ElggFile $file, $follow_symlinks=true)
 Delete the file associated with a given file handle. More...
 
 getFileSize (\ElggFile $file)
 Return the size in bytes for a given file. More...
 
 getFilenameOnFilestore (\ElggFile $file)
 Return the filename of a given file as stored on the filestore. More...
 
 getParameters ()
 Get the filestore's creation parameters as an associative array. More...
 
 setParameters (array $parameters)
 Set the parameters from the associative array produced by $this->getParameters(). More...
 
 grabFile (\ElggFile $file)
 Get the contents of the whole file. More...
 
 exists (\ElggFile $file)
 Return whether a file physically exists or not. More...
 

Public Attributes

const BUCKET_SIZE = 5000
 Number of entries per matrix dir. More...
 

Protected Member Functions

 makeDirectoryRoot ($dirroot)
 Create a directory $dirroot. More...
 
 makeFileMatrix ($guid)
 Deprecated methods. More...
 

Detailed Description

Definition at line 11 of file ElggDiskFilestore.php.

Constructor & Destructor Documentation

ElggDiskFilestore::__construct (   $directory_root = "")

Construct a disk filestore using the given directory root.

Parameters
string$directory_rootRoot directory, must end in "/"

Definition at line 35 of file ElggDiskFilestore.php.

Member Function Documentation

ElggDiskFilestore::close (   $f)

Close a file pointer.

Parameters
resource$fA file pointer resource
Returns
bool

Definition at line 140 of file ElggDiskFilestore.php.

ElggDiskFilestore::delete ( \ElggFile  $file,
  $follow_symlinks = true 
)

Delete an file.

Parameters
\ElggFile$fileFile to delete
bool$follow_symlinksIf true, will also delete the target file if the current file is a symlink
Returns
bool

Definition at line 151 of file ElggDiskFilestore.php.

ElggDiskFilestore::eof (   $f)

Tests for end of file on a file pointer.

Parameters
resource$fFile pointer resource
Returns
bool

Definition at line 194 of file ElggDiskFilestore.php.

ElggDiskFilestore::exists ( \ElggFile  $file)

Tests if an file exists.

Parameters
\ElggFile$fileFile object
Returns
bool

Definition at line 258 of file ElggDiskFilestore.php.

ElggDiskFilestore::getFilenameOnFilestore ( \ElggFile  $file)

Get the filename as saved on disk for an object.

Returns an empty string if no filename set

Parameters
\ElggFile$fileFile object
Returns
string The full path of where the file is stored
Exceptions
InvalidParameterException

Definition at line 219 of file ElggDiskFilestore.php.

ElggDiskFilestore::getFileSize ( \ElggFile  $file)

Returns the file size of an file.

Parameters
\ElggFile$fileFile object
Returns
int The file size

Definition at line 205 of file ElggDiskFilestore.php.

ElggDiskFilestore::getParameters ( )

Returns a list of attributes to save to the database when saving the object using this file store.

Returns
array

Definition at line 306 of file ElggDiskFilestore.php.

ElggDiskFilestore::getSize (   $prefix,
  $container_guid 
)

Returns the size of all data stored under a directory in the disk store.

Parameters
string$prefixThe prefix to check under.
string$container_guidThe guid of the entity whose data you want to check.
Returns
int|false

Definition at line 273 of file ElggDiskFilestore.php.

ElggDiskFilestore::grabFile ( \ElggFile  $file)

Returns the contents of the file.

Parameters
\ElggFile$fileFile object
Returns
string

Definition at line 247 of file ElggDiskFilestore.php.

ElggDiskFilestore::makeDirectoryRoot (   $dirroot)
protected

Create a directory $dirroot.

Parameters
string$dirrootThe full path of the directory to create
Exceptions
IOException
Returns
true

Definition at line 290 of file ElggDiskFilestore.php.

ElggDiskFilestore::makeFileMatrix (   $guid)
protected

Deprecated methods.

Construct a file path matrix for an entity.

Parameters
int$guidThe guid of the entity to store the data under.
Returns
string The path where the entity's data will be stored relative to the data dir.

Definition at line 340 of file ElggDiskFilestore.php.

ElggDiskFilestore::open ( \ElggFile  $file,
  $mode 
)

Open a file for reading, writing, or both.

Note
All files are opened binary safe.
This will try to create the a directory if it doesn't exist and is opened in write or append mode.
Parameters
\ElggFile$fileThe file to open
string$moderead, write, or append.
Exceptions
InvalidParameterException
Returns
resource File pointer resource

Definition at line 60 of file ElggDiskFilestore.php.

ElggDiskFilestore::read (   $f,
  $length,
  $offset = 0 
)

Read data from a file.

Parameters
resource$fFile pointer resource
int$lengthThe number of bytes to read
int$offsetThe number of bytes to start after
Returns
mixed Contents of file or false on fail.

Definition at line 125 of file ElggDiskFilestore.php.

ElggDiskFilestore::seek (   $f,
  $position 
)

Seek to the specified position.

Parameters
resource$fFile resource
int$positionPosition in bytes
Returns
int 0 for success, or -1

Definition at line 172 of file ElggDiskFilestore.php.

ElggDiskFilestore::setParameters ( array  $parameters)

Sets parameters that should be saved to database.

Parameters
array$parametersSet parameters to save to DB for this filestore.
Returns
bool

Definition at line 317 of file ElggDiskFilestore.php.

ElggDiskFilestore::tell (   $f)

Return the current location of the internal pointer.

Parameters
resource$fFile pointer resource
Returns
int|false

Definition at line 183 of file ElggDiskFilestore.php.

ElggDiskFilestore::write (   $f,
  $data 
)

Write data to a file.

Parameters
resource$fFile pointer resource
mixed$dataThe data to write.
Returns
bool

Definition at line 112 of file ElggDiskFilestore.php.

Member Data Documentation

const ElggDiskFilestore::BUCKET_SIZE = 5000

Number of entries per matrix dir.

You almost certainly don't want to change this.

Definition at line 21 of file ElggDiskFilestore.php.


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