function _pdfpreview_prepare_filesystem in PDFPreview 7
Same name and namespace in other branches
- 6 pdfpreview.module \_pdfpreview_prepare_filesystem()
- 7.2 pdfpreview.module \_pdfpreview_prepare_filesystem()
Prepare the file system for PDF preview image creation
This function is called after the module's setting form is submitted. It checks whether the target directory for preview images exists. If this is not the case, the directory will be created.
See also
1 string reference to '_pdfpreview_prepare_filesystem'
- _pdfpreview_admin_settings in ./
pdfpreview.module - Creates the module settings render array
File
- ./
pdfpreview.module, line 232 - This file contains hooks for the pdfpreview module
Code
function _pdfpreview_prepare_filesystem($form, &$form_state) {
$output_uri = file_default_scheme() . '://' . $form['pdfpreview_pathtoimages']['#value'];
$output_dir = drupal_realpath($output_uri);
if (!file_exists($output_dir)) {
if (!mkdir($output_dir)) {
drupal_set_message(t('Error creating directory @dir', array(
'%dir' => $output_dir,
)), 'error');
watchdog('pdfpreview', 'Error creating directory @dir', array(
'%dir' => $output_dir,
), WATCHDOG_ERROR);
}
$message = t('The directory %dir has been created', array(
'%dir' => $output_dir,
));
watchdog('pdfpreview', 'The directory %dir has been created', array(
'%dir' => $output_dir,
));
drupal_set_message($message, 'status');
}
elseif (!is_dir($output_dir)) {
$message = t('The path %dir is not a directory', array(
'%dir' => $output_dir,
));
watchdog('pdfpreview', 'The path %dir is not a directory', array(
'%dir' => $output_dir,
), WATCHDOG_ERROR);
drupal_set_message($message, 'error');
}
}