Copies original module files to destination folder.
@return bool
@throws ErrorException
341361
private function copy()
    {
        $source = Yii::getAlias($this->source);
        if (!file_exists($source) || !is_dir($source)) {
            throw new ErrorException("Source directory {$this->source} not found");
        }
        $destination = Yii::getAlias($this->destination);
        if (!$this->replace && is_dir($destination)) { // if replace is disabled we will skip existing files
            $this->keepFiles = FileHelper::findFiles($destination);
        }
        FileHelper::copyDirectory($source, $destination, [
            'except' => ['.git/'],
            'fileMode' => 0775,
            'beforeCopy' => function ($from, $to) {
                return $this->replace || !file_exists($to) || !is_file($to);
            }
        ]);
        return true;
    }
1301211
def _copy_module(old):
    """"""
    saved = sys.modules.pop(old.__name__, None)
    new = __import__(old.__name__)
    sys.modules[old.__name__] = saved
    return new
498800
protected function copyDir(array $paths, /*# string */ $destination)
    {
        foreach ($paths as $path) {
            $dest = $this->mergePath($destination, basename($path));
            if (!$this->copy($path, $dest)) {
                return false;
            }
        }
        return true;
    }
1426
public function copyDirectory( string $directory, string $destination, $options = null ): bool
	{
		if( !$this->isDirectory( $directory ) )
		{
			return false;
		}

		$options = $options ?: FilesystemIterator::SKIP_DOTS;

		// If the destination directory does not actually exist, we will go ahead and
		// create it recursively, which just gets the destination prepared to copy
		// the files over. Once we make the directory we'll proceed the copying.
		if( !$this->isDirectory( $destination ) )
		{
			$this->makeDirectory( $destination, 0777, true );
		}

		$items = new FilesystemIterator( $directory, $options );
		foreach( $items as $item )
		{
			// As we spin through items, we will check to see if the current file is actually
			// a directory or a file. When it is actually a directory we will need to call
			// back into this function recursively to keep copying these nested folders.
			$target = $destination . '/' . $item->getBasename();
			if( $item->isDir() )
			{
				$path = $item->getPathname();
				if( !$this->copyDirectory( $path, $target, $options ) )
				{
					return false;
				}
			}

			// If the current items is just a regular file, we will just copy this to the new
			// location and keep looping. If for some reason the copy fails we'll bail out
			// and return false, so the developer is aware that the copy process failed.
			else
			{
				if( !$this->copy( $item->getPathname(), $target ) )
				{
					return false;
				}
			}
		}

		return true;
	}
731378
public function copy($filename, $newFilePath, $newFileName = null, $pathToFile = null)
    {
        if ($pathToFile==null) {
            $pathToFile=$this->_filePath;
        }
        if ($newFileName==null) {
            $newFileName=$filename;
        }
        if (file_exists($pathToFile."/".$filename)) {
            return copy($pathToFile."/".$filename, $newFilePath."/".$newFileName);
        } else {
            return false;
        }
    }
364051
protected function installRuleset()
    {
        if (!file_exists($this->pathRulesetLocal)
            || $this->confirm('Overwrite local configuration with our copy? (y/n) [y]')
        ) {
            $copy = copy($this->pathRulesetStock, $this->pathRulesetLocal);

            return $copy;
        }

        return false;
    }
1084330
protected function copyServicesToShop()
    {
        $fileCopier = new FileCopier();
        $target = $this->getTestConfig()->getRemoteDirectory() . '/Services';
        $fileCopier->copyFiles(TEST_LIBRARY_PATH.'/Services', $target, true);
    }
994359
public function copyDirectory($directory, $destination)
    {
        if (! $this->isDirectory($directory)) {
            return false;
        }

        if (! $this->files->isDirectory($destination)) {
            $this->makeDirectory($destination, 0777, true);
        }

        $items = new FilesystemIterator($directory, FilesystemIterator::SKIP_DOTS);

        foreach ($items as $item) {
            $target = $destination .DS .$item->getBasename();

            if ($item->isDir()) {
                if (! $this->copyDirectory($item->getPathname(), $target)) {
                    return false;
                }

                continue;
            }

            // The current item is a file.
            if ($this->files->exists($target) && ! $this->option('force')) {
                continue;
            } else if (! $this->files->copy($item->getPathname(), $target)) {
                return false;
            }
        }

        return true;
    }
