Backdrop now has a consistent way of performing all CRUD functions for entities, as well as accessing entity properties such as label, revision, id, etc.
This applies to:
Create a File entity:
$url = 'path/to/file.file_extension'; // Can be a stream wrapper, such as 'Public://myfile.txt'
$file = entity_create('file', array(
'fid' => NULL,
'uid' => 1,
'filename' => 'newfile.file',
'uri' => $url,
'filemime' => 'text/plain',
'filesize' => filesize($url),
'status' => 1,
'timestamp' => REQUEST_TIME,
Files entities are currently owned by System module. After completing this conversion, it's likely we will follow D8's suit here and move the
hook_entity_info() for files into File module after this conversion.
Drupal.org issue: https://drupal.org/node/1361226