summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/ivymon31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/ivymon b/src/ivymon
index b94444d..1e32d3a 100755
--- a/src/ivymon
+++ b/src/ivymon
@@ -1357,7 +1357,10 @@ sub loadfile {
);
return unless $file;
# open file
- open(IN, "$file") or $mw->Tk::Error("$!\n");
+ unless (open(IN, "$file")) {
+ $mw->Tk::Error("$!\n");
+ return;
+ }
my %client;
my $step = 0;
my $line = 0;
@@ -1405,21 +1408,31 @@ sub savefile {
['All Files', '*']],
);
return unless $file;
+ my $status = 0;
# open file
- open(OUT, ">$file") or $mw->Tk::Error("$!\n");
-
+ unless (open(OUT, ">$file")) {
+ $mw->Tk::Error("$!\n");
+ return;
+ }
# save connected applications name
my @clients = $clientsListbox->get(0, 'end');
- print OUT "applications=", join(',', @clients),"\n" or $mw->Tk::Error("$!\n");
+ unless (print OUT "applications=", join(',', @clients),"\n") {
+ $mw->Tk::Error("$!\n");
+ close(OUT);
+ return;
+ }
-
my $nblines = $messagesText->index("end");
$nblines =~ s/\.\d+$//;
$nblines--;
$progressbar->configure(-to => $nblines);
my $step = int($nblines/10);
#print "step=$step\n";
- print OUT "messages_number=$nblines\n" or $mw->Tk::Error("$!\n");
+ unless (print OUT "messages_number=$nblines\n") {
+ $mw->Tk::Error("$!\n");
+ close(OUT);
+ return;
+ }
# save messages 100 by 100, in order to reduce memory usage
my $index = "1.0";
my $counter = 0;
@@ -1431,7 +1444,11 @@ sub savefile {
$progressbar->update;
last;
}
- print OUT $messages or $mw->Tk::Error("$!\n");
+ unless (print OUT $messages) {
+ $mw->Tk::Error("$!\n");
+ close(OUT);
+ return;
+ }
$progressbar->value($counter);
$counter += 100;
$progressbar->update if ($step == 0 or $counter % $step == 0);