Join a split file into a whole file. Does the reverse of [File::split].
$count = File::join($file);
integer Core_File::join( string $filename [, string $storage = string(7) "default" ] )
参数列表
参数 类型 描述 默认值 $filename
string
Split filename, without .000 extension $storage
string
Output filename, if different then an the filename string(7) "default"
integer
The number of pieces that were joined.public static function join($filename , $storage = 'default')
{
$info = File::check_and_get_path($filename);
if (File::can_do_run($storage))
{
// Open the file
$file = fopen($filename, 'wb+');
// Read files in 8k blocks
$block_size = 1024 * 8;
// Total number of peices
$pieces = 0;
while (is_file($piece = $filename.'.'.str_pad($pieces + 1, 3, '0', STR_PAD_LEFT)))
{
// Read another piece
$pieces += 1;
// Open the piece for reading
$piece = fopen($piece, 'rb');
while (!feof($piece))
{
// Transfer the data in blocks
fwrite($file, fread($piece, $block_size));
}
// Close the peice
fclose($piece);
}
return $pieces;
}
else
{
return File::call_http_host($storage,'file/join', $info[0], $info[1]);
}
}