You are here

function imce_check_directory in IMCE 6

Same name and namespace in other branches
  1. 6.2 inc/imce.page.inc \imce_check_directory()
  2. 7 inc/imce.page.inc \imce_check_directory()

Create a writable directory(any level) under file system directory.

1 call to imce_check_directory()
imce_working_directory in inc/page.inc
Return an avaliable directory for the profile.

File

inc/page.inc, line 787

Code

function imce_check_directory($dirname) {
  $root = file_directory_path();
  $dirpath = $root . '/' . $dirname;
  if (!file_check_directory($dirpath)) {

    //directory does not exist. try to create it.
    $path = $root;
    foreach (explode('/', $dirname) as $arg) {
      $path .= '/' . $arg;
      if (!file_check_location($path, $root) || !file_check_directory($path, FILE_CREATE_DIRECTORY)) {
        return imce_inaccessible_directory($dirname);
      }
    }
  }
  else {
    if (!file_check_location($dirpath, $root)) {

      //directory exists outside of root.
      return imce_inaccessible_directory($dirname);
    }
  }
  return TRUE;
}