You are here

function file_check_path in Drupal 6

Same name and namespace in other branches
  1. 4 includes/file.inc \file_check_path()
  2. 5 includes/file.inc \file_check_path()

Checks path to see if it is a directory, or a dir/file.

Parameters

$path A string containing a file path. This will be set to the: directory's path.

Return value

If the directory is not in a Drupal writable directory, FALSE is returned. Otherwise, the base name of the path is returned.

Related topics

2 calls to file_check_path()
file_copy in includes/file.inc
Copies a file to a new location.
file_save_upload in includes/file.inc
Saves a file upload to a new location.

File

includes/file.inc, line 222
API for handling file uploads and server file management.

Code

function file_check_path(&$path) {

  // Check if path is a directory.
  if (file_check_directory($path)) {
    return '';
  }

  // Check if path is a possible dir/file.
  $filename = basename($path);
  $path = dirname($path);
  if (file_check_directory($path)) {
    return $filename;
  }
  return FALSE;
}