UPD: detectstr EXT="*" support; FIX: LuaWdx class fixes; ADD: descriptionwdx.lua plugin for descript.ion files support

This commit is contained in:
b4rr4cuda 2008-06-03 21:28:07 +00:00
commit 1bb63bfb2f
4 changed files with 1634 additions and 1558 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,63 @@
#!/usr/local/bin/lua
first=true;
function ContentGetSupportedField(Index)
if (not first) then
return '','', 0; -- ft_nomorefields
end
if (first) then
first=false;
return 'Description','', 8; -- FieldName,Units,ft_string
end
end
function ContentGetDefaultSortOrder(FieldIndex)
return 1; --or -1
end
function ContentGetDetectString()
return 'EXT="*"'; -- return detect string
end
function ContentGetValue(FileName, FieldIndex, UnitIndex, flags)
if FieldIndex==0 then
--Linux paths only
local pat="/.*/"
i,j=string.find(FileName,pat);
if i~=nil then
local path=string.sub(FileName,i,j);
fn=string.sub(FileName,string.len(path)+1,-1);
if fn~=".." then
return GetDesc(path,fn);
else
return "";
end
end
end
end
function GetDesc(Path,Name)
local f=io.open(Path..'descript.ion',"r");
if not f then
return "";
end
local CurrDesc={};
for line in f:lines() do
table.insert(CurrDesc,line);
end
for i,v in pairs(CurrDesc) do
if string.find(v,Name..' ') then
return string.sub(v,string.len(Name..' ')+1,-1);
end
end
CurrDesc=nil;
f:close();
return ds;
end

View file

@ -25,7 +25,7 @@ unit uDetectStr;
interface
uses
SysUtils, Classes, uTypes,uFileOp,LCLProc;
SysUtils, Classes, uTypes,uFileOp,LCLProc,Masks;
type
@ -116,8 +116,8 @@ begin
tmp:='"'+tmp+'"';
//---------------------
case Aoperator.op of
moequ: Result:=BooleanToStr(tmp=operand2.data);
moneq: Result:=BooleanToStr(tmp<>operand2.data);
moequ: Result:=BooleanToStr(MatchesMask(tmp,operand2.data));
moneq: Result:=BooleanToStr(not MatchesMask(tmp,operand2.data));
end;
end;
@ -323,7 +323,7 @@ function TParserControl.isdigit(c:char):boolean;
begin
result:=false;
if (integer(c)>64) or
(c in ['1','2','3','4','5','6','7','8','9','0','"']) then
(c in ['1','2','3','4','5','6','7','8','9','0','"','*']) then
result:=true;
end;

View file

@ -281,7 +281,7 @@ procedure TWDXModuleList.Clear;
begin
while Flist.Count>0 do
begin
TWDXModule(Flist.Objects[0]).Free;
TWDXModule(Flist.Objects[0]).Free;
Flist.Delete(0);
end;
end;
@ -352,8 +352,8 @@ procedure TWDXModuleList.DeleteItem(Index: integer);
begin
if (Index>-1) and (Index<Flist.Count) then
begin
TWDXModule(Flist.Objects[Index]).Free;
Flist.Delete(Index);
TWDXModule(Flist.Objects[Index]).Free;
Flist.Delete(Index);
end;
end;
@ -368,7 +368,15 @@ begin
s:=ExtractFileName(FileName);
if pos('.',s)>0 then
delete(s,pos('.',s),length(s));
Result:=Flist.AddObject(UpCase(s),TWDXModule.Create);
if upcase(ExtractFileExt(FileName))='.WDX' then
Flist.AddObject(UpCase(s),TPluginWDX.Create)
else {иначе проверка на скрипт}
if upcase(ExtractFileExt(FileName))='.LUA' then
Flist.AddObject(UpCase(s),TLuaWdx.Create);
//Result:=Flist.AddObject(UpCase(s),TWDXModule.Create);
TWDXModule(Flist.Objects[Result]).Name:=s;
TWDXModule(Flist.Objects[Result]).FileName:=FileName;
if TWDXModule(Flist.Objects[Result]).LoadModule then
@ -381,7 +389,14 @@ end;
function TWDXModuleList.Add(AName, FileName, DetectStr: string): integer;
begin
Result:=Flist.AddObject(UpCase(AName),TWDXModule.Create);
if upcase(ExtractFileExt(FileName))='.WDX' then
Result:=Flist.AddObject(UpCase(AName),TPluginWDX.Create)
else {иначе проверка на скрипт}
if upcase(ExtractFileExt(FileName))='.LUA' then
Result:=Flist.AddObject(UpCase(AName),TLuaWdx.Create);
// Result:=Flist.AddObject(UpCase(AName),TWDXModule.Create);
TWDXModule(Flist.Objects[Result]).Name:=AName;
TWDXModule(Flist.Objects[Result]).DetectStr:=DetectStr;
TWDXModule(Flist.Objects[Result]).FileName:=FileName;
@ -771,7 +786,7 @@ begin
Self.UnloadModule;
UnloadLuaLib; //Todo вынести выгрузку либы в VmClass
//UnloadLuaLib; //Todo вынести выгрузку либы в VmClass
inherited Destroy;
end;
@ -810,7 +825,7 @@ end;
function TLuaWdx.IsLoaded: boolean;
begin
Result:={IsLuaLibLoaded and }Assigned(Self.L);
Result:=IsLuaLibLoaded and Assigned(Self.L);
end;
function TLuaWdx.FieldList: TStringlist;