1122383
protected function make()
	{
		if (count($this->templateFiles) > 0)
		{
			foreach ($this->templateFiles as $template)
			{
				if (is_dir($template['path']))
				{
					if (!Filesystem::copyDirectory($template['path'], $template['destination']))
					{
						$this->output->error("Error: an problem occured copying {$template['path']} to {$template['destination']}.");
					}

					// Get folder contents
					$this->scanFolder($template['destination']);
				}
				elseif (is_file($template['path']))
				{
					if (!copy($template['path'], $template['destination']))
					{
						$this->output->error("Error: an problem occured copying {$template['path']} to {$template['destination']}.");
					}

					// Get template contents
					$contents = file_get_contents($template['destination']);
					$contents = $this->doReplacements($contents);

					// Write file
					$this->putContents($template['destination'], $contents);
				}
			}
		}
	}
113161
public function copy() {
    $destination = $this->getConfigValue('repo.root') . '/hooks';
    $this->say("Copying default Acquia cloud hooks into $destination...");
    // This WILL overwrite files is source files are newer.
    $result = $this->taskCopyDir([
      $this->getConfigValue('blt.root') . '/scripts/cloud-hooks/hooks' => $destination,
    ])
      ->run();
    $this->taskFilesystemStack()
      ->chmod($destination, 0755, 0000, TRUE)
      ->run();

    return $result;
  }
160720
public function copyContent(string $newFolderPath): self
    {
        $newFolderPath = normalize_path($newFolderPath);

        if (is_dir($newFolderPath)) {
            if (recursive_copy($this->getPath(), $newFolderPath)) {
                return self::load($newFolderPath);
            }
        }
        throw new FolderException('Cannot copy folder content, because the destination folder path ('.$newFolderPath.') does not exist',
            FolderException::DONT_EXIST);
    }
433314
public function export()
    {
        $path = $this->module->dataPath;
        FileHelper::createDirectory($path, $this->module->dirMode);

        $summary = $this->collectSummary();
        $dataFile = "$path/{$this->tag}.data";
        $data = [];
        $exceptions = [];
        foreach ($this->module->panels as $id => $panel) {
            try {
                $data[$id] = serialize($panel->save());
            } catch (\Exception $exception) {
                $exceptions[$id] = new FlattenException($exception);
            }
        }
        $data['summary'] = $summary;
        $data['exceptions'] = $exceptions;

        file_put_contents($dataFile, serialize($data));
        if ($this->module->fileMode !== null) {
            @chmod($dataFile, $this->module->fileMode);
        }

        $indexFile = "$path/index.data";
        $this->updateIndexFile($indexFile, $summary);
    }
197243
private function copyStubsDirectory()
    {
        $path = $this->option('path');

        // if controller stub already exist
        if ($this->files->exists($path . DIRECTORY_SEPARATOR . 'controller.stub') && $this->option('force') === false) {
            $this->error("Stubs already exists! Run 'generate:publish-stubs --force' to override the stubs.");
            die;
        }

        File::copyDirectory(__DIR__ . '/../../resources/stubs', $path);
    }
937253
public function copy_page() {
        if (!$this->filename) {
            return false;
        }
        if ($this->currentpage>=$this->pagecount) {
            return false;
        }
        $this->currentpage++;
        $this->create_page_from_source($this->currentpage);
        return true;
    }
69727
public function rollback()
    {
        $backupFile = "{$this->filepath}.bkup.1";

        if (!file_exists($backupFile)) {
            throw new \RuntimeException("Backup file ({$backupFile}) does not exists.");
        }
        copy($backupFile, $this->filepath);

        return true;
    }
640207
protected function uploadFile () : bool
	{
		// Determine the destination
		$this->newFileLocation = $this->getUploadDir().$this->uploadFileDir.getConstant('DS', TRUE).$this->newFileName;			  
		// Make sure a file doesn't already exist in the target location
		if (file_exists($this->newFileLocation)):
			$this->error = "The file {$this->newFileLocation} already exists.";
			return FALSE;
		endif;
		// Attempt to move/upload the file 
		if (!move_uploaded_file($this->tempPath, $this->newFileLocation)):
			// File was not moved - failure.
			$this->error = "The file upload failed.";
			return FALSE;
		endif;
		// SUCCESS
		return TRUE;
	}
48476
function copyExampleConfig()
    {
        if (! $this->files->exists($this->configPath)) {
            $this->files->copyAsUser(
                $this->exampleConfigPath,
                $this->configPath
            );
        }
    }