Source file: /~heha/hsn/WdxInfoPacker64.zip/FileProcessing.pas

{$D-,L-,O+,Q-,R-,Y-,S-}
unit FileProcessing;

interface
uses SysUtils,Windows,Classes,IniFiles,LineProcessing,IniFile_Class,
{dialogs,}
someStuff,
WdxStruc;

type TFileProcess=Class
private
SchemeIni:TSchema;
WdxInfoPackerIni:TMyIni;
ContentPluginDefaultIni:array[0..260] of char;
Function UseKnowExtension(PackedFile:pchar):pchar;
public
fileInfo:TFileProp;
procedure loadSchemeOnce(schemeName:pchar);
procedure Init(DefaultIni:pchar); overload;
function Init(DefaultIni:pchar;count:boolean):integer; overload;
function Init2(myIni,DefaultIni:pchar):integer;
function RunOrNot(PackedFile:pchar):boolean;
Function UtiliserScheme(PackedFile:pchar):pchar;
Function FileExtension():pchar;
function WriteHeader(SrcPath,DestName:pchar):pchar;
function UseDivider():boolean;
Function ProcessOneFile(var AllWdxInfo:array of TWdxInfo; Fileprop:TFileProp;Add_Divider:boolean;var Error:boolean;var Force:boolean;processThisDir:boolean):pchar;
function WriteFooter(SrcPath,DestName:pchar):pchar;
function AddCounter():boolean;
function AddTextAdditional():boolean;
procedure ResetIniFile();
function FindTheBestIni(IniParDef:pchar):pchar;
function SaveErrorLog:boolean;
function SchemeisEmpty():boolean;
function GetCounterLength():integer;
function GetCounterPos():integer;
function WorkWithFolder():boolean;
function GetDivider():pchar;
function GetAdditionalText():pchar;
function GetIntervalText():integer;
function LoadEachPlugin(var AllMyWdx:array of TWdxInfo):cardinal;
procedure FreePlugin(AllMyWdx:array of TWdxInfo;nbPlugin:cardinal);
function limitDepth():boolean;
function GetRecursionDepth():integer;
function UseExtensionList():boolean;
procedure GetNeededPluginList(neededList:tstringlist);

end;
implementation


procedure TFileProcess.loadSchemeOnce(schemeName:pchar);
begin
 SchemeIni.LoadScheme(schemeName);
end;

