Completed
Push — stable2 ( b888dd...7c94d5 )
by Robin
06:02
created

System::getNetPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
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 520
	private $date;
20
21 520
	public static function getFD($num) {
22
		$folders = array(
23 520
			'/proc/self/fd',
24 520
			'/dev/fd'
25 520
		);
26 520
		foreach ($folders as $folder) {
27
			if (file_exists($folder)) {
28
				return $folder . '/' . $num;
29
			}
30
		}
31
		throw new Exception('Cant find file descriptor path');
32 520
	}
33 520
34 520
	public function getSmbclientPath() {
35 520
		if (!$this->smbclient) {
36 520
			$this->smbclient = trim(`which smbclient`);
37
		}
38
		return $this->smbclient;
39 192
	}
40 192
41 192
	public function getNetPath() {
42 192
		if (!$this->net) {
43 192
			$this->net = trim(`which net`);
44
		}
45
		return $this->net;
46 512
	}
47 512
48 512
	public function getDatePath() {
49 512
		if (!$this->date) {
50 512
			$this->date = trim(`which date`);
51 512
		}
52 512
		return $this->date;
53 512
	}
54
55
	public function hasStdBuf() {
56
		if (!$this->stdbuf) {
57
			$result = null;
58
			$output = array();
59
			exec('which stdbuf 2>&1', $output, $result);
60
			$this->stdbuf = $result === 0;
61
		}
62
		return $this->stdbuf;
63
	}
64
}
65