forked from Novik/ruTorrent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlfs.php
More file actions
65 lines (58 loc) · 1.67 KB
/
lfs.php
File metadata and controls
65 lines (58 loc) · 1.67 KB
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
56
57
58
59
60
61
62
63
64
65
<?php
class LFS
{
static public function test($fname,$flag)
{
$out = array();
@exec( 'test -'.$flag.' '.escapeshellarg( $fname ), $out, $ret );
return($ret == 0);
}
static protected function statPrim($fname)
{
$out = array();
$st = explode(':',@exec( getExternal('stat').' -Lc%d:%i:%f:%h:%u:%g:%s:%X:%Y:%Z:%B:%b '.escapeshellarg( $fname ), $out, $ret ));
return(($ret == 0) ? array(
"dev" => intval($st[0]),
"ino" => intval($st[1]),
"mode" => intval($st[2],16),
"nlink" => intval($st[3]),
"uid" => intval($st[4]),
"gid" => intval($st[5]),
"size" => floatval($st[6]),
"atime" => intval($st[7]),
"mtime" => intval($st[8]),
"ctime" => intval($st[9]),
"blksize" => intval($st[10]),
"blocks" => intval($st[11])) : false);
}
static public function is_file($fname)
{
return(@is_file($fname) || ((PHP_INT_SIZE<=4) && !@is_dir($fname) && @file_exists($fname) && self::test($fname,'f')));
}
static public function is_readable($fname)
{
return(@is_readable($fname) || ((PHP_INT_SIZE<=4) && @file_exists($fname) && self::test($fname,'r')));
}
static public function stat($fname)
{
$ss = @stat($fname);
if(PHP_INT_SIZE<=4)
{
if($ss==false)
return(@file_exists($fname) ? self::statPrim($fname) : false);
if(($ss["blocks"]==-1) || ($ss["blocks"]>4194303))
$ss = self::statPrim($fname);
}
return($ss);
}
static public function filesize($fname)
{
$ss = self::stat($fname);
return(($ss==false) ? false : floatval($ss["size"]));
}
static public function filemtime($fname)
{
$ss = self::stat($fname);
return(($ss==false) ? false : floatval($ss["mtime"]));
}
}