You are here

function file_entity_generate_unique_uri in File Entity (fieldable files) 7.3

Same name and namespace in other branches
  1. 7.2 file_entity.devel_generate.inc \file_entity_generate_unique_uri()
1 call to file_entity_generate_unique_uri()
file_entity_generate_file in ./file_entity.devel_generate.inc
Generate file function for file_entity.

File

./file_entity.devel_generate.inc, line 181
Devel generate integration for the File Entity module.

Code

function file_entity_generate_unique_uri($extension) {
  module_load_include('inc', 'devel_generate');
  do {
    $uri = 'public://devel-generate/' . devel_generate_word(3) . '/' . devel_generate_word(16) . '.' . $extension;
  } while (is_file($uri) || db_query("SELECT 1 FROM {file_managed} WHERE uri = :uri", array(
    ':uri' => $uri,
  ))
    ->fetchField());
  return $uri;
}