aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/icewind/smb/src/System.php
blob: 7c519988aa5d0c3bc5a3a5ca6c5afcd22550be70 (plain)
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
<?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;

	private $stdbuf;

	public static function getFD($num) {
		$folders = array(
			'/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;
	}

	public function hasStdBuf() {
		if (!$this->stdbuf) {
			$result = null;
			$output = array();
			exec('which stdbuf 2>&1', $output, $result);
			$this->stdbuf = $result === 0;
		}
		return $this->stdbuf;
	}
}