summaryrefslogtreecommitdiffstats
path: root/urpm/sys.pm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm/sys.pm')
-rw-r--r--urpm/sys.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/urpm/sys.pm b/urpm/sys.pm
index 313cf730..f6d33d78 100644
--- a/urpm/sys.pm
+++ b/urpm/sys.pm
@@ -232,6 +232,25 @@ sub unlock_urpmi_db {
_unlock(\$LOCK_FILE);
}
+sub syserror {
+ my ($urpm, $msg, $info) = @_;
+ $urpm->{error}("$msg [$info] [$!]");
+}
+
+sub open_safe {
+ my ($urpm, $sense, $filename) = @_;
+ open my $f, $sense, $filename
+ or syserror($urpm, $sense eq '>' ? "Can't write file" : "Can't open file", $filename), return undef;
+ return $f;
+}
+
+sub opendir_safe {
+ my ($urpm, $dirname) = @_;
+ opendir my $d, $dirname
+ or syserror($urpm, "Can't open directory", $dirname), return undef;
+ return $d;
+}
+
1;
__END__