chiark / gitweb /
nailing-cargo: Provide stat_exists
[nailing-cargo.git] / nailing-cargo
index fa16da5da1811a3a1f86455fc899b2537e1a2208..4a8daf99ccd16f63a37967861c9d343f83ea2b67 100755 (executable)
@@ -99,6 +99,13 @@ sub read_or_enoent ($) {
   $r;
 }
 
+sub stat_exists ($$) {
+  my ($fn, $what) = @_;
+  if (stat $fn) { return 1; }
+  $!==ENOENT or die "$self: stat $what: $fn: $!\n";
+  return 0;
+}
+
 sub toml_or_enoent ($$) {
   my ($f,$what) = @_;
   my $toml = read_or_enoent($f) // return;