function directoryPath(&$directory) {
    if (substr($directory, 0, 1) != '/') {
      // Relative, and so assumed to be in Drupal's files folder: prepend this to
      // the given directory.
      // sanity check. need to verify /files exists before we do anything. see http://drupal.org/node/367138
      $files = file_create_path();
      file_check_directory($files, FILE_CREATE_DIRECTORY);
      $directory = file_create_path($directory);
    }
  }