Beispiel #1
0
 /**
  * Attempt to create the file or path, if it does not exist.
  * Not guaranteed to succeed. Test with {@link exists()} to determine
  * if it succeeded. Works just like {@link ensure_path_exists()} if the
  * URL does not include a file name.
  * @param boolean $normalize_allowed If True, illegal file ids are converted before attempting creation.
  */
 public function ensure_file_exists($normalize_allowed = true)
 {
     if (!is_file($this->_text)) {
         $opts = $this->options();
         $this->ensure_path_exists($normalize_allowed);
         if (is_file_name($this->_text, $opts)) {
             fopen($this->_text, 'w+');
             chmod($this->_text, $opts->default_access_mode);
         }
     }
 }
 /**
  * Adds the default registered extension if necessary.
  * Adds an extension to 'fragment' if it does not end in a delimiter, does not already
  * have an extension and there is a default extension registered for 'alias'.
  * @param string $alias
  * @param string $fragment
  * @return string
  * @access private
  */
 protected function _apply_extension_for_alias($alias, $fragment)
 {
     if (!ends_with_delimiter($fragment, $this->_url_options) && !is_file_name($fragment, $this->_url_options)) {
         $ext = $this->extension_for_alias($alias);
         if ($ext) {
             $fragment .= '.' . $ext;
         }
     }
     return $fragment;
 }