39 lines
773 B
PHP
39 lines
773 B
PHP
<?php
|
|
|
|
namespace App\Classes\File;
|
|
|
|
use App\Classes\FTN\Tic as FTNTic;
|
|
use App\Models\{Address,File};
|
|
|
|
class Tic extends Item
|
|
{
|
|
private string $file;
|
|
|
|
/**
|
|
* @throws \Exception
|
|
*/
|
|
public function __construct(Address $ao,File $fo,int $action)
|
|
{
|
|
switch ($action) {
|
|
case self::I_SEND:
|
|
$tic = new FTNTic;
|
|
$this->file = $tic->generate($ao,$fo);
|
|
$this->file_name = sprintf('%s.tic',sprintf('%08x',$fo->id));
|
|
$this->file_size = strlen($this->file);
|
|
$this->file_mtime = $fo->created_at->timestamp;
|
|
|
|
break;
|
|
|
|
default:
|
|
throw new \Exception('Unknown action: '.$action);
|
|
}
|
|
|
|
$this->action = $action;
|
|
$this->type = self::IS_TIC;
|
|
}
|
|
|
|
public function read(int $start,int $length): string
|
|
{
|
|
return substr($this->file,$start,$length);
|
|
}
|
|
} |