diff options
Diffstat (limited to 'src/Support')
-rw-r--r-- | src/Support/HandlesFiles.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Support/HandlesFiles.php b/src/Support/HandlesFiles.php new file mode 100644 index 0000000..8db6975 --- /dev/null +++ b/src/Support/HandlesFiles.php @@ -0,0 +1,27 @@ +<?php + +namespace PHPIAC\Modules\Support; + +use PHPIAC\Connection; + +trait HandlesFiles +{ + /** + * @param string $path + * + * @return bool + */ + public function fileExists(string $path): bool + { + Connection::enablePty(); + + Connection::exec("ls $path"); + $ls = Connection::read(); + + $state = ! str_contains($ls, 'No such file or directory'); + + Connection::disablePty(); + + return $state; + } +} |