function TFileProcess.Init2(myIni,DefaultIni:pchar):integer;//Use for Copy2CLip...
var s:string;
nbplug:integer;
begin
  WdxInfoPackerIni:=TMyIni.Create;
  SchemeIni:=TSchema.Create;
  Fillchar(ContentPluginDefaultIni,sizeof(ContentPluginDefaultIni),#0);
  StrLCat(ContentPluginDefaultIni,DefaultIni,sizeof(ContentPluginDefaultIni));
  s:=ExtractFilePath(myIni)+'WdxInfoPacker.ini';
  Fillchar(ContentPluginDefaultIni,sizeof(ContentPluginDefaultIni),#0);
  StrLCat(ContentPluginDefaultIni,DefaultIni,sizeof(ContentPluginDefaultIni));
  Fillchar(WdxInfoPackerIni.MyIni.PathToIni,sizeof(WdxInfoPackerIni.MyIni.PathToIni),#0);
  strlcat(WdxInfoPackerIni.MyIni.PathToIni,pchar(s),sizeof(WdxInfoPackerIni.MyIni.PathToIni));
  WdxInfoPackerIni.LoadIniValue;
  Fillchar(SchemeIni.Scheme.PathToSchemeFile ,sizeof(SchemeIni.Scheme.PathToSchemeFile),#0);
  if WdxInfoPackerIni.UseAnotherFileForScheme<>'-1' then begin
        if pos(':\',WdxInfoPackerIni.UseAnotherFileForScheme)=0 then s:=ExtractFilePath(WdxInfoPackerIni.MyIni.PathToIni)+WdxInfoPackerIni.UseAnotherFileForScheme
        else s:=WdxInfoPackerIni.UseAnotherFileForScheme;
  end else begin
     s:=ExtractFilePath(WdxInfoPackerIni.MyIni.PathToIni)+'Scheme.ini';
  end;
  strlcat(SchemeIni.Scheme.PathToSchemeFile,pchar(s),sizeof(SchemeIni.Scheme.PathToSchemeFile));

  nbplug:= WdxInfoPackerIni.CountknownPlugin;
  if nbplug=0 then WdxInfoPackerIni.MyIni.KnownPlugin:=false;
  result:=nbplug;

end;

procedure TFileProcess.Init(DefaultIni:pchar);
var s:string;
begin
  WdxInfoPackerIni:=TMyIni.Create;
  SchemeIni:=TSchema.Create;
  Fillchar(ContentPluginDefaultIni,sizeof(ContentPluginDefaultIni),#0);
  StrLCat(ContentPluginDefaultIni,pchar(ExtractFilepath(DefaultIni)+'contplug.ini'),sizeof(ContentPluginDefaultIni));
  Fillchar(WdxInfoPackerIni.MyIni.PathToIni,sizeof(WdxInfoPackerIni.MyIni.PathToIni),#0);
  strlcat(WdxInfoPackerIni.MyIni.PathToIni,FindTheBestIni(DefaultIni),sizeof(WdxInfoPackerIni.MyIni.PathToIni));
  WdxInfoPackerIni.LoadIniValue;
  Fillchar(SchemeIni.Scheme.PathToSchemeFile ,sizeof(SchemeIni.Scheme.PathToSchemeFile),#0);
  if WdxInfoPackerIni.UseAnotherFileForScheme<>'-1' then begin
   if pos(':\',WdxInfoPackerIni.UseAnotherFileForScheme)=0 then s:=ExtractFilePath(WdxInfoPackerIni.MyIni.PathToIni)+WdxInfoPackerIni.UseAnotherFileForScheme
   else s:=WdxInfoPackerIni.UseAnotherFileForScheme;
  end else begin
   s:=ExtractFilePath(WdxInfoPackerIni.MyIni.PathToIni)+'Scheme.ini';
  end;
  strlcat(SchemeIni.Scheme.PathToSchemeFile,pchar(s),sizeof(SchemeIni.Scheme.PathToSchemeFile));
end;


function TFileProcess.Init(DefaultIni:pchar;count:boolean):integer;
var s:string;
nbplug:integer;

begin
  WdxInfoPackerIni:=TMyIni.Create;
  SchemeIni:=TSchema.Create;
  Fillchar(ContentPluginDefaultIni,sizeof(ContentPluginDefaultIni),#0);
  StrLCat(ContentPluginDefaultIni,pchar(ExtractFilepath(DefaultIni)+'contplug.ini'),sizeof(ContentPluginDefaultIni));
  Fillchar(WdxInfoPackerIni.MyIni.PathToIni,sizeof(WdxInfoPackerIni.MyIni.PathToIni),#0);
  strlcat(WdxInfoPackerIni.MyIni.PathToIni,FindTheBestIni(DefaultIni),sizeof(WdxInfoPackerIni.MyIni.PathToIni));
  WdxInfoPackerIni.LoadIniValue;
  Fillchar(SchemeIni.Scheme.PathToSchemeFile ,sizeof(SchemeIni.Scheme.PathToSchemeFile),#0);
  if WdxInfoPackerIni.UseAnotherFileForScheme<>'-1' then begin

        if pos(':\',WdxInfoPackerIni.UseAnotherFileForScheme)=0 then s:=ExtractFilePath(WdxInfoPackerIni.MyIni.PathToIni)+WdxInfoPackerIni.UseAnotherFileForScheme
        else s:=WdxInfoPackerIni.UseAnotherFileForScheme;
  end else begin
     s:=ExtractFilePath(WdxInfoPackerIni.MyIni.PathToIni)+'Scheme.ini';
  end;
  strlcat(SchemeIni.Scheme.PathToSchemeFile,pchar(s),sizeof(SchemeIni.Scheme.PathToSchemeFile));
 // WdxInfoPackerIni.CheckPluginFolder; // IF %COMMANDER_PATH% is used, we must check for plugin path ...
  nbplug:= WdxInfoPackerIni.CountknownPlugin;
  if nbplug=0 then WdxInfoPackerIni.MyIni.KnownPlugin:=false;
  result:=nbplug;

end;

var dps1:tContentDefaultParamStruct;
function  TFileProcess.LoadEachPlugin(var AllMyWdx:array of TWdxInfo):cardinal;
var List1,List2,List3,List4:tstringlist;
i,j,k:cardinal;
s:string;
res:boolean;
begin
  list1:=Tstringlist.create;
  list2:=Tstringlist.create;
  list1.sorted:=true;
  WdxInfoPackerIni.ListPlugin(list1,list2);
  List3:=Tstringlist.create;
  List3.Sorted:=true;
  List3.Duplicates:=dupIgnore;
  GetNeededPluginList(List3);
  k:=List3.count;
  List4:=TstringList.create;
  List4.clear;
  if k>0 then begin
   for j:=0 to k-1 do begin
    s:=StringReplace(List3[j],'->R', '',[rfReplaceAll, rfIgnoreCase]);
    s:=StringReplace(s,'->B', '',[rfReplaceAll, rfIgnoreCase]);
    s:=StringReplace(s,'->F', '',[rfReplaceAll, rfIgnoreCase]);
    List4.add(s);
   end;
  end;
  dps1.PluginInterfaceVersionLow:=40;
  dps1.PluginInterfaceVersionHi:=1;
  dps1.size:=sizeof(dps1);
  s:=ContentPluginDefaultIni;
  FillChar(dps1.DefaultIniName,sizeof(dps1.DefaultIniName),#0);
  strlcat(dps1.DefaultIniName,pchar(s),sizeof(dps1.DefaultIniName));
  dps1.size:=sizeof(dps1);
  for  i:=0 to list1.count-1 do begin
   if k>0 then begin
    for j:=0 to k-1 do begin
     if UpperCase(List4[j])=UpperCase(List1[i]) then begin
      AllMyWdx[j]:=TwdxInfo.create;
      res:=AllMyWdx[j].Load(pchar(List1[i]),pchar(List2[i]),dps1);
      AllMyWdx[j].CanBeUsed:=res;
     end;
    end;
   end;
  end;
  List4.free;
  List3.free;
  List2.Free ;
  List1.Free ;
  result:=k;
end;
function TFileProcess.FindTheBestIni(IniParDef:pchar):pchar;
var path:string; ModName: array[0..260] of Char; Res:array[0..260] of Char;AllTest,Find:boolean;
begin
  find:=false;
  AllTest:=false;
  if not AllTest then begin
  //Test1 : .\PluginName.ini (relative to the directory where Wincmd.ini is located)
  path:=ExtractFilePath(IniParDef)+'WdxInfoPacker.ini';
  if not (FileIsReadOnly(path)) then begin
     find:=true;
     Fillchar(Res,sizeof(Res),#0);
     strlcat(Res,pchar(path),sizeof(Res));
  end;
  //Test2 : .\PluginName\PluginName.ini (relative to the directory where Wincmd.ini is located)
  path:=ExtractFilePath(IniParDef)+'WdxInfoPacker\WdxInfoPacker.ini';
  if not (FileIsReadOnly(path)) then begin
     find:=true;
     Fillchar(Res,sizeof(Res),#0);
     strlcat(Res,pchar(path),sizeof(Res));
  end;
  //Test3 : .\PluginName.ini (relative to the directory where the plugin is located)
  Fillchar(ModName,sizeof(ModName),#0);
  SetString(path, ModName,Windows.GetModuleFileName(HInstance, ModName, SizeOf(ModName)));
  path:=ExtractFilePath(path)+'WdxInfoPacker.ini';
  if not (FileIsReadOnly(path)) then begin
     find:=true;
     Fillchar(Res,sizeof(Res),#0);
     strlcat(Res,pchar(path),sizeof(Res));
  end;
  //Test4 : .\PluginName.ini (relative to the directory where Total Commander is located)
  Fillchar(ModName,sizeof(ModName),#0);
  SetString(path, ModName,Windows.GetModuleFileName(0, ModName, SizeOf(ModName)));
  path:=ExtractFilePath(path)+'WdxInfoPacker.ini';
  if not (FileIsReadOnly(path)) then begin
     find:=true;
     Fillchar(Res,sizeof(Res),#0);
     strlcat(Res,pchar(path),sizeof(Res));
  end;
  if not find then AllTest:=true;
  end;
  if AllTest then begin //We'll use wincmd.ini folder , it must be writable
     Path:=ExtractFilePath(IniParDef)+'WdxInfoPacker.ini';
     Fillchar(Res,sizeof(Res),#0);
     strlcat(Res,pchar(path),sizeof(Res));
  end;
  result:=Res;
end;


function TFileProcess.RunOrNot(PackedFile:pchar):boolean;
var KnowExt,Run:boolean;
i,unique:integer;
use:array[0..50]of char;
ext:array[0..2]of TStringList;
begin
  KnowExt:=false;
  if WdxInfoPackerIni.MyIni.KnownPlugin then begin
    if WdxInfoPackerIni.MyIni.Assoc then begin
      ext[0]:=TStringList.Create;
      ext[1]:=TStringList.Create;
      SchemeIni.ListAvailableExtension(ext);
      unique:=0;
      for i:=0 to ext[0].Count-1 do begin
         if comparestr(UpperCase(ext[1][i]),Uppercase(ExtractFileExt(PackedFile)))=0 then begin
         Fillchar(use,sizeof(use),#0);
            KnowExt:=true;
            strlcat(use,pchar(Ext[0][i]),sizeof(use));
            inc(unique);
         end;
      end;
      if unique>1 then KnowExt:=false;
    end;
  end;
  if (not WdxInfoPackerIni.MyIni.Run) then begin
   if(WdxInfoPackerIni.MyIni.RememberLast or KnowExt) then begin
    Run:=true;
   end else Run:=False;
  end else Run:=true;
  result:=Run;
end;

Function TFileProcess.UseKnowExtension(PackedFile:pchar):pchar;
var i:integer;
use:array[0..50]of char;
ext:array[0..2]of TStringList;
Found:boolean;
begin
  ext[0]:=TStringList.Create;
  ext[1]:=TStringList.Create;
  SchemeIni.ListAvailableExtension(ext);
  Found:=false;
  Fillchar(use,sizeof(use),#0);
  for i:=0 to ext[0].Count-1 do begin
      if (comparestr(UpperCase(ext[1][i]),Uppercase(ExtractFileExt(PackedFile)))=0) and (not Found) then begin
         strlcat(use,pchar(Ext[0][i]),sizeof(use));
         Found:=true;
      end;
  end;
  result:=use;
end;

Function TFileProcess.UtiliserScheme(PackedFile:pchar):pchar;
var scheme:array[0..50] of char;
i:integer;
assign:boolean;
begin
  assign:=false;
  FillChar(scheme,sizeof(scheme),#0);
  strcat(scheme,UseKnowExtension(PackedFile));
  if scheme <>'' then begin
     assign:=true;
  end else FillChar(scheme,sizeof(scheme),#0);
  if WdxInfoPackerIni.MyIni.RememberLast and (not assign) then begin
     FillChar(scheme,sizeof(scheme),#0);
     strcopy(scheme,WdxInfoPackerIni.MyIni.LastScheme);
  end;
  if WdxInfoPackerIni.MyIni.Run and (not assign) then begin
     FillChar(scheme,sizeof(scheme),#0);
     strcopy(scheme,'RunTemp');
  end;
  if not (WdxInfoPackerIni.MyIni.Run or WdxInfoPackerIni.MyIni.RememberLast) then begin
     FillChar(scheme,sizeof(scheme),#0);
     strcat(scheme,UseKnowExtension(PackedFile));
  end;
  for i:=0 to sizeof(scheme)-1 do begin
      if scheme[i]=#3 then scheme[i]:=#0;
  end;
  result:=scheme;
end;


Function TFileProcess.FileExtension():pchar;
var p:pchar;
begin
 p:=SchemeIni.Scheme.Extension ;
 result:=p;
end;

Function TFileProcess.ProcessOneFile(var AllWdxInfo:array of TWdxInfo;Fileprop:TFileProp;Add_Divider:boolean;var Error:boolean;var Force:boolean;processThisDir:boolean):pchar;
var
Divi,DoNotWrite,val:boolean;
Line:TOneLine;
outputbuf:array[0..6*1024] of char;
testing:array[0..1024] of char;
i,j,k:integer;
s,s1:string;
List:TStringList;
process,testExtension:boolean;
begin
  Divi:=Add_Divider;
  testExtension:=UseExtensionList();
  Fillchar(outputbuf,sizeof(outputbuf),#0);
  Fillchar(testing,sizeof(testing),#0);
  Line:=TOneLine.Create;
  process:=false;
  if testExtension then begin
   if (pos('|',Schemeini.Scheme.ListExtension)=0) and (Schemeini.Scheme.ListExtension<>'') then begin
    s:=Schemeini.Scheme.ListExtension;
    s1:='.'+s;
    if UpperCase(s1)=UpperCase(ExtractFileExt(  Fileprop.pnextname)) then process:=true;
   end else begin
    List:=TStringList.Create;
    Split('|',Schemeini.Scheme.ListExtension,List);
    for i:=0 to List.Count-1 do begin
     s:='.'+List[i];
     if UpperCase(s)=UpperCase(ExtractFileExt(  Fileprop.pnextname)) then process:=true;
    end;
   end;
  end else process:=true;
  if (process) then begin
  j:=0;
  k:=0;
  DoNotWrite:=SchemeIni.Scheme.DoNotWrite;
  if StrLen(SchemeIni.Scheme.Use)>0 then begin
    for i:=0 to StrLen(SchemeIni.Scheme.Use) do begin
      Fillchar(testing,sizeof(testing),#0);
      val:=DoNotWrite;
      Fillchar(Line.ContPLugDefIni,sizeof(Line.ContPLugDefIni),#0);
      strlcat(Line.ContPLugDefIni,ContentPluginDefaultIni,sizeof(Line.ContPLugDefIni));
      fileInfo.strReplace:=SchemeIni.Scheme.StrReplace;
      fileInfo.strReplaceValue:=SchemeIni.Scheme.StrReplaceValue;
      if (processThisDir=false) then begin
        case SchemeIni.Scheme.Use[i] of
          'b','B':begin
          inc(k);
          Line.SetLineValue(SchemeIni.Scheme.Before); //before
          strlcat(testing,Line.GetAllValueForLine(Fileinfo,WdxInfoPackerIni.MyIni.PathToIni,val,SchemeIni.Scheme.MaxRight,AllWdxInfo,false),sizeof(testing));
          if val then begin
            inc(j);
            if pos('/IFE/',SchemeIni.Scheme.Before)<>0 then strlcat(outputbuf,pchar(''),sizeof(outputbuf));
          end;
          if (pos('/IFE/',SchemeIni.Scheme.Before)=0) or not val then strlcat(outputbuf,testing,sizeof(outputbuf));
        end;
        'c','C':begin //The Name
          if Divi then begin
            Line.SetLineValue(SchemeIni.Scheme.Divider);
            strlcat(outputbuf,Line.GetSeparator,sizeof(outputbuf));
          end;
          inc(k);
          Line.SetLineValue(SchemeIni.Scheme.name);
          strlcat(testing,Line.GetAllValueForLine(Fileinfo,WdxInfoPackerIni.MyIni.PathToIni,val,SchemeIni.Scheme.MaxRight,AllWdxInfo,false),sizeof(testing));
          if val then begin
            inc(j);
            if pos('/IFE/',SchemeIni.Scheme.name)<>0 then strlcat(outputbuf,pchar(''),sizeof(outputbuf));
           end;
          if (pos('/IFE/',SchemeIni.Scheme.name)=0) or not val then strlcat(outputbuf,testing,sizeof(outputbuf));
         end;
         'd','D':begin //Between Name & information
        if Divi then begin
           Line.SetLineValue(SchemeIni.Scheme.Divider);
           strlcat(outputbuf,Line.GetSeparator,sizeof(outputbuf));
        end;
        inc(k);
        Line.SetLineValue(SchemeIni.Scheme.Between);
        strlcat(testing,Line.GetAllValueForLine(Fileinfo,WdxInfoPackerIni.MyIni.PathToIni,val,SchemeIni.Scheme.MaxRight,AllWdxInfo,false),sizeof(testing));
        if val then begin
        inc(j);
        if pos('/IFE/',SchemeIni.Scheme.Between)<>0 then strlcat(outputbuf,pchar(''),sizeof(outputbuf));
        end;
        if (pos('/IFE/',SchemeIni.Scheme.Between)=0) or not val then strlcat(outputbuf,testing,sizeof(outputbuf));
        end;
        'e','E':begin //Information :)
        if Divi then begin
           Line.SetLineValue(SchemeIni.Scheme.Divider);
           strlcat(outputbuf,Line.GetSeparator,sizeof(outputbuf));
        end;
        inc(k);
        Line.SetLineValue(SchemeIni.Scheme.WdxInfo);
        strlcat(testing,Line.GetAllValueForLine(Fileinfo,WdxInfoPackerIni.MyIni.PathToIni,val,SchemeIni.Scheme.MaxRight,AllWdxInfo,false),sizeof(testing));
        if val then begin
           inc(j);
           if (pos('/IFE/',SchemeIni.Scheme.WdxInfo)<>0) then strlcat(outputbuf,pchar(''),sizeof(outputbuf));
        end;
        if (pos('/IFE/',SchemeIni.Scheme.WdxInfo)=0)or not val then strlcat(outputbuf,testing,sizeof(outputbuf));
        end;
        'f','F':begin //after the information
        if Divi then begin
           Line.SetLineValue(SchemeIni.Scheme.Divider);
           strlcat(outputbuf,Line.GetSeparator,sizeof(outputbuf));
        end;
        inc(k);
        Line.SetLineValue(SchemeIni.Scheme.After);
        strlcat(testing,Line.GetAllValueForLine(Fileinfo,WdxInfoPackerIni.MyIni.PathToIni,val,SchemeIni.Scheme.MaxRight,AllWdxInfo,false),sizeof(testing));
        if val then begin
           inc(j);
           if pos('/IFE/',SchemeIni.Scheme.After)<>0 then strlcat(outputbuf,pchar(''),sizeof(outputbuf));
        end;
        if (pos('/IFE/',SchemeIni.Scheme.After)=0) or not val then strlcat(outputbuf,testing,sizeof(outputbuf));
        end;
      end;
    end
    else if (processThisDir=true) then begin
      case SchemeIni.Scheme.Use[i] of
       'k','K':begin
        inc(k);
        Line.SetLineValue(SchemeIni.Scheme.DirectoryText);
        strlcat(testing,Line.GetAllValueForLine(Fileinfo,WdxInfoPackerIni.MyIni.PathToIni,val,SchemeIni.Scheme.MaxRight,AllWdxInfo,true),sizeof(testing));
        if val then begin
           inc(j);
           if pos('/IFE/',SchemeIni.Scheme.DirectoryText)<>0 then strlcat(outputbuf,pchar(''),sizeof(outputbuf));
        end;
        if (pos('/IFE/',SchemeIni.Scheme.DirectoryText)=0) or not val then strlcat(outputbuf,testing,sizeof(outputbuf));
        end;
      end;
    end;
    end;
    end;

  Line.free;
  if ((j=k) and  SchemeIni.Scheme.DoNotWrite) then Error:=true;
  if ((j=k) and  SchemeIni.Scheme.SaveLog) then force:=true;
  end else begin Line.free; Error:=true;force:=false;end;
  result:=outputbuf
end;
function TFileProcess.SchemeisEmpty():boolean;begin
if StrLen(SchemeIni.Scheme.Use)>0 then result:=false
else result:=true;

end;

function TFileProcess.WriteHeader(SrcPath,DestName:pchar):pchar;
var  Line:TOneLine;
outputbuf:array[0..1024] of char;
i:integer;
find:boolean;
begin
  fillchar(outputbuf,sizeof(outputbuf),#0);
  Line:=TOneLine.Create;
  find:=false;
  if StrLen(SchemeIni.Scheme.Use)>0 then begin
  for i:=0 to StrLen(SchemeIni.Scheme.Use) do begin
          case SchemeIni.Scheme.Use[i] of
            'a','A':begin
                Line.SetLineValue(SchemeIni.Scheme.Header);
                find:=true;
                strlcat(outputbuf,Line.GetHeaderOrFooter(SrcPath,DestName),sizeof(outputbuf));
            end;
        end;
  end;
  end;
  if not find then result:=pchar('-1')
  else result:=outputbuf;
  Line.free;

end;

function TFileProcess.WriteFooter(SrcPath,DestName:pchar):pchar;
var Line:TOneLine;
outputbuf:array[0..1024] of char;
//temp:array[0..50] of char;
i:integer;
find:boolean;
begin
  fillchar(outputbuf,sizeof(outputbuf),#0);
  Line:=TOneLine.Create;
  find:=false;
  if StrLen(SchemeIni.Scheme.Use)>0 then begin
  for i:=0 to StrLen(SchemeIni.Scheme.Use) do begin
          case SchemeIni.Scheme.Use[i] of
            'g','G':begin
                Line.SetLineValue(SchemeIni.Scheme.Footer);
                find:=true;
                strlcat(outputbuf,Line.GetHeaderOrFooter(SrcPath,DestName),sizeof(outputbuf));
            end;
        end;
  end;
  end;
  Line.free;
result:=outputbuf;
if not find then result:=pchar('-1');

end;

function TFileProcess.AddCounter():boolean;
var Counter:boolean;
begin
  Counter:=SchemeIni.Scheme.Counter;
  result:=Counter;
end;

function TFileProcess.GetCounterLength():integer;
var i:integer;
begin
 i:=SchemeIni.Scheme.CounterLength;
 result:=i;
end;

function TFileProcess.GetCounterPos():integer;
var i:integer;
begin
 i:=SchemeIni.Scheme.CounterPos;
 result:=i;
end;

function TFileProcess.SaveErrorLog:boolean;
var p:boolean;
begin
p:=SchemeIni.Scheme.SaveLog;
result:=p;
end;

procedure TFileProcess.ResetIniFile();
begin
    WdxInfoPackerIni.MyIni.Run:=false;
    WdxInfoPackerIni.SaveIniValue;
    SchemeIni.DeleteScheme(pchar('RunTemp'));
end;


function TFileProcess.UseDivider():boolean;
var i:integer;
begin
 result:=false;
if StrLen(SchemeIni.Scheme.Use)>0 then begin
for i:=0 to StrLen(SchemeIni.Scheme.Use) do begin
    case SchemeIni.Scheme.Use[i] of
         'h','H':begin
            result:=true;
         end;
    end;
end;
end;

end;
function TFileProcess.GetDivider():pchar;
var tempLine:TOneLine;
p:pchar;
begin
p:=SchemeIni.Scheme.divider;
 if p<>'' then begin
  tempLine:=TOneLine.Create;
  tempLine.SetLineValue(SchemeIni.Scheme.divider);
  result:=tempLine.GetSeparator;
  tempLine.Free
 end else result:='';
end;
function TFileProcess.AddTextAdditional():boolean;
var i:integer;
begin
result:=false;
if StrLen(SchemeIni.Scheme.Use)>0 then begin
for i:=0 to StrLen(SchemeIni.Scheme.Use) do begin
  case SchemeIni.Scheme.Use[i] of
    'j','J':begin
      result:=true;
    end;
  end;
end;
end;
end;
function TFileProcess.UseExtensionList():boolean;
var i:integer;
begin
result:=false;
if StrLen(SchemeIni.Scheme.Use)>0 then begin
for i:=0 to StrLen(SchemeIni.Scheme.Use) do begin
  case SchemeIni.Scheme.Use[i] of
    'i','I':begin
      result:=true;
    end;
  end;
end;
end;
end;


function TFileProcess.GetAdditionalText():pchar;
var
tempLine:TOneLine;
begin
 if SchemeIni.Scheme.divider<>'' then begin
  tempLine:=TOneLine.Create;
  tempLine.SetLineValue(SchemeIni.Scheme.AdditionnalText);
  result:=tempLine.GetSeparator;
  tempLine.Free
 end else result:='';
end;
function TFileProcess.GetIntervalText():integer;
var i:integer;
begin
i:=SchemeIni.Scheme.IntervalNbr;
result:=i;
end;

function TFileProcess.WorkWithFolder():boolean;
begin
if ((pos('k',SchemeIni.Scheme.Use)<>0) or (pos('K',SchemeIni.Scheme.Use)<>0))then result:=true
else result:=false;

end;

function TFileProcess.limitDepth():boolean;
begin
if ((pos('l',SchemeIni.Scheme.Use)<>0) or (pos('L',SchemeIni.Scheme.Use)<>0))then result:=true
else result:=false;

end;

function TFileProcess.GetRecursionDepth():integer;
var p:integer;
begin
p:=SchemeIni.Scheme.recursionDepth;
result:=p;
end;

procedure TFileProcess.FreePlugin(AllMyWdx:array of TWdxInfo;nbPlugin:cardinal);
var s:string;
UnloadListe:Tstringlist;
testUnload:boolean;
i,k:integer;
begin
  testUnload:=false;
  UnloadListe:=TStringList.create;
  s:=getExtendedPath(WdxInfoPackerIni.MyIni.UnloadingFile);
  if (pos(':\',s)=0) then s:=ExtractFilePath(WdxInfoPackerIni.MyIni.PathToIni)+s;
  if (strlen(pchar(s))>0) then begin
    if (FileExists(s)) then begin
      UnloadListe.LoadFromFile(s);
      testUnload:=true;
    end
    else testUnload:=false;
  end;
  k:=0;
  if nbPlugin>1 then begin
   for i:=0 to  nbPlugin-1 do begin
     if (testUnload=true) then begin
       if (UnloadListe.Find(AllMyWdx[i].Name,k)=true) then AllMyWdx[i].FreeMe(true)
       else AllMyWdx[i].FreeMe(false);
     end else AllMyWdx[i].FreeMe(false);
   end;
  end;
  UnloadListe.Free;
end;

procedure TFileProcess.GetNeededPluginList(neededList:tstringlist);
var
L1,L2:TStringlist;
s:string;
i,j:cardinal;
begin
 neededList.Clear;
 L1:=TStringList.Create;
 L2:=TStringList.Create;
 if (pos('C',UpperCase(SchemeIni.Scheme.Use))<>0)and(pos('@Mod=',SchemeIni.Scheme.Name)<>0) then begin
  s:=StringReplace(SchemeIni.Scheme.Name,' ','1_1',[rfReplaceAll, rfIgnoreCase]);
  s:=StringReplace(s,'@Mod=','',[rfReplaceAll, rfIgnoreCase]);
  L1.Clear;
  Split(';',s,L1);
  j:=L1.Count-1;
  L2.clear;
  for i:=0 to j do begin
   if pos('@',L1[i])<>0 then begin
    Split('@',L1[i],L2);
    neededList.Add(StringReplace(L2[1],'1_1',' ',[rfReplaceAll, rfIgnoreCase]));
   end;
  end;
 end;
 if (pos('B',UpperCase(SchemeIni.Scheme.Use))<>0)and(pos('@Mod=',SchemeIni.Scheme.before)<>0) then begin
  s:=StringReplace(SchemeIni.Scheme.before,' ','1_1',[rfReplaceAll, rfIgnoreCase]);
  s:=StringReplace(s,'@Mod=','',[rfReplaceAll, rfIgnoreCase]);
  L1.Clear;
  Split(';',s,L1);
  j:=L1.Count-1;
  L2.clear;
  for i:=0 to j do begin
   if pos('@',L1[i])<>0 then begin
    Split('@',L1[i],L2);
    neededList.Add(StringReplace(L2[1],'1_1',' ',[rfReplaceAll, rfIgnoreCase]));
   end;
  end;
 end;
  if (pos('D',UpperCase(SchemeIni.Scheme.Use))<>0)and(pos('@Mod=',SchemeIni.Scheme.between)<>0) then begin
  s:=StringReplace(SchemeIni.Scheme.between,' ','1_1',[rfReplaceAll, rfIgnoreCase]);
  s:=StringReplace(s,'@Mod=','',[rfReplaceAll, rfIgnoreCase]);
  L1.Clear;
  Split(';',s,L1);
  j:=L1.Count-1;
  L2.clear;
  for i:=0 to j do begin
   if pos('@',L1[i])<>0 then begin
    Split('@',L1[i],L2);
    neededList.Add(StringReplace(L2[1],'1_1',' ',[rfReplaceAll, rfIgnoreCase]));
   end;
  end;
 end;
  if (pos('E',UpperCase(SchemeIni.Scheme.Use))<>0)and(pos('@Mod=',SchemeIni.Scheme.wdxinfo)<>0) then begin
  s:=StringReplace(SchemeIni.Scheme.wdxinfo,' ','1_1',[rfReplaceAll, rfIgnoreCase]);
  s:=StringReplace(s,'@Mod=','',[rfReplaceAll, rfIgnoreCase]);
  L1.Clear;
  Split(';',s,L1);
  j:=L1.Count-1;
  L2.clear;
  for i:=0 to j do begin
   if pos('@',L1[i])<>0 then begin
    Split('@',L1[i],L2);
    neededList.Add(StringReplace(L2[1],'1_1',' ',[rfReplaceAll, rfIgnoreCase]));
   end;
  end;
 end;
 if (pos('F',UpperCase(SchemeIni.Scheme.Use))<>0)and(pos('@Mod=',SchemeIni.Scheme.after)<>0) then begin
  s:=StringReplace(SchemeIni.Scheme.after,' ','1_1',[rfReplaceAll, rfIgnoreCase]);
  s:=StringReplace(s,'@Mod=','',[rfReplaceAll, rfIgnoreCase]);
  L1.Clear;
  Split(';',s,L1);
  j:=L1.Count-1;
  L2.clear;
  for i:=0 to j do begin
   if pos('@',L1[i])<>0 then begin
    Split('@',L1[i],L2);
    neededList.Add(StringReplace(L2[1],'1_1',' ',[rfReplaceAll, rfIgnoreCase]));
   end;
  end;
 end;
  if (pos('K',UpperCase(SchemeIni.Scheme.Use))<>0)and(pos('@Mod=',SchemeIni.Scheme.DirectoryText)<>0) then begin
  s:=StringReplace(SchemeIni.Scheme.DirectoryText,' ','1_1',[rfReplaceAll, rfIgnoreCase]);
  s:=StringReplace(s,'@Mod=','',[rfReplaceAll, rfIgnoreCase]);
  L1.Clear;
  Split(';',s,L1);
  j:=L1.Count-1;
  L2.clear;
  for i:=0 to j do begin
   if pos('@',L1[i])<>0 then begin
    Split('@',L1[i],L2);
    neededList.Add(StringReplace(L2[1],'1_1',' ',[rfReplaceAll, rfIgnoreCase]));
   end;
  end;
 end;
end;
end.
Detected encoding: ASCII (7 bit)2