Completed
Push — master ( 50c9d0...db51c6 )
by Robin
06:58
created

System::getNetPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * Copyright (c) 2014 Robin Appelman <[email protected]>
4
 * This file is licensed under the Licensed under the MIT license:
5
 * http://opensource.org/licenses/MIT
6
 */
7
8
namespace Icewind\SMB;
9
10
use Icewind\SMB\Exception\Exception;
11
12
class System {
13
	private $smbclient;
14
15
	private $net;
16
17
	private $stdbuf;
18
19 504
	public static function getFD($num) {
20
		$folders = array(
21 504
			'/proc/self/fd',
22
			'/dev/fd'
23 504
		);
24 504
		foreach ($folders as $folder) {
25 504
			if (file_exists($folder)) {
26 504
				return $folder . '/' . $num;
27
			}
28
		}
29
		throw new Exception('Cant find file descriptor path');
30
	}
31
32 504
	public function getSmbclientPath() {
33 504
		if (!$this->smbclient) {
34 504
			$this->smbclient = trim(`which smbclient`);
35 504
		}
36 504
		return $this->smbclient;
37
	}
38
39 190
	public function getNetPath() {
40 190
		if (!$this->net) {
41 190
			$this->net = trim(`which net`);
42 190
		}
43 190
		return $this->net;
44
	}
45
46 496
	public function hasStdBuf() {
47 496
		if (!$this->stdbuf) {
48 496
			$result = null;
49 496
			$output = array();
50 496
			exec('which stdbuf 2>&1', $output, $result);
51 496
			$this->stdbuf = $result === 0;
52 496
		}
53 496
		return $this->stdbuf;
54
	}
55
}
56