[pve-devel] r5014 - pve-common/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Aug 16 13:48:13 CEST 2010


Author: dietmar
Date: 2010-08-16 11:48:13 +0000 (Mon, 16 Aug 2010)
New Revision: 5014

Modified:
   pve-common/trunk/Tools.pm
Log:
add safe_print


Modified: pve-common/trunk/Tools.pm
===================================================================
--- pve-common/trunk/Tools.pm	2010-08-16 11:35:10 UTC (rev 5013)
+++ pve-common/trunk/Tools.pm	2010-08-16 11:48:13 UTC (rev 5014)
@@ -14,6 +14,7 @@
 file_set_contents 
 file_get_contents
 split_list
+safe_print
 );
 
 # flock: we use one file handle per process, so lock file
@@ -316,4 +317,14 @@
     return @data;
 }
 
+sub safe_print {
+    my ($filename, $fh, $data) = @_;
+
+    return if !$data;
+
+    my $res = print $fh $data;
+
+    die "write to '$filename' failed\n" if !$res;
+}
+
 1;




More information about the pve-devel mailing list