-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathfatattrwdx.lua
More file actions
88 lines (84 loc) · 2.4 KB
/
fatattrwdx.lua
File metadata and controls
88 lines (84 loc) · 2.4 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
local cmd = "fatattr"
local output = ''
local dosattr = ''
local filename = ''
function ContentGetSupportedField(FieldIndex)
if (FieldIndex == 0) then
return 'archive', '', 6;
elseif (FieldIndex == 1) then
return 'hidden', '', 6;
elseif (FieldIndex == 2) then
return 'readonly', '', 6;
elseif (FieldIndex == 3) then
return 'system', '', 6;
elseif (FieldIndex == 4) then
return 'attr string', '', 8;
end
return '', '', 0; -- ft_nomorefields
end
function ContentGetDetectString()
return nil; -- return detect string
end
function ContentGetValue(FileName, FieldIndex, UnitIndex, flags)
local delimpat = SysUtils.PathDelim;
if (delimpat == nil) then
delimpat = "/\\";
end
if (FileName:find("[" .. delimpat .. "]%.%.$")) then
return nil;
end
if (filename ~= FileName) or (FieldIndex == 4) then
local attr = SysUtils.FileGetAttr(FileName);
if (attr < 0) or (math.floor(attr / 0x00000004) % 2 ~= 0) then
return nil;
end
local handle = io.popen(cmd .. ' "' .. FileName:gsub('"', '\\"') .. '"', 'r');
output = handle:read("*a");
handle:close();
if (output ~= nil) and (output:sub(1, 9) ~= FileName:sub(1, 9)) then
dosattr = output:sub(1, 9);
end
filename = FileName;
end
if (FieldIndex == 0) then
return checkattr(dosattr, 'a');
elseif (FieldIndex == 1) then
return checkattr(dosattr, 'h');
elseif (FieldIndex == 2) then
return checkattr(dosattr, 'r');
elseif (FieldIndex == 3) then
return checkattr(dosattr, 's');
elseif (FieldIndex == 4) then
local str = '';
if (checkattr(dosattr, 'r')) then
str = str .. 'r';
else
str = str .. '-';
end
if (checkattr(dosattr, 'a')) then
str = str .. 'a';
else
str = str .. '-';
end
if (checkattr(dosattr, 'h')) then
str = str .. 'h';
else
str = str .. '-';
end
if (checkattr(dosattr, 's')) then
str = str .. 's';
else
str = str .. '-';
end
return str;
end
return nil; -- invalid
end
function checkattr(vattr, val)
if (vattr ~= nil) then
if (string.find(vattr, val)) then
return true;
end
end
return false;
end