How to prepare directories in private file system? I've configured private file system. Using it from UI works well.
I want to generate dump site content via devel_generate with custom modifications. So I'm hooking into Node API for assigning sample PDF files to nodes.

Inside private directory I want to create directory structure:

  $dir = sprintf('private://org%d/%d/person%d', $this-&gt;getOrganization()-&gt;nid,
                    date('Y'), $this-&gt;getEmployee()-&gt;uid);

  if (!file_prepare_directory($dir)) {
    throw new Exception('Cannot create document file directory or it\'s not writable');
  }


But exception is thrown.

How to set proper directory permissions? Content is generated  via drush command - drush genc.
Ok, I solved it by passing proper flag (for UI):

file_prepare_directory($dir, FILE_CREATE_DIRECTORY);


For using drush command still don't know and failing.