I'm thinking about changing the way Drupal stores it's files. I'm weary of having all the uploads in one directory (or about 4 directories in my case with the additions of image, video, and userphotos). I'm envisioning a more postfix mail queue style structure, with nested folders like 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and inside each of those folders is another set of 0-9 folders. That would allow I think for better disk performance when the number of files gets large and allow for some different partitioning options down the road too.

It looks to me like the function file_create_filename in file.inc could be easily edited to look something like the one below to handle my idea. I'm thinking it's not a good idea to edit file.inc though. Is there a way to override that function? Am I missing something obvious? Am I over thinking all of this? Thanks for any feedback.

function file_create_filename($basename, $directory) {
  $rand1 = rand(0,9);
  $rand2 = rand(0,9);

  $dest = $directory .'/'. $rand1. '/'. $rand2 .'/'. $basename;

  if (file_exists($dest)) {
    // Destination file already exists, generate an alternative.
    if ($pos = strrpos($basename, '.')) {
      $name = substr($basename, 0, $pos);
      $ext = substr($basename, $pos);
    }
    else {
      $name = $basename;
    }

    $counter = 0;
    do {
      $dest = $directory .'/'. $name .'_'. $counter++ . $ext;
    } while (file_exists($dest));
  }

  return $dest;
}