mirror of
https://github.com/unraid/webgui.git
synced 2026-02-26 12:18:56 -06:00
Update Wrappers.php
This commit is contained in:
@@ -22,6 +22,25 @@ $_proxy_ = '__';
|
||||
$_arrow_ = '»';
|
||||
|
||||
// Wrapper functions
|
||||
function file_put_contents_atomic($filename,$data, $flags = 0, $context = null) {
|
||||
while (true) {
|
||||
$suffix = rand();
|
||||
if ( ! is_file("$filename$suffix") )
|
||||
break;
|
||||
}
|
||||
$renResult = false;
|
||||
$copyResult = @copy($filename,"$filename$suffix");
|
||||
if ( $copyResult ) {
|
||||
if (file_put_contents("$filename$suffix",$data,$flags,$context) === strlen($data))
|
||||
$renResult = @rename("$filename$suffix",$filename);
|
||||
}
|
||||
if ( (! $copyResult || ! $renResult) ) {
|
||||
my_logger("File_put_contents_atomic failed to write / rename $filename");
|
||||
@unlink("$filename$suffix");
|
||||
return false;
|
||||
}
|
||||
return strlen($data);
|
||||
}
|
||||
function parse_plugin_cfg($plugin, $sections=false, $scanner=INI_SCANNER_NORMAL) {
|
||||
global $docroot;
|
||||
$ram = "$docroot/plugins/$plugin/default.cfg";
|
||||
|
||||
Reference in New Issue
Block a user