Generate scaled versions of a specific source file, along all configured templates.

@param string $filename Filename of the source file in need of scaling
@param bool $overwrite
@return bool
352937
protected function _generateScaledImagesForFilename($filename, $overwrite = false) {
        Garp_Cli::lineOut('Generating scaled images for file "' . $filename . '".');

        if (!$filename) {
            return;
        }

        $scaler     = new Garp_Image_Scaler();
        $templates  = $scaler->getTemplateNames();
        $imageModel = new Model_Image();
        $select     = $imageModel->getAdapter()->quoteInto('filename = ?', $filename);
        $record     = $imageModel->fetchRow($select);
        $file       = new Garp_Image_File();
        $success    = 0;

        if (!$record) {
            Garp_Cli::errorOut(
                'I couldn\'t find any records in the database, containing "' .
                $filename . '" as filename'
            );
            return;
        }

        foreach ($templates as $template) {
            $success += (int)$this->_scaleDatabaseImage(
                $record, $file, $scaler, $template, $overwrite
            );
        }

        return $success == count($templates);
    }
207327
public static function create(string $path, string $content = '', bool $overwrite = true): self
    {
        $path = normalize_path($path);

        if (is_file($path) && $overwrite) {
            self::unlink($path);
        }
        if (!is_file($path)) {
            if (is_writeable(dirname($path))) {
                if ($handle = fopen($path, 'w')) {
                    fwrite($handle, $content);
                    fclose($handle);

                    return new static($path);
                }
                throw new FileException('Creating file ('.$path.') failed');
            }
            throw new FileException('Cannot create file, because the directory ('.dirname($path).') is not accessible',
                FileException::NOT_WRITEABLE);
        }
        throw new FileException('Cannot create file, because the file path ('.$path.') already exist', FileException::ALREADY_EXIST);
    }
41107
protected function _generateScaledImagesForId($id, $overwrite = false) {
        if (!$id) {
            return;
        }

        $imageModel = new Model_Image();
        $record     = $imageModel->fetchById($id);
        return $this->_generateScaledImagesForFilename($record->filename);
    }
938701
private function loadFromFile($filename, $overwrite = false)
    {
        try {
            $yamlDatas = Yaml::parse(file_get_contents($filename));

            if (is_array($yamlDatas)) {
                if (true === $this->debug) {
                    $this->debug_data[$filename] = $yamlDatas;
                }

                if (self::CONFIG_FILE.'.'.self::EXTENSION === basename($filename) ||
                    self::CONFIG_FILE.'.'.$this->environment.'.'.self::EXTENSION === basename($filename)) {
                    foreach ($yamlDatas as $component => $config) {
                        if (!is_array($config)) {
                            $this->container->get('logger')->error('Bad configuration, array expected, given : '.$config);
                        }
                        $this->setSection($component, $config, $overwrite);
                    }
                } else {
                    $this->setSection(basename($filename, '.'.self::EXTENSION), $yamlDatas, $overwrite);
                }
            }
        } catch (ParseException $e) {
            throw new InvalidConfigException($e->getMessage(), null, $e, $e->getParsedFile(), $e->getParsedLine());
        }
    }
756838
public function copy($dest, $overwrite = true)
    {
        if (!$this->exists() || is_file($dest) && !$overwrite) {
            return false;
        }

        return copy($this->path, $dest);
    }
332270
public function saveAs($overwrite = [])
    {
        $data = $this->data();
        $data['id'] = null;
        $data = array_merge($data, $overwrite);

        return $this->create($data, $this->getEntity());
    }
308703
public static function moveFile($fileUrl, $aimUrl, $overWrite = false) {
		if (!is_file($fileUrl)) {
			return false;
		}
		if (is_file($aimUrl) && $overWrite = false) {
			return false;
		} elseif (is_file($aimUrl) && $overWrite = true) {
			self::unlinkFile($aimUrl);
		}
		$aimDir = dirname($aimUrl);
		self::createDir($aimDir);
		rename($fileUrl, $aimUrl);
		return true;
	}
