-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathFileCopyAsyncTask.php
More file actions
65 lines (55 loc) · 1.79 KB
/
Copy pathFileCopyAsyncTask.php
File metadata and controls
65 lines (55 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* _ _ _ _
* | (_) | (_)
* | |_| |__ __ _ ___ _ _ _ __ ___ _ ___
* | | | '_ \ / _` / __| | | | '_ \ / __| |/ _ \
* | | | |_) | (_| \__ \ |_| | | | | (__| | (_) |
* |_|_|_.__/ \__,_|___/\__, |_| |_|\___|_|\___/
* __/ |
* |___/
*
* Copyright (C) 2016-2026 NetherGames Network
*
* This is private software, you cannot redistribute and/or modify it in any way
* unless given explicit permission to do so. If you have not been given explicit
* permission to view or modify this software you should take the appropriate actions
* to remove this software from your device immediately.
*
* @author driesboy
*
*/
declare(strict_types=1);
namespace libasyncio;
use pocketmine\Server;
use pocketmine\utils\Filesystem;
use Throwable;
class FileCopyAsyncTask extends FileOperationTask
{
/** @var string */
protected string $destination;
public function __construct(string $source, string $destination, callable $callable)
{
$this->destination = $destination;
parent::__construct($source, $callable);
}
public function onRun(): void
{
parent::onRun();
try {
Filesystem::recursiveCopy($this->source, $this->destination);
$this->setSuccess(true);
} catch (Throwable $e) {
$this->setSuccess(false);
}
}
protected function checkSuccess(): void
{
$logger = Server::getInstance()->getLogger();
if ($this->getSuccess()) {
$logger->debug("Copied file {$this->source} to {$this->destination}");
} else {
Server::getInstance()->getLogger()->error("Unable to copy file {$this->source} to {$this->destination}");
}
}
}