You are here

function file_destination in Coder 7.2

Same name and namespace in other branches
  1. 5.2 scripts/coder_format/coder_format.php \file_destination()
  2. 6.2 scripts/coder_format/coder_format.php \file_destination()
  3. 6 scripts/coder_format/coder_format.php \file_destination()
  4. 7 scripts/coder_format/coder_format.php \file_destination()

Determines the destination path for a file depending on how replacement of existing files should be handled.

Parameters

$destination A string specifying the desired path.:

$replace Replace behavior when the destination file already exists.:

Return value

The destination file path or FALSE if the file already exists and FILE_EXISTS_ERROR was specified.

1 call to file_destination()
file_copy in scripts/coder_format/coder_format.php
Copies a file to a new location. This is a powerful function that in many ways performs like an advanced version of copy().

File

scripts/coder_format/coder_format.php, line 227
Coder format shell invocation script.

Code

function file_destination($destination, $replace) {
  if (file_exists($destination)) {
    switch ($replace) {
      case FILE_EXISTS_RENAME:
        $basename = basename($destination);
        $directory = dirname($destination);
        $destination = file_create_filename($basename, $directory);
        break;
      case FILE_EXISTS_ERROR:
        drupal_set_message(t('The selected file %file could not be copied, because a file by that name already exists in the destination.', array(
          '%file' => $destination,
        )), 'error');
        return FALSE;
    }
  }
  return $destination;
}