chiark / gitweb /
Move stat_exists to Dgit.pm
[dgit.git] / Debian / Dgit.pm
index 211bae3a6626d503b6452864aa5815769ba1c6e9..8b29ba2746be30267b9cef7cf73ff60b3d95e25e 100644 (file)
@@ -12,6 +12,7 @@ BEGIN {
     $VERSION     = 1.00;
     @ISA         = qw(Exporter);
     @EXPORT      = qw(debiantag server_branch server_ref
+                      stat_exists
                       $package_re $branchprefix);
     %EXPORT_TAGS = ( policyflags => qw() );
     @EXPORT_OK   = qw();
@@ -43,4 +44,11 @@ sub debiantag ($) {
 sub server_branch ($) { return "$branchprefix/$_[0]"; }
 sub server_ref ($) { return "refs/".server_branch($_[0]); }
 
+sub stat_exists ($) {
+    my ($f) = @_;
+    return 1 if stat $f;
+    return 0 if $!==&ENOENT;
+    die "stat $f: $!";
+}
+
 1;