public function __construct($filename, $open_mode = 'r', $use_include_path = false)
{
// Check if the given filename was readable.
if (!$this->_resolveFilename($filename, $use_include_path)) {
throw new InvalidArgumentException(var_export($filename, true) . ' is not readable.');
}
// Check if the given open mode was valid.
if (!in_array($open_mode, self::$_availableOpenModes)) {
throw new InvalidArgumentException('Unknown open mode ' . var_export($open_mode, true) . '.');
}
// Store the configuration.
$this->_fileConfig = array('filename' => $filename, 'open_mode' => $open_mode, 'use_include_path' => (bool) $use_include_path, 'delimiter' => ',');
// Try to automatically determine the most optimal settings for this file.
// First we clear the stat cache to have a better prediction.
clearstatcache(false, $filename);
$fsize = filesize($filename);
$malloc = memory_get_usage();
$mlimit = (int) ini_get('memory_limit');
// We have memory to spare. Make use of that.
if ($mlimit < 0 || $mlimit - $malloc > $fsize * 2) {
$this->_garbageCollection = false;
}
// If the file is large, flush empty rows to improve filter speed.
if ($fsize > 1000000.0) {
$this->_flushOnAfterFilter = true;
}
}