file_prepare_directory似乎没有创建目录

I am running this code, and not getting any errors, but the directory is not being created:

  $publicsys = 'public://sys';
  file_prepare_directory($publicsys, FILE_CREATE_DIRECTORY);

This is in Drupal - is there something wrong with my syntax?

Another solution (for Drupal 7)

You can solve this issue by defining your own Stream Wrapper.

/**
 * Implements hook_stream_wrappers().
 */
function MYMODULE_stream_wrappers() {
  return array(
    'syspublic' => array(
      'name' => t("Default distribution files"),
      'class' => 'SysPublicStreamWrapper',
      'description' => t("Visible, readable and writeable local path"),
      'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
    ),
  );
}

/**
 * Default sys (syspublic://) stream wrapper class.
 */
class SysPublicStreamWrapper extends DrupalPublicStreamWrapper {
  public function getDirectoryPath() {
    return 'sites/default/files/sys';
  }
}

Via: Writing Stream Wrappers