Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
Core file system class definition.
Copyright: | 2017 Andrew Nicols <andrew@nicols.co.uk> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 665 lines (26 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
file_system:: (26 methods):
readfile()
get_local_path_from_storedfile()
get_remote_path_from_storedfile()
is_file_readable_locally_by_storedfile()
is_file_readable_remotely_by_storedfile()
is_file_readable_locally_by_hash()
is_file_readable_remotely_by_hash()
is_file_removable()
get_content()
list_files()
extract_to_pathname()
extract_to_storage()
add_storedfile_to_archive()
add_to_curl_request()
get_imageinfo()
is_image_from_storedfile()
get_imageinfo_from_path()
xsendfile_file()
xsendfile()
supports_xsendfile()
validate_hash_and_file_size()
get_content_file_handle()
get_file_handle_for_path()
mimetype_from_hash()
mimetype_from_storedfile()
cron()
Class: file_system - X-Ref
File system class used for low level access to real files in filedir.readfile(stored_file $file) X-Ref |
Output the content of the specified stored file. Note, this is different to get_content() as it uses the built-in php readfile function which is more efficient. return: void param: stored_file $file The file to serve. |
get_local_path_from_storedfile(stored_file $file, $fetchifnotfound = false) X-Ref |
Get the full path on disk for the specified stored file. Note: This must return a consistent path for the file's contenthash and the path _will_ be in a standard local format. Streamable paths will not work. A local copy of the file _will_ be fetched if $fetchifnotfound is tree. The $fetchifnotfound allows you to determine the expected path of the file. return: string full path to pool file with file content param: stored_file $file The file to serve. param: bool $fetchifnotfound Whether to attempt to fetch from the remote path if not found. |
get_remote_path_from_storedfile(stored_file $file) X-Ref |
Get a remote filepath for the specified stored file. This is typically either the same as the local filepath, or it is a streamable resource. See https://secure.php.net/manual/en/wrappers.php for further information on valid wrappers. return: string full path to pool file with file content param: stored_file $file The file to serve. |
is_file_readable_locally_by_storedfile(stored_file $file, $fetchifnotfound = false) X-Ref |
Determine whether the file is present on the file system somewhere. A local copy of the file _will_ be fetched if $fetchifnotfound is tree. The $fetchifnotfound allows you to determine the expected path of the file. return: bool param: stored_file $file The file to ensure is available. param: bool $fetchifnotfound Whether to attempt to fetch from the remote path if not found. |
is_file_readable_remotely_by_storedfile(stored_file $file) X-Ref |
Determine whether the file is present on the local file system somewhere. return: bool param: stored_file $file The file to ensure is available. |
is_file_readable_locally_by_hash($contenthash, $fetchifnotfound = false) X-Ref |
Determine whether the file is present on the file system somewhere given the contenthash. return: bool param: string $contenthash The contenthash of the file to check. param: bool $fetchifnotfound Whether to attempt to fetch from the remote path if not found. |
is_file_readable_remotely_by_hash($contenthash) X-Ref |
Determine whether the file is present locally on the file system somewhere given the contenthash. return: bool param: string $contenthash The contenthash of the file to check. |
is_file_removable($contenthash) X-Ref |
Check whether a file is removable. This must be called prior to file removal. return: bool param: string $contenthash |
get_content(stored_file $file) X-Ref |
Get the content of the specified stored file. Generally you will probably want to use readfile() to serve content, and where possible you should see if you can use get_content_file_handle and work with the file stream instead. return: string The full file content param: stored_file $file The file to retrieve |
list_files($file, file_packer $packer) X-Ref |
List contents of archive. return: array of file infos param: stored_file $file The archive to inspect param: file_packer $packer file packer instance |
extract_to_pathname(stored_file $file, file_packer $packer, $pathname, file_progress $progress = null) X-Ref |
Extract file to given file path (real OS filesystem), existing files are overwritten. return: array|bool List of processed files; false if error param: stored_file $file The archive to inspect param: file_packer $packer File packer instance param: string $pathname Target directory param: file_progress $progress progress indicator callback or null if not required |
extract_to_storage(stored_file $file, file_packer $packer, $contextid,$component, $filearea, $itemid, $pathbase, $userid = null, file_progress $progress = null) X-Ref |
Extract file to given file path (real OS filesystem), existing files are overwritten. return: array|bool list of processed files; false if error param: stored_file $file The archive to inspect param: file_packer $packer file packer instance param: int $contextid context ID param: string $component component param: string $filearea file area param: int $itemid item ID param: string $pathbase path base param: int $userid user ID param: file_progress $progress Progress indicator callback or null if not required |
add_storedfile_to_archive(stored_file $file, file_archive $filearch, $archivepath) X-Ref |
Add file/directory into archive. return: bool success param: stored_file $file The file to archive param: file_archive $filearch file archive instance param: string $archivepath pathname in archive |
add_to_curl_request(stored_file $file, &$curlrequest, $key) X-Ref |
Adds this file path to a curl request (POST only). return: void param: stored_file $file The file to add to the curl request param: curl $curlrequest The curl request object param: string $key What key to use in the POST request |
get_imageinfo(stored_file $file) X-Ref |
Returns information about image. Information is determined from the file content return: mixed array with width, height and mimetype; false if not an image param: stored_file $file The file to inspect |
is_image_from_storedfile(stored_file $file) X-Ref |
Attempt to determine whether the specified file is likely to be an image. Since this relies upon the mimetype stored in the files table, there may be times when this information is not 100% accurate. return: bool param: stored_file $file The file to check |
get_imageinfo_from_path($path) X-Ref |
Returns image information relating to the specified path or URL. return: array|bool array that containing width, height, and mimetype or false if cannot get the image info. param: string $path The full path of the image file. |
xsendfile_file(stored_file $file) X-Ref |
Serve file content using X-Sendfile header. Please make sure that all headers are already sent and the all access control checks passed. This alternate method to xsendfile() allows an alternate file system to use the full file metadata and avoid extra lookups. return: bool success param: stored_file $file The file to send |
xsendfile($contenthash) X-Ref |
Serve file content using X-Sendfile header. Please make sure that all headers are already sent and the all access control checks passed. return: bool success param: string $contenthash The content hash of the file to be served |
supports_xsendfile() X-Ref |
Returns true if filesystem is configured to support xsendfile. return: bool |
validate_hash_and_file_size($contenthash, $pathname) X-Ref |
Validate that the content hash matches the content hash of the file on disk. return: array The content hash (it might change) and file size param: string $contenthash The current content hash to validate param: string $pathname The path to the file on disk |
get_content_file_handle(stored_file $file, $type = stored_file::FILE_HANDLE_FOPEN) X-Ref |
Returns file handle - read only mode, no writing allowed into pool files! When you want to modify a file, create a new file and delete the old one. return: resource file handle param: stored_file $file The file to retrieve a handle for param: int $type Type of file handle (FILE_HANDLE_xx constant) |
get_file_handle_for_path($path, $type = stored_file::FILE_HANDLE_FOPEN) X-Ref |
Return a file handle for the specified path. This abstraction should be used when overriding get_content_file_handle in a new file system. return: resource param: string $path The path to the file. This shoudl be any type of path that fopen and gzopen accept. param: int $type Type of file handle (FILE_HANDLE_xx constant) |
mimetype_from_hash($contenthash, $filename) X-Ref |
Retrieve the mime information for the specified stored file. return: string The MIME type. param: string $contenthash param: string $filename |
mimetype_from_storedfile($file) X-Ref |
Retrieve the mime information for the specified stored file. return: string The MIME type. param: stored_file $file The stored file to retrieve mime information for |
cron() X-Ref |
Run any periodic tasks which must be performed. |