-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathsomefilesindirwdx.lua
More file actions
66 lines (60 loc) · 2.19 KB
/
somefilesindirwdx.lua
File metadata and controls
66 lines (60 loc) · 2.19 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
-- based on someaudioext4findfiles.lua/someaudioext4columns.lua by Skif_off
-- https://doublecmd.sourceforge.io/forum/viewtopic.php?f=8&t=806&p=19751#p19751
-- dc >= r8553
local masks = {
"*.aa3", "*.aac", "*.ac3", "*.adts", "*.aiff", "*.ape", "*.at3", "*.au", "*.dts", "*.dtshd", "*.flac", "*.l16", "*.m4a",
"*.m4b", "*.m4p", "*.m4r", "*.mp", "*.mp+", "*.mp1", "*.mp2", "*.mp3", "*.mp4", "*.mpc", "*.mpp", "*.ofr", "*.oga", "*.ogg",
"*.oma", "*.opus", "*.pcm", "*.sb0", "*.spx", "*.tak", "*.tta", "*.vqf", "*.wav", "*.wave", "*.wma", "*.wv",
}
local delim = SysUtils.PathDelim;
function ContentGetSupportedField(FieldIndex)
if (masks[FieldIndex + 1] ~= nil) then
return masks[FieldIndex + 1], 'default|recursively', 6;
end
return '', '', 0; -- ft_nomorefields
end
function ContentGetValue(FileName, FieldIndex, UnitIndex, flags)
if SysUtils.DirectoryExists(FileName) then
if (delim == nil) then
if (FileName:find("^/") ~= nil) then
delim = "/";
else
delim = "\\";
end
end
if (UnitIndex == 0) then
return FindFiles(FileName, masks[FieldIndex + 1]);
elseif (UnitIndex == 1) then
return ScanDir(FileName, masks[FieldIndex + 1]);
end
end
return nil;
end
function FindFiles(path, mask)
local handle = SysUtils.FindFirst(path .. delim .. mask);
if (handle ~= nil) then
SysUtils.FindClose(handle);
return true;
end
return false;
end
function ScanDir(path, mask)
if (FindFiles(path, mask) == true) then
return true;
end
local result = false;
local handle, FindData = SysUtils.FindFirst(path .. delim .. '*');
if (handle ~= nil) then
repeat
if (FindData.Name ~= ".") and (FindData.Name ~= "..") then
if (math.floor(FindData.Attr / 0x00000010) % 2 ~= 0) and (ScanDir(path .. delim .. FindData.Name, mask) == true) then
result = true;
break;
end
end
found, FindData = SysUtils.FindNext(handle);
until (found == nil)
SysUtils.FindClose(handle);
end
return result;
end