hook_file_references
- Versions
- 7
hook_file_references($file)
Report the number of times a file is referenced by a module.
This hook is called to determine if a files is in use. Multiple modules may be referencing the same file and to prevent one from deleting a file used by another this hook is called.
See also
@see upload_file_references()
Parameters
$file The file object being checked for references.
Return value
If the module uses this file return an array with the module name as the key and the value the number of times the file is used.
Related topics
Code
modules/system/system.api.php, line 1505
<?php
function hook_file_references($file) {
// If upload.module is still using a file, do not let other modules delete it.
$file_used = (bool) db_query_range('SELECT 1 FROM {upload} WHERE fid = :fid', 0, 1, array(':fid' => $file->fid))->fetchField();
if ($file_used) {
// Return the name of the module and how many references it has to the file.
return array('upload' => $count);
}
}
?>Login or register to post comments 