- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/file.php
- Класс: BitrixDiskFile
- Вызов: File::copyTo
public function copyTo(Folder $targetFolder, $updatedBy, $generateUniqueName = false)
{
$this->errorCollection->clear();
$forkFileId = CFile::CloneFile($this->getFileId());
if (!$forkFileId)
{
$this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_COPY_FILE'), self::ERROR_COULD_NOT_COPY_FILE)));
return null;
}
$fileModel = $targetFolder->addFile([
'NAME' => $this->getName(),
'FILE_ID' => $forkFileId,
'ETAG' => $this->getEtag(),
'SIZE' => $this->getSize(),
'CREATED_BY' => $updatedBy,
], [], $generateUniqueName);
if (!$fileModel)
{
CFile::Delete($forkFileId);
$this->errorCollection->add($targetFolder->getErrors());
return null;
}
return $fileModel;
}