OSDN Git Service
(root)
/
pukiwiki
/
pukiwiki.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
31c021c
)
file_head() with non-lock option
author
henoheno
<henoheno>
Tue, 11 Apr 2006 14:31:37 +0000
(23:31 +0900)
committer
henoheno
<henoheno>
Tue, 11 Apr 2006 14:31:37 +0000
(23:31 +0900)
lib/file.php
patch
|
blob
|
history
diff --git
a/lib/file.php
b/lib/file.php
index
18f48c2
..
4c42b3c
100644
(file)
--- a/
lib/file.php
+++ b/
lib/file.php
@@
-1,6
+1,6
@@
<?php
// PukiWiki - Yet another WikiWikiWeb clone.
<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: file.php,v 1.5
7 2006/04/11 14:26:03
henoheno Exp $
+// $Id: file.php,v 1.5
8 2006/04/11 14:31:37
henoheno Exp $
// Copyright (C)
// 2002-2006 PukiWiki Developers Team
// 2001-2002 Originally written by yu-ji
// Copyright (C)
// 2002-2006 PukiWiki Developers Team
// 2001-2002 Originally written by yu-ji
@@
-152,22
+152,21
@@
function generate_fixed_heading_anchor_id($seed)
// (Use PHP file() function if you want to get ALL lines)
function file_head($file, $count = 1, $lock = TRUE, $buffer = 8192)
{
// (Use PHP file() function if you want to get ALL lines)
function file_head($file, $count = 1, $lock = TRUE, $buffer = 8192)
{
- $index = 0;
- $array = array();
+ $array = array();
$fp = @fopen($file, 'r');
if ($fp === FALSE) return FALSE;
set_file_buffer($fp, 0);
$fp = @fopen($file, 'r');
if ($fp === FALSE) return FALSE;
set_file_buffer($fp, 0);
-
if ($lock) flock($fp, LOCK_SH);
if ($lock) flock($fp, LOCK_SH);
+ rewind($fp);
+ $index = 0;
while (! feof($fp)) {
$line = fgets($fp, $buffer);
if ($line != FALSE) $array[] = $line;
if (++$index >= $count) break;
}
if ($lock) flock($fp, LOCK_UN);
while (! feof($fp)) {
$line = fgets($fp, $buffer);
if ($line != FALSE) $array[] = $line;
if (++$index >= $count) break;
}
if ($lock) flock($fp, LOCK_UN);
-
- if(! fclose($fp)) return FALSE;
+ if (! fclose($fp)) return FALSE;
return $array;
}
return $array;
}