summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2006-09-16 20:29:55 +0200
committerAndreas Gohr <andi@splitbrain.org>2006-09-16 20:29:55 +0200
commit40a0d685d578c360d245e98c8ca217953b8b765a (patch)
tree107f093d7dc04b6d8fffb9521bf1bbd450f6411d
parent7bff22c03d8d769cfed475f6e253c72b43f9b131 (diff)
downloadrpg-40a0d685d578c360d245e98c8ca217953b8b765a.tar.gz
rpg-40a0d685d578c360d245e98c8ca217953b8b765a.tar.bz2
better getVersion when working on a darcs tree
getVersion tries to find the date of the latest applied patch from _darcs/inventory - this patch makes it only read the last 2000 byte of the file instead of loading the whole file. darcs-hash:20060916182955-7ad00-5a38de1ae4f1a206a8f62cc88551d4f0bc35340e.gz
-rw-r--r--inc/common.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/inc/common.php b/inc/common.php
index 5372a17d7..016c7922d 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -979,9 +979,14 @@ function getVersion(){
//official release
return 'Release '.trim(io_readfile(DOKU_INC.'/VERSION'));
}elseif(is_dir('_darcs')){
- //darcs checkout
- $inv = file('_darcs/inventory');
- $inv = preg_grep('#\*\*\d{14}[\]$]#',$inv);
+ //darcs checkout - read last 2000 bytes of inventory
+ $sz = filesize('_darcs/inventory');
+ $seek = max(0,$sz-2000);
+ $fh = fopen('_darcs/inventory','rb');
+ fseek($fh,$seek);
+ $chunk = fread($fh,2000);
+ fclose($fh);
+ $inv = preg_grep('#\*\*\d{14}[\]$]#',explode("\n",$chunk));
$cur = array_pop($inv);
preg_match('#\*\*(\d{4})(\d{2})(\d{2})#',$cur,$matches);
return 'Darcs '.$matches[1].'-'.$matches[2].'-'.$matches[3];