private function files($files, $piece_length)
{
sort($files);
usort($files, create_function('$a,$b', 'return strrpos($a,DIRECTORY_SEPARATOR)-strrpos($b,DIRECTORY_SEPARATOR);'));
$first = current($files);
if (!self::is_url($first)) {
$files = array_map('realpath', $files);
} else {
$this->url_list(dirname($first) . DIRECTORY_SEPARATOR);
}
$files_path = array_map('self::path_explode', $files);
$root = call_user_func_array('array_intersect_assoc', $files_path);
$pieces = null;
$info_files = array();
$count = count($files) - 1;
foreach ($files as $i => $file) {
if (!($handle = self::fopen($file, $filesize = self::filesize($file)))) {
self::set_error(new Exception('Failed to open file: "' . $file . '" discarded'));
continue;
}
$pieces .= $this->pieces($handle, $piece_length, $count == $i);
$info_files[] = array('length' => $filesize, 'path' => array_diff_assoc($files_path[$i], $root));
}
return array('files' => $info_files, 'name' => end($root), 'piece length' => $piece_length, 'pieces' => $pieces);
}