Example #1
0
 /**
  * 当参数overwrite=false时,执行文件重命名,再创建文件
  */
 private function renameFile()
 {
     // overwrite=true,不执行之后操作
     if ($this->overwrite == true) {
         return;
     }
     $children = MFiles::queryChildrenByParentId($this->user_id, $this->parent_file_id);
     if ($children === false) {
         throw new MFilesException(Yii::t('api', MConst::INTERNAL_SERVER_ERROR), MConst::HTTP_CODE_500);
     }
     $names = array();
     foreach ($children as $k => $v) {
         $names[strtolower($v["file_name"])] = $v["file_name"];
     }
     //
     // 执行重命名文件操作
     //
     $this->file_name = MUtils::getConflictName($this->file_name, $names);
     $this->path = MUtils::convertStandardPath($this->parent_path . "/" . $this->file_name);
     $this->file_path = "/" . $this->user_id . $this->path;
     $this->create_file = true;
 }