-/**
- * detects if a given filename is present in a directory and find an alternate filename
- * @param $name the initial filename
- * @param $dir the directory to explore (finishing with a '/')
- * @returns an alternate filename, possibly the initial filename
- */
-function jirafeau_detect_collision($name, $dir) {
-  if(!file_exists($dir . $name)) {
-    return $name;
-  }
-
-  $dot = strpos($name, '.');
-  $dot = ($dot === false) ? strlen($name) : $dot;
-  $first = substr($name, 0, $dot);
-  $second = substr($name, $dot);
-  $i = 1;
-  do {
-    $new_name = $first . '-' . $i . $second;
-    $i++;
-  } while(file_exists($dir . $new_name));
-
-  return $new_name;
-}
-