You are here

function webfm_mkdir in Web File Manager 5.2

Same name and namespace in other branches
  1. 5 webfm_file.inc \webfm_mkdir()

webfm_mkdir -called from the ajax action - switch case 'mkdir':

@ret bool -true if the directory is created with 775 permissions

Parameters

string $source - the source directory path:

string $dest - the destination directory name:

1 call to webfm_mkdir()
webfm_ajax in ./webfm.module
Ajax post requests

File

./webfm_file.inc, line 11

Code

function webfm_mkdir($source, $dest, $rename = FALSE, &$error) {
  $mkdir_path = $source . '/' . $dest;
  if (!is_dir($mkdir_path)) {
    if (@mkdir($mkdir_path)) {
      chmod($mkdir_path, 0775);
      if (!is_writable($mkdir_path)) {
        $error = 'The directory ' . $mkdir_path . ' is not writable';
      }
      else {
        return TRUE;
      }
    }
  }
  else {
    if ($rename == TRUE) {
      $count = 0;
      while (is_dir($munge_path = $mkdir_path . '_' . $count)) {
        $count++;
      }
      if (@mkdir($munge_path)) {
        chmod($munge_path, 0775);
        if (!is_writable($munge_path)) {
          $error = 'The directory ' . $munge_path . ' is not writable';
        }
        else {
          return TRUE;
        }
      }
      else {
        $error = 'mkdir for ' . $munge_path . ' failed';
      }
    }
    else {
      $error = 'The directory ' . $mkdir_path . ' already exists';
    }
  }
  return FALSE;
}