37 $this->CONFIG = $CONFIG;
39 if ($directory_root) {
40 $this->dir_root = $directory_root;
42 $this->dir_root = $this->CONFIG->dataroot;
64 $ls = strrpos($fullname,
"/");
69 $path = substr($fullname, 0, $ls);
71 if ((
$mode !=
'write') && (!file_exists($fullname))) {
80 _elgg_services()->logger->warn(
"Couldn't create directory: $path");
96 $msg =
"Unrecognized file mode '" .
$mode .
"'";
97 throw new \InvalidParameterException($msg);
100 return fopen($fullname,
$mode);
113 return fwrite($f,
$data);
130 return fread($f, $length);
222 $msg =
"File " . $file->
getFilename() .
" (file guid:" . $file->guid .
") is missing an owner!";
223 throw new \InvalidParameterException($msg);
233 return $this->dir_root . $dir . $file->
getFilename();
289 elgg_deprecated_notice(
'\ElggDiskFilestore::make_directory_root() is deprecated by ::makeDirectoryRoot()', 1.8);
304 if (!file_exists($dirroot)) {
305 if (!@mkdir($dirroot, 0700,
true)) {
306 throw new \IOException(
"Could not make " . $dirroot);
320 return array(
"dir_root" => $this->dir_root);
331 if (isset($parameters[
'dir_root'])) {
332 $this->dir_root = $parameters[
'dir_root'];
355 elgg_deprecated_notice(
'\ElggDiskFilestore::make_file_matrix() is deprecated by \Elgg\EntityDirLocator', 1.8);
374 elgg_deprecated_notice(
'\ElggDiskFilestore::user_file_matrix() is deprecated by \Elgg\EntityDirLocator', 1.8);
393 private function mb_str_split(
$string, $charset =
'UTF8') {
396 if (is_callable(
'mb_substr')) {
401 $array[] = mb_substr(
$string, 0, 1, $charset);
423 elgg_deprecated_notice(
'\ElggDiskFilestore::makeFileMatrix() is deprecated by \Elgg\EntityDirLocator', 1.9);
430 $dir = new \Elgg\EntityDirLocator(
$guid);
431 return $dir->getPath();
eof($f)
Tests for end of file on a file pointer.
close($f)
Close a file pointer.
const BUCKET_SIZE
Number of entries per matrix dir.
$mode
Configure site maintenance mode.
make_directory_root($dirroot)
Create a directory $dirroot.
getFilenameOnFilestore(\ElggFile $file)
Get the filename as saved on disk for an object.
read($f, $length, $offset=0)
Read data from a file.
user_file_matrix($guid)
Construct a filename matrix.
open(\ElggFile $file, $mode)
Open a file for reading, writing, or both.
getFileSize(\ElggFile $file)
Returns the file size of an file.
get_dir_size($dir, $total_size=0)
Get the size of the specified directory.
make_file_matrix($identifier)
Deprecated methods.
$guid
Removes an admin notice.
__construct($directory_root="")
Construct a disk filestore using the given directory root.
makeFileMatrix($guid)
Construct a file path matrix for an entity.
getFilenameOnFilestore()
Return the filename of this file as it is/will be stored on the filestore, which may be different to ...
makeDirectoryRoot($dirroot)
Create a directory $dirroot.
write($f, $data)
Write data to a file.
getFilename()
Return the filename.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
getSize($prefix, $container_guid)
Returns the size of all data stored under a directory in the disk store.
grabFile(\ElggFile $file)
Returns the contents of the file.
setParameters(array $parameters)
Sets parameters that should be saved to database.
exists(\ElggFile $file)
Tests if an file exists.
tell($f)
Return the current location of the internal pointer.
seek($f, $position)
Seek to the specified position.
getParameters()
Returns a list of attributes to save to the database when saving the object using this file store...
get_entity($guid)
Loads and returns an entity object from a guid.