Stores $contents to a temporary location under the file name $target.

@param string $target
@param string $contents
@return string The name of the temp file or false if it failed.
@todo remove or replace with eZ Components functionality
350837
protected function storeUploadedFile( $target, $contents )
    {
        $dir = self::tempDirectory() . '/' . md5( microtime() . '-' . $target );
        $filePath = $dir . '/' . basename( $target );

        if ( !file_exists( $dir ) )
        {
            eZDir::mkdir( $dir, false, true );
        }

        $result = file_put_contents( $filePath, $contents );
        if ( !$result )
        {
            $result = file_exists( $filePath );
        }

        if ( $result )
        {
            return $filePath;
        }
        return false;
    }
85145
public function putContents($contents, $remote)
    {
        $stream = fopen('data://text/plain,' . $contents, 'r');

        return $this->fput($stream, $remote);
    }
1072034
public function copy($source, $target) {
        // using mark.
        if ('@' == $source[0]) $source = $this->as($source);
        if ('@' == $target[0]) $target = $this->as($target);

        // copy file.
        if (is_file($source)) return copy($source, $target);

        // copy directory.
        $handle = opendir($source);
        while (false !== ($name = readdir($handle))) {
            if ('.' == $name or '..' == $name) continue;
            $subsource = $source.self::DS.$name;
            $subtarget = $target.self::DS.$name;
            if (!$this->copy($subsource, $subtarget)) return false;
        }
        closedir($handle);
        return true;
    }
1249673
public function setContents($contents)
    {
        $contents_exist = file_exists($contents);

        if ($contents_exist) {
            $this->contents = file_get_contents($contents);

            $this->updateLog("info", "Page contents set from {$contents}");
        } else {
            $this->contents = false;
            
            $this->updateLog("alert", "File {$contents} not found");
        }

        return $contents_exist;
    }
164867
protected function makeDir($target)
    {
        if (!file_exists(dirname($target))) {
            mkdir(dirname($target), 0777, true);
        }

        return $this;
    }
941381
protected function getResourceContents( $target )
    {
        $result = array( 'data' => false, 'file' => false );
        $fullPath = $target;
        $target = $this->splitFirstPathElement( $fullPath, $currentSite );

        $data = $this->getVirtualFolderData( $result, $currentSite, $target, $fullPath );
        if ( $data['file'] )
        {
            $file = eZClusterFileHandler::instance( $data['file'] );
            //$this->cachedProperties[ $data['file'] ]['size'] = $file->size();
            return $file->fetchContents();
        }

        return false;
    }
1273415
public function setTarget($target)
    {
        if (!is_string($target) || $target == '') {
            throw new \InvalidArgumentException('No valid URL given.');
        }

        $this->target = $target;

        // Set meta refresh content if header location is ignored
        $this->setContent(
            sprintf('<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="0; url=%1$s" />
    </head>
    <body>
        <p>Redirecting to <a href="%1$s">%1$s</a>.
    </body>
</html>', htmlspecialchars($target, ENT_QUOTES, 'UTF-8')));

        // Set header location
        $this->setHeader('Location', $target);

        return $this;
    }
798672
public function copy_content_from_storedfile(stored_file $file, $target) {
        $source = $this->get_local_path_from_storedfile($file, true);
        return copy($source, $target);
    }
665856
public static function put($path, $contents, $lock = false)
    {
        return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
    }
370467
public function putContent($path, $contents, $lock = false)
    {
        return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
    }
1164142
public static function copy(String $source, String $target) : Bool
    {
        return Filesystem::copy(Info::rpath($source), Info::rpath($target));
    }
331191
public static function putContents($filename, $contents)
    {
        $result = file_put_contents($filename, $contents, \LOCK_EX | \LOCK_NB);
        if ($result === false) {
            throw new \RuntimeException("Cannot write the file: " . $filename);
        }
    }
108819
protected static function writeFile($target, $content, $tmp)
    {
        $dir = dirname($target);
        if (!is_dir($dir))
            mkdir($dir, 644, true);
        $file = tempnam($tmp, 'hum');
        if (!($fd = fopen($file, 'w')))
            throw new \RuntimeException("create template tmp file failed:$file!");
        fwrite($fd, $content);
        fclose($fd);
        if (file_exists($target))
            unlink($target);
        $ret = rename($file, $target);
        if ($ret)
            chmod($target, 644);
        else
            throw new \RuntimeException("create template failed:$target!");

        return $ret;
    }
959821
private function copyThenRemove($source, $target)
    {
        if (!is_dir($source)) {
            copy($source, $target);
            $this->unlink($source);

            return;
        }

        $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
        $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
        $this->ensureDirectoryExists($target);

        foreach ($ri as $file) {
            $targetPath = $target.DIRECTORY_SEPARATOR.$ri->getSubPathName();
            if ($file->isDir()) {
                $this->ensureDirectoryExists($targetPath);
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }

        $this->removeDirectoryPhp($source);
    }
36485
public function setContents($key, $contents, $append = false)
    {
        return $this->driver->setContents($key, $contents, $append);
    }
424292
private function mkdir($target)
    {
        if (\is_dir($target)) {
            return;
        }

        if (! $this->file->mkdir($target)) {
            $this->output->writeln("<error>[$target] could not be created. Please check directory permissions.</error>");
        }
    }
1097431
public function copy($source, $target)
    {
        $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
        $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);

        if (!file_exists($target)) {
            mkdir($target, 0777, true);
        }

        foreach ($ri as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
            if ($file->isDir()) {
                if (!file_exists($targetPath)) {
                    mkdir($targetPath);
                }
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }