1 file_example.module file_example_delete_directory_submit($form, &$form_state)

Submit handler for directory deletion.

See also

file_unmanaged_delete_recursive()

Related topics

File

modules/examples/file_example/file_example.module, line 448
Examples demonstrating the backdrop File API (and Stream Wrappers).

Code

function file_example_delete_directory_submit($form, &$form_state) {
  $directory = $form_state['values']['directory_name'];

  $result = file_unmanaged_delete_recursive($directory);
  if (!$result) {
    backdrop_set_message(t('Failed to delete %directory.', array('%directory' => $directory)), 'error');
  }
  else {
    backdrop_set_message(t('Recursively deleted directory %directory.', array('%directory' => $directory)));
    $_SESSION['file_example_default_directory'] = $directory;
  }
}