10 if (\file_exists($source)) {
11 $str=\file_get_contents($source);
18 if (($str=self::openReplaceInTemplateFile($source, $keyAndValues))) {
19 return \file_put_contents($destination, $str, LOCK_EX);
25 \array_walk($keyAndValues,
function (&$item) {
27 $item=\implode(
"\n", $item);
29 $str=\str_replace(\array_keys($keyAndValues), \array_values($keyAndValues), $content);
34 return \file_put_contents($destination, self::replaceFromTemplate($content, $keyAndValues), LOCK_EX);
37 public static function save($filename,$content,$flags=LOCK_EX){
38 return \file_put_contents($filename, $content, $flags);
41 public static function xcopy($source, $dest, $permissions = 0755){
42 if (\is_link($source)) {
43 return \symlink(\readlink($source), $dest);
45 if (\is_file($source)) {
46 return \copy($source, $dest);
48 if (!\is_dir($dest)) {
49 \mkdir($dest, $permissions,
true);
52 while (
false !== $entry = $dir->read()) {
53 if ($entry ==
'.' || $entry ==
'..') {
56 self::xcopy(
"$source/$entry",
"$dest/$entry", $permissions);
62 public static function xmove(
string $source,
string $dest,
int $permission=0755):bool {
63 if (\is_link($source)) {
64 if( \symlink(\readlink($source), $dest)){
65 return \unlink($source);
69 if(self::xcopy($source, $dest,$permission)){
73 return \unlink($source);
File system utilities Ubiquity\utils\base$UFileSystem This class is part of Ubiquity.
static delTree($dir)
Deletes recursivly a folder and its content.
static xmove(string $source, string $dest, int $permission=0755)
static replaceFromTemplate($content, $keyAndValues)
static openReplaceInTemplateFile($source, $keyAndValues)
static replaceWriteFromContent($content, $destination, $keyAndValues)
static save($filename, $content, $flags=LOCK_EX)
static xcopy($source, $dest, $permissions=0755)
static openReplaceWriteFromTemplateFile($source, $destination, $keyAndValues)