[pve-devel] [PATCH pve-common] add function file_atomic_copy

Wolfgang Link w.link at proxmox.com
Mon Nov 23 14:35:13 CET 2015


---
 src/PVE/Tools.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 125c307..32d14c4 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -41,6 +41,7 @@ template_replace
 safe_print
 trim
 extract_param
+file_atomic_copy
 );
 
 my $pvelogdir = "/var/log/pve";
@@ -220,6 +221,12 @@ sub file_get_contents {
     return $content;
 }
 
+sub file_atomic_copy {
+    my ($filename, $dst, $max, $perm) = @_;
+
+    file_set_contents ($dst, file_get_contents($filename, $max), $perm);
+}
+
 sub file_read_firstline {
     my ($filename) = @_;
 
-- 
2.1.4





More information about the pve-devel mailing list