Elgg  Version 1.11
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)
 Delete an \ElggFile 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 \ElggFile file. More...
 
 getFilenameOnFilestore (\ElggFile $file)
 Get the filename as saved on disk for an \ElggFile object. More...
 
 grabFile (\ElggFile $file)
 Returns the contents of the \ElggFile file. More...
 
 exists (\ElggFile $file)
 Tests if an \ElggFile 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 \ElggFile object using this file store. More...
 
 setParameters (array $parameters)
 Sets parameters that should be saved to database. More...
 

Public Attributes

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

Protected Member Functions

 make_directory_root ($dirroot)
 Create a directory $dirroot. More...
 
 makeDirectoryRoot ($dirroot)
 Create a directory $dirroot. More...
 
 make_file_matrix ($identifier)
 Deprecated methods. More...
 
 user_file_matrix ($guid)
 Construct a filename matrix. More...
 
 makeFileMatrix ($guid)
 Construct a file path matrix for an entity. More...
 

Detailed Description

Definition at line 11 of file ElggDiskFilestore.php.

Constructor & Destructor Documentation

◆ __construct()

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

◆ close()

ElggDiskFilestore::close (   $f)

Close a file pointer.

Parameters
resource$fA file pointer resource
Returns
bool

Reimplemented from ElggFilestore.

Definition at line 140 of file ElggDiskFilestore.php.

◆ delete()

ElggDiskFilestore::delete ( \ElggFile  $file)

Delete an \ElggFile file.

Parameters
\ElggFile$fileFile to delete
Returns
bool

Reimplemented from ElggFilestore.

Definition at line 151 of file ElggDiskFilestore.php.

◆ eof()

ElggDiskFilestore::eof (   $f)

Tests for end of file on a file pointer.

Parameters
resource$fFile pointer resource
Returns
bool

Reimplemented from ElggFilestore.

Definition at line 190 of file ElggDiskFilestore.php.

◆ exists()

ElggDiskFilestore::exists ( \ElggFile  $file)

Tests if an \ElggFile file exists.

Parameters
\ElggFile$fileFile object
Returns
bool

Reimplemented from ElggFilestore.

Definition at line 254 of file ElggDiskFilestore.php.

◆ getFilenameOnFilestore()

ElggDiskFilestore::getFilenameOnFilestore ( \ElggFile  $file)

Get the filename as saved on disk for an \ElggFile 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

Reimplemented from ElggFilestore.

Definition at line 215 of file ElggDiskFilestore.php.

◆ getFileSize()

ElggDiskFilestore::getFileSize ( \ElggFile  $file)

Returns the file size of an \ElggFile file.

Parameters
\ElggFile$fileFile object
Returns
int The file size

Reimplemented from ElggFilestore.

Definition at line 201 of file ElggDiskFilestore.php.

◆ getParameters()

ElggDiskFilestore::getParameters ( )

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

Returns
array

Reimplemented from ElggFilestore.

Definition at line 319 of file ElggDiskFilestore.php.

◆ getSize()

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 269 of file ElggDiskFilestore.php.

◆ grabFile()

ElggDiskFilestore::grabFile ( \ElggFile  $file)

Returns the contents of the \ElggFile file.

Parameters
\ElggFile$fileFile object
Returns
string

Reimplemented from ElggFilestore.

Definition at line 243 of file ElggDiskFilestore.php.

◆ make_directory_root()

ElggDiskFilestore::make_directory_root (   $dirroot)
protected

Create a directory $dirroot.

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

Definition at line 288 of file ElggDiskFilestore.php.

◆ make_file_matrix()

ElggDiskFilestore::make_file_matrix (   $identifier)
protected

Deprecated methods.

Construct a file path matrix for an entity.

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

Definition at line 354 of file ElggDiskFilestore.php.

◆ makeDirectoryRoot()

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 303 of file ElggDiskFilestore.php.

◆ makeFileMatrix()

ElggDiskFilestore::makeFileMatrix (   $guid)
protected

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 422 of file ElggDiskFilestore.php.

◆ open()

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

Reimplemented from ElggFilestore.

Definition at line 60 of file ElggDiskFilestore.php.

◆ read()

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.

Reimplemented from ElggFilestore.

Definition at line 125 of file ElggDiskFilestore.php.

◆ seek()

ElggDiskFilestore::seek (   $f,
  $position 
)

Seek to the specified position.

Parameters
resource$fFile resource
int$positionPosition in bytes
Returns
bool

Reimplemented from ElggFilestore.

Definition at line 168 of file ElggDiskFilestore.php.

◆ setParameters()

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

Reimplemented from ElggFilestore.

Definition at line 330 of file ElggDiskFilestore.php.

◆ tell()

ElggDiskFilestore::tell (   $f)

Return the current location of the internal pointer.

Parameters
resource$fFile pointer resource
Returns
int|false

Reimplemented from ElggFilestore.

Definition at line 179 of file ElggDiskFilestore.php.

◆ user_file_matrix()

ElggDiskFilestore::user_file_matrix (   $guid)
protected

Construct a filename matrix.

Generates a matrix using the entity's creation time and unique guid.

Parameters
int$guidThe entity to contrust a matrix for
Returns
string The

Definition at line 373 of file ElggDiskFilestore.php.

◆ write()

ElggDiskFilestore::write (   $f,
  $data 
)

Write data to a file.

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

Reimplemented from ElggFilestore.

Definition at line 112 of file ElggDiskFilestore.php.

Member Data Documentation

◆ BUCKET_SIZE

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: