From: David Riebenbauer <davrieb@liegesta.at>
Date: Sat, 30 Jan 2010 09:25:10 +0000 (+0100)
Subject: Make srcfile() return undef, if the file isn't there.
X-Git-Tag: 3.20100427~62^2~28^2~13
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/4af4d26582f0c2b915d7102fb4a604b176385748

Make srcfile() return undef, if the file isn't there.

This has the advantage that it's now possible to check for the existence of a
sourcefile with that function.
---

diff --git a/IkiWiki.pm b/IkiWiki.pm
index b8e599928..cb1c46a68 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -743,7 +743,10 @@ sub srcfile_stat {
 }
 
 sub srcfile ($;$) {
-	return (srcfile_stat(@_))[0];
+	if (my @stat=srcfile_stat(@_)) {
+		return $stat[0];
+	}
+	return undef
 }
 
 sub add_underlay ($) {