mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-04 01:34:07 +02:00
Improve locating file descriptors and smbclient/net commands
This commit is contained in:
parent
a07a5ad2ec
commit
b865f430d6
5 changed files with 100 additions and 18 deletions
43
src/System.php
Normal file
43
src/System.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
||||
* This file is licensed under the Licensed under the MIT license:
|
||||
* http://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Icewind\SMB;
|
||||
|
||||
use Icewind\SMB\Exception\Exception;
|
||||
|
||||
class System {
|
||||
private $smbclient;
|
||||
|
||||
private $net;
|
||||
|
||||
public static function getFD($num) {
|
||||
$folders = [
|
||||
'/proc/self/fd',
|
||||
'/dev/fd'
|
||||
];
|
||||
foreach ($folders as $folder) {
|
||||
if (file_exists($folder)) {
|
||||
return $folder . '/' . $num;
|
||||
}
|
||||
}
|
||||
throw new Exception('Cant find file descriptor path');
|
||||
}
|
||||
|
||||
public function getSmbclientPath() {
|
||||
if (!$this->smbclient) {
|
||||
$this->smbclient = trim(`which smbclient`);
|
||||
}
|
||||
return $this->smbclient;
|
||||
}
|
||||
|
||||
public function getNetPath() {
|
||||
if (!$this->net) {
|
||||
$this->net = trim(`which net`);
|
||||
}
|
||||
return $this->net;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue