You are here

public function FeedsWebTestCase::copyDir in Feeds 7.2

Copies a directory.

Parameters

string $source: The path of the source directory, from which files should be copied.

string $dest: The path of the destination directory, where files should be copied to.

array $mapping: (optional) The files to rename in the process. To skip files from being copied, map filename to FALSE.

9 calls to FeedsWebTestCase::copyDir()
FeedsFileFetcherTestCase::testPrivateFiles in tests/feeds_fetcher_file.test
Test uploading private files.
FeedsFileFetcherTestCase::testPublicFiles in tests/feeds_fetcher_file.test
Test scheduling on cron.
FeedsMapperFileTestCase::test in tests/feeds_mapper_file.test
Basic test loading a single entry CSV file.
FeedsMapperFileTestCase::testFileExistsRename in tests/feeds_mapper_file.test
Test mapping of local resources with the file exists "Rename" setting.
FeedsMapperFileTestCase::testFileExistsRenameIfDifferent in tests/feeds_mapper_file.test
Test mapping of local resources with the file exists "Rename if different" setting.

... See full list

File

tests/feeds.test, line 699
Common functionality for all Feeds tests.

Class

FeedsWebTestCase
Test basic Data API functionality.

Code

public function copyDir($source, $dest, array $mapping = array()) {
  $result = file_prepare_directory($dest, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  foreach (@scandir($source) as $file) {
    if (is_file("{$source}/{$file}")) {
      $new_name = isset($mapping[$file]) ? $mapping[$file] : $file;
      if ($new_name !== FALSE) {
        $file = file_unmanaged_copy("{$source}/{$file}", "{$dest}/{$new_name}");
      }
    }
  }
}