51247
public static function rename($origin, $target, $overwrite = false)
    {
        self::ensureFileSystem()->rename($origin, $target, $overwrite);
    }
143110
public function rename($filename)
    {
        if ($this->exists() && !@rename($this->filename, $filename)) {
            return false;
        }

        unset(static::$instances[$this->filename]);
        static::$instances[$filename] = $this;

        $this->filename = $filename;

        return true;
    }
430471
public function copy($source, $overrides = [])
    {
        $this->sourceId = $source;
        return $this->sync($overrides) ? $this : null;
    }
1024403
public static function copyDirectory($oldDir, $aimDir, $overWrite = false) {
		$aimDir = str_replace('', '/', $aimDir);
		$aimDir = substr($aimDir, -1) == '/' ? $aimDir : $aimDir . '/';
		$oldDir = str_replace('', '/', $oldDir);
		$oldDir = substr($oldDir, -1) == '/' ? $oldDir : $oldDir . '/';
		if (!is_dir($oldDir)) {
			return false;
		}
		if (!is_dir($aimDir)) {
			self::createDir($aimDir);
		}
		$dirHandle = opendir($oldDir);
		while (false !== ($file = readdir($dirHandle))) {
			if ($file == '.' || $file == '..') {
				continue;
			}
			if (!is_dir($oldDir . $file)) {
				self::copyFile($oldDir . $file, $aimDir . $file, $overWrite);
			} else {
				self:: copyDir($oldDir . $file, $aimDir . $file, $overWrite);
			}
		}
		return closedir($dirHandle);
	}
1107598
static function write($filename, $contents, $overwriteExisting = true) {
        if (file_exists($filename) && self::isWritable($filename)) {
            if ($overwriteExisting) unlink($filename);
        }

        file_put_contents($filename, $contents);
    }
311792
public static function putContents(string $filename, $data, bool $override = false)
    {
        $dirname = dirname($filename);
        if (!file_exists($dirname)) {
            mkdir($dirname, 0700, true);
        }
        if (!file_exists($filename) || $override) {
            $result = file_put_contents($filename, $data);
        } else {
            throw new \Exception("{$filename} is already exists");
        }
        return $result;
    }
560789
public function blendFromSeed($seed_key, $overwrite = false)
    {
        $this->loadObjectDataFromSeed($seed_key);
        return $this->blend($overwrite);
    }
428661
public function createGroup($name, $overwrite = false)
    {
        if (isset($this->groups[$name])) {
            return $this->groups[$name];
        }

        $assets = $this->createAssetArray($name);
        $filters = $this->createFilterArray($name);
        $coll = new AssetCollection($assets, $filters);

        if ($output = $this->getConfig($name, 'output')) {
            $coll->setTargetPath($output);
        }

        // check output cache
        $write_output = true;
        if (!$overwrite) {
            if (file_exists($output = public_path($coll->getTargetPath()))) {
                $output_mtime = filemtime($output);
                $asset_mtime = $coll->getLastModified();

                if ($asset_mtime && $output_mtime >= $asset_mtime) {
                    $write_output = false;
                }
            }
        }

        // store assets
        if ($overwrite || $write_output) {
            $writer = new AssetWriter(public_path());
            $writer->writeAsset($coll);
        }

        return $this->groups[$name] = $coll;
    }
1367234
public function copy(string $target, string $source, bool $override = false)
    {
        if (is_null($this->get($target)) || $override) {
            $this->set($target, $this->get($source));
        }
        return $this;
    }
1364858
public function move(Filesystem $filesystem = null, $targetFilename = null, $overwrite = true)
    {
        // source file
        $sourceFile = $this->getTransport()->getFile();
        
        // target base name
        $targetBasename = $this->buildTargetBasename($sourceFile, $targetFilename);

        // move file to target storage
        $content = stream_get_contents($sourceFile->getStream());

        // write file
        $filesystem->write(
            $targetBasename,
            $content,
            $overwrite
        );

        return $filesystem->get($targetBasename);
    }