summaryrefslogtreecommitdiffstats
path: root/urpm/sys.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-21 16:10:45 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-21 16:10:45 +0000
commit190ab2c006dd503413775aabd6af940a72df8239 (patch)
treeed9c8e5058cc5b63fb5c99f9e1beb4517de02e80 /urpm/sys.pm
parentc17798ddc4bf5740bbc31fd6d0e281c18f62dd26 (diff)
downloadurpmi-190ab2c006dd503413775aabd6af940a72df8239.tar
urpmi-190ab2c006dd503413775aabd6af940a72df8239.tar.gz
urpmi-190ab2c006dd503413775aabd6af940a72df8239.tar.bz2
urpmi-190ab2c006dd503413775aabd6af940a72df8239.tar.xz
urpmi-190ab2c006dd503413775aabd6af940a72df8239.zip
move open_safe, opendir_safe and syserror to urpm::sys
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__