diff options
author | Daniel Weipert <code@drogueronin.de> | 2021-04-28 13:58:55 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2021-04-28 13:58:55 +0200 |
commit | 20d9f63918d3b2bd75853182063f43eb36d7cd8a (patch) | |
tree | b6f48898297f761dcec8532b524844cc968ec565 /src/Support | |
parent | 11dc8c730dda2c5bd38cb386f96331c5ce3cac9c (diff) |
Adjusts modulesv1.0.0
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; + } +} |