Elgg  Version master
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\Filesystem\Filestore\DiskFilestore Class Reference

A filestore that uses disk as storage. More...

Inheritance diagram for Elgg\Filesystem\Filestore\DiskFilestore:
Elgg\Filesystem\Filestore Elgg\Filesystem\Filestore\TempDiskFilestore

Public Member Functions

 __construct ($directory_root='')
 Construct a disk filestore using the given directory root. More...
 
 open (\ElggFile $file, string $mode)
 Open a file for reading, writing, or both. More...
 
 write ($f, $data)
 Write data to a file. More...
 
 read ($f, int $length, int $offset=0)
 Read data from a file. More...
 
 close ($f)
 Close a file pointer. More...
 
 delete (\ElggFile $file, bool $follow_symlinks=true)
 Delete an \ElggFile file. More...
 
 seek ($f, int $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...
 
 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 Member Functions inherited from Elgg\Filesystem\Filestore
 write ($f, string $data)
 Write data to a given file handle. More...
 

Public Attributes

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

Protected Member Functions

 makeDirectoryRoot ($dirroot)
 Create a directory $dirroot. More...
 

Protected Attributes

 $dir_root
 

Detailed Description

A filestore that uses disk as storage.

Warning
This should be used by a wrapper class like \ElggFile.

Definition at line 17 of file DiskFilestore.php.

Constructor & Destructor Documentation

◆ __construct()

Elgg\Filesystem\Filestore\DiskFilestore::__construct (   $directory_root = '')

Construct a disk filestore using the given directory root.

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

Reimplemented in Elgg\Filesystem\Filestore\TempDiskFilestore.

Definition at line 35 of file DiskFilestore.php.

Member Function Documentation

◆ close()

Elgg\Filesystem\Filestore\DiskFilestore::close (   $f)

Close a file pointer.

Parameters
resource$fA file pointer resource
Returns
bool

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 134 of file DiskFilestore.php.

◆ delete()

Elgg\Filesystem\Filestore\DiskFilestore::delete ( \ElggFile  $file,
bool  $follow_symlinks = true 
)

Delete an \ElggFile 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

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 146 of file DiskFilestore.php.

◆ eof()

Elgg\Filesystem\Filestore\DiskFilestore::eof (   $f)

Tests for end of file on a file pointer.

Parameters
resource$fFile pointer resource
Returns
bool

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 190 of file DiskFilestore.php.

◆ exists()

Elgg\Filesystem\Filestore\DiskFilestore::exists ( \ElggFile  $file)

Tests if an \ElggFile file exists.

Parameters
\ElggFile$fileFile object
Returns
bool

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 258 of file DiskFilestore.php.

◆ getFilenameOnFilestore()

Elgg\Filesystem\Filestore\DiskFilestore::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
InvalidArgumentException

Reimplemented from Elgg\Filesystem\Filestore.

Reimplemented in Elgg\Filesystem\Filestore\TempDiskFilestore.

Definition at line 215 of file DiskFilestore.php.

◆ getFileSize()

Elgg\Filesystem\Filestore\DiskFilestore::getFileSize ( \ElggFile  $file)

Returns the file size of an \ElggFile file.

Parameters
\ElggFile$fileFile object
Returns
int The file size

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 201 of file DiskFilestore.php.

◆ getParameters()

Elgg\Filesystem\Filestore\DiskFilestore::getParameters ( )

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

Returns
array

Reimplemented from Elgg\Filesystem\Filestore.

Reimplemented in Elgg\Filesystem\Filestore\TempDiskFilestore.

Definition at line 305 of file DiskFilestore.php.

◆ grabFile()

Elgg\Filesystem\Filestore\DiskFilestore::grabFile ( \ElggFile  $file)

Returns the contents of the \ElggFile file.

Parameters
\ElggFile$fileFile object
Returns
false|string

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 247 of file DiskFilestore.php.

◆ makeDirectoryRoot()

Elgg\Filesystem\Filestore\DiskFilestore::makeDirectoryRoot (   $dirroot)
protected

Create a directory $dirroot.

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

Definition at line 281 of file DiskFilestore.php.

◆ open()

Elgg\Filesystem\Filestore\DiskFilestore::open ( \ElggFile  $file,
string  $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.
Returns
false|resource File pointer resource or false on failure
Exceptions

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 56 of file DiskFilestore.php.

◆ read()

Elgg\Filesystem\Filestore\DiskFilestore::read (   $f,
int  $length,
int  $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
string|false Contents of file or false on fail.

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 119 of file DiskFilestore.php.

◆ seek()

Elgg\Filesystem\Filestore\DiskFilestore::seek (   $f,
int  $position 
)

Seek to the specified position.

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

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 168 of file DiskFilestore.php.

◆ setParameters()

Elgg\Filesystem\Filestore\DiskFilestore::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 Elgg\Filesystem\Filestore.

Reimplemented in Elgg\Filesystem\Filestore\TempDiskFilestore.

Definition at line 318 of file DiskFilestore.php.

◆ tell()

Elgg\Filesystem\Filestore\DiskFilestore::tell (   $f)

Return the current location of the internal pointer.

Parameters
resource$fFile pointer resource
Returns
int|false

Reimplemented from Elgg\Filesystem\Filestore.

Definition at line 179 of file DiskFilestore.php.

◆ write()

Elgg\Filesystem\Filestore\DiskFilestore::write (   $f,
  $data 
)

Write data to a file.

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

Definition at line 106 of file DiskFilestore.php.

Member Data Documentation

◆ $dir_root

Elgg\Filesystem\Filestore\DiskFilestore::$dir_root
protected

Definition at line 22 of file DiskFilestore.php.

◆ BUCKET_SIZE

const Elgg\Filesystem\Filestore\DiskFilestore::BUCKET_SIZE = 5000

Number of entries per matrix dir.

You almost certainly don't want to change this.

Definition at line 28 of file DiskFilestore.php.


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