public static function safeFileAppend($filepath, $str, $opts = array())
	{
		$debug = \bdk\Debug::getInstance();
		$debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__, $filepath);
		$return = false;
		if (substr($str, -1, 1) != "\n") {
			$str .= "\n";
		}
		$opts = array_merge(array(
			'mode'		=> 'a',
			'est_size'	=> strlen($str),
			'lock'		=> false,
			'keep_open'	=> false,	// only applicable when not locking
		), $opts);
		$fh = self::safeFopen($filepath, $opts);
		if ($fh) {
			if (fwrite($fh, $str)) {
				$return = true;
			} else {
				trigger_error('Error writing to '.$filepath, E_USER_ERROR);
			}
			self::safeFclose($fh);
		}
		$debug->groupEnd();
		return $return;
	}