mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
ADD: Lister. First step.
This commit is contained in:
parent
071fdd455a
commit
1a352b0cf6
6 changed files with 1013 additions and 803 deletions
68
fviewer.lfm
68
fviewer.lfm
|
|
@ -1,15 +1,15 @@
|
|||
object frmViewer: TfrmViewer
|
||||
Left = 66
|
||||
Height = 489
|
||||
Top = 87
|
||||
Width = 760
|
||||
HorzScrollBar.Page = 759
|
||||
VertScrollBar.Page = 468
|
||||
Left = 289
|
||||
Height = 726
|
||||
Top = 91
|
||||
Width = 987
|
||||
HorzScrollBar.Page = 986
|
||||
VertScrollBar.Page = 699
|
||||
VertScrollBar.Range = 19
|
||||
ActiveControl = ScrollBarVert
|
||||
Caption = 'Viewer'
|
||||
ClientHeight = 469
|
||||
ClientWidth = 760
|
||||
ClientHeight = 700
|
||||
ClientWidth = 987
|
||||
Constraints.MinHeight = 100
|
||||
Constraints.MinWidth = 200
|
||||
KeyPreview = True
|
||||
|
|
@ -22,10 +22,16 @@ object frmViewer: TfrmViewer
|
|||
OnKeyUp = frmViewerKeyUp
|
||||
Position = poDefault
|
||||
ShowInTaskBar = stAlways
|
||||
object pnlLister: TPanel
|
||||
Height = 680
|
||||
Width = 987
|
||||
Align = alClient
|
||||
TabOrder = 2
|
||||
end
|
||||
object Status: TStatusBar
|
||||
Height = 23
|
||||
Top = 446
|
||||
Width = 760
|
||||
Height = 20
|
||||
Top = 680
|
||||
Width = 987
|
||||
Panels = <
|
||||
item
|
||||
Width = 200
|
||||
|
|
@ -42,19 +48,19 @@ object frmViewer: TfrmViewer
|
|||
SimplePanel = False
|
||||
end
|
||||
object nbPages: TNotebook
|
||||
Height = 446
|
||||
Width = 760
|
||||
Height = 680
|
||||
Width = 987
|
||||
Align = alClient
|
||||
PageIndex = 0
|
||||
PageIndex = 1
|
||||
ShowTabs = False
|
||||
TabOrder = 0
|
||||
object pgText: TPage
|
||||
Caption = 'pgText'
|
||||
ClientWidth = 752
|
||||
ClientHeight = 438
|
||||
ClientWidth = 987
|
||||
ClientHeight = 680
|
||||
object ScrollBarVert: TScrollBar
|
||||
Left = 737
|
||||
Height = 438
|
||||
Left = 972
|
||||
Height = 680
|
||||
Width = 15
|
||||
Align = alRight
|
||||
Anchors = [akTop, akRight]
|
||||
|
|
@ -68,8 +74,8 @@ object frmViewer: TfrmViewer
|
|||
end
|
||||
object ViewerControl: TViewerControl
|
||||
Cursor = crIBeam
|
||||
Height = 438
|
||||
Width = 737
|
||||
Height = 680
|
||||
Width = 972
|
||||
ViewerMode = vmText
|
||||
Font.Height = -14
|
||||
Font.Name = 'fixed'
|
||||
|
|
@ -81,18 +87,20 @@ object frmViewer: TfrmViewer
|
|||
end
|
||||
object pgImage: TPage
|
||||
Caption = 'pgImage'
|
||||
ClientWidth = 983
|
||||
ClientHeight = 676
|
||||
object ScrollBox: TScrollBox
|
||||
Height = 468
|
||||
Width = 788
|
||||
HorzScrollBar.Page = 787
|
||||
VertScrollBar.Page = 467
|
||||
Height = 676
|
||||
Width = 983
|
||||
HorzScrollBar.Page = 978
|
||||
VertScrollBar.Page = 671
|
||||
Align = alClient
|
||||
ParentCtl3D = False
|
||||
TabOrder = 0
|
||||
TabStop = True
|
||||
object Image: TImage
|
||||
Height = 468
|
||||
Width = 788
|
||||
Height = 672
|
||||
Width = 979
|
||||
Align = alClient
|
||||
Transparent = False
|
||||
end
|
||||
|
|
@ -169,6 +177,14 @@ object frmViewer: TfrmViewer
|
|||
object miDiv1: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object miPlugins: TMenuItem
|
||||
Caption = 'Plugins'
|
||||
ShortCut = 55
|
||||
OnClick = miPluginsClick
|
||||
end
|
||||
object MenuItem1: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object miSearch: TMenuItem
|
||||
Caption = 'Search'
|
||||
ShortCut = 114
|
||||
|
|
|
|||
54
fviewer.lrt
54
fviewer.lrt
|
|
@ -1,26 +1,28 @@
|
|||
TFRMVIEWER.CAPTION=Viewer
|
||||
TFRMVIEWER.PGTEXT.CAPTION=pgText
|
||||
TFRMVIEWER.PGIMAGE.CAPTION=pgImage
|
||||
TFRMVIEWER.MIFILE.CAPTION=&File
|
||||
TFRMVIEWER.MIPREV.CAPTION=&Previous
|
||||
TFRMVIEWER.MINEXT.CAPTION=&Next
|
||||
TFRMVIEWER.MISEPARATOR.CAPTION=-
|
||||
TFRMVIEWER.MISAVEPOS.CAPTION=&Save Position
|
||||
TFRMVIEWER.N1.CAPTION=-
|
||||
TFRMVIEWER.MIEXIT.CAPTION=E&xit
|
||||
TFRMVIEWER.MIEDIT.CAPTION=&Edit
|
||||
TFRMVIEWER.MICOPYTOCLIPBOARD.CAPTION=Copy To Clipboard
|
||||
TFRMVIEWER.MISELECTALL.CAPTION=Select All
|
||||
TFRMVIEWER.MIVIEW.CAPTION=&View
|
||||
TFRMVIEWER.MITEXT.CAPTION=Show as &Text
|
||||
TFRMVIEWER.MIBIN.CAPTION=Show as &Bin
|
||||
TFRMVIEWER.MIHEX.CAPTION=Show as &Hex
|
||||
TFRMVIEWER.MIWRAPTEXT.CAPTION=Show as &Wrap text
|
||||
TFRMVIEWER.MIDIV2.CAPTION=-
|
||||
TFRMVIEWER.MIGRAPHICS.CAPTION=Graphics
|
||||
TFRMVIEWER.MIDIV1.CAPTION=-
|
||||
TFRMVIEWER.MISEARCH.CAPTION=Search
|
||||
TFRMVIEWER.MIIMAGE.CAPTION=&Image
|
||||
TFRMVIEWER.MISTRETCH.CAPTION=Stretch
|
||||
TFRMVIEWER.MIABOUT.CAPTION=About
|
||||
TFRMVIEWER.MIABOUT2.CAPTION=About Viewer...
|
||||
TFRMVIEWER.CAPTION=Viewer
|
||||
TFRMVIEWER.PGTEXT.CAPTION=pgText
|
||||
TFRMVIEWER.PGIMAGE.CAPTION=pgImage
|
||||
TFRMVIEWER.MIFILE.CAPTION=&File
|
||||
TFRMVIEWER.MIPREV.CAPTION=&Previous
|
||||
TFRMVIEWER.MINEXT.CAPTION=&Next
|
||||
TFRMVIEWER.MISEPARATOR.CAPTION=-
|
||||
TFRMVIEWER.MISAVEPOS.CAPTION=&Save Position
|
||||
TFRMVIEWER.N1.CAPTION=-
|
||||
TFRMVIEWER.MIEXIT.CAPTION=E&xit
|
||||
TFRMVIEWER.MIEDIT.CAPTION=&Edit
|
||||
TFRMVIEWER.MICOPYTOCLIPBOARD.CAPTION=Copy To Clipboard
|
||||
TFRMVIEWER.MISELECTALL.CAPTION=Select All
|
||||
TFRMVIEWER.MIVIEW.CAPTION=&View
|
||||
TFRMVIEWER.MITEXT.CAPTION=Show as &Text
|
||||
TFRMVIEWER.MIBIN.CAPTION=Show as &Bin
|
||||
TFRMVIEWER.MIHEX.CAPTION=Show as &Hex
|
||||
TFRMVIEWER.MIWRAPTEXT.CAPTION=Show as &Wrap text
|
||||
TFRMVIEWER.MIDIV2.CAPTION=-
|
||||
TFRMVIEWER.MIGRAPHICS.CAPTION=Graphics
|
||||
TFRMVIEWER.MIDIV1.CAPTION=-
|
||||
TFRMVIEWER.MIPLUGINS.CAPTION=Plugins
|
||||
TFRMVIEWER.MENUITEM1.CAPTION=-
|
||||
TFRMVIEWER.MISEARCH.CAPTION=Search
|
||||
TFRMVIEWER.MIIMAGE.CAPTION=&Image
|
||||
TFRMVIEWER.MISTRETCH.CAPTION=Stretch
|
||||
TFRMVIEWER.MIABOUT.CAPTION=About
|
||||
TFRMVIEWER.MIABOUT2.CAPTION=About Viewer...
|
||||
|
|
|
|||
1129
fviewer.pas
1129
fviewer.pas
File diff suppressed because it is too large
Load diff
|
|
@ -25,7 +25,7 @@ unit uDetectStr;
|
|||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes, uTypes;//,LCLProc;
|
||||
SysUtils, Classes, uTypes,uFileOp,LCLProc;
|
||||
|
||||
|
||||
type
|
||||
|
|
@ -56,7 +56,8 @@ unit uDetectStr;
|
|||
|
||||
TParserControl = class
|
||||
public
|
||||
Function TestFileResult(ptr:PFileRecItem):boolean;
|
||||
Function TestFileResult(ptr:PFileRecItem):boolean; overload;
|
||||
function TestFileResult(AFileName: string): boolean; overload;
|
||||
private
|
||||
input,output,stack:array of tmathchar;
|
||||
fmathstring:string;
|
||||
|
|
@ -73,6 +74,7 @@ unit uDetectStr;
|
|||
function getprecedence(mop:TMathOperatortype):integer;
|
||||
function BooleanToStr(x:boolean):string;
|
||||
function StrToBoolean(s:string):boolean;
|
||||
|
||||
protected
|
||||
published
|
||||
property DetectStr:string read fmathstring write fmathstring;
|
||||
|
|
@ -81,6 +83,8 @@ unit uDetectStr;
|
|||
|
||||
implementation
|
||||
|
||||
|
||||
|
||||
function TParserControl.calculate(operand1,operand2,Aoperator:Tmathchar):string;
|
||||
var tmp:string;
|
||||
begin
|
||||
|
|
@ -142,17 +146,28 @@ begin
|
|||
end;}
|
||||
end;
|
||||
|
||||
function TParserControl.TestFileResult(ptr:PFileRecItem):boolean;
|
||||
begin
|
||||
function TParserControl.TestFileResult(ptr:PFileRecItem):boolean;
|
||||
begin
|
||||
fptr:=ptr;
|
||||
Result:=getresult;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TParserControl.getresult:boolean;
|
||||
var
|
||||
|
||||
function TParserControl.TestFileResult(AFileName: string): boolean;
|
||||
var fr:TFileRecItem;
|
||||
begin
|
||||
fr:=LoadFilebyName(AFileName);
|
||||
fptr:=@fr;
|
||||
DebugLn('fptr.sExt = '+fptr^.sExt);
|
||||
DebugLn('fptr.sExt = '+fr.sExt);
|
||||
Result:=getresult;
|
||||
end;
|
||||
|
||||
function TParserControl.getresult:boolean;
|
||||
var
|
||||
i:integer;
|
||||
tmp1,tmp2,tmp3:tmathchar;
|
||||
begin
|
||||
begin
|
||||
if fmathstring='' then
|
||||
begin
|
||||
Result:=true;
|
||||
|
|
|
|||
482
ufileop.pas
482
ufileop.pas
|
|
@ -1,195 +1,287 @@
|
|||
{
|
||||
Seksi Commander
|
||||
----------------------------
|
||||
Licence : GNU GPL v 2.0
|
||||
Author : radek.cervinka@centrum.cz
|
||||
|
||||
contributors:
|
||||
|
||||
Peter Cernoch 2002, pcernoch@volny.cz
|
||||
|
||||
Martin Matusu, xmat@volny.cz
|
||||
|
||||
Alexander Koblov (Alexx2000@mail.ru)
|
||||
|
||||
}
|
||||
|
||||
unit uFileOp;
|
||||
{$mode objfpc}{$H+}
|
||||
interface
|
||||
uses
|
||||
uFileList, uTypes;
|
||||
|
||||
Function LoadFilesbyDir(const sDir:String; fl:TFileList):Boolean;
|
||||
Function AttrToStr(iAttr:Cardinal):String;
|
||||
//Function IsDirByName(const sName:String):Boolean;
|
||||
|
||||
const
|
||||
__S_IFMT = $F000;
|
||||
__S_IFDIR = $4000;
|
||||
__S_IFCHR = $2000;
|
||||
__S_IFBLK = $6000;
|
||||
__S_IFREG = $8000;
|
||||
__S_IFIFO = $1000;
|
||||
__S_IFLNK = $A000;
|
||||
__S_IFSOCK = $C000;
|
||||
|
||||
__S_ISUID = $800;
|
||||
__S_ISGID = $400;
|
||||
__S_ISVTX = $200;
|
||||
__S_IREAD = $100;
|
||||
__S_IWRITE = $80;
|
||||
__S_IEXEC = $40;
|
||||
|
||||
S_ISUID = __S_ISUID;
|
||||
S_ISGID = __S_ISGID;
|
||||
S_ISVTX = __S_ISVTX;
|
||||
|
||||
implementation
|
||||
uses
|
||||
SysUtils, uFileProcs, uFindEx, uGlobs, uOSUtils {$IFNDEF WIN32}, uUsersGroups, Unix, BaseUnix{$ENDIF};
|
||||
|
||||
{$IFNDEF WIN32} // *nix
|
||||
Function IsDirByName(const sName:String):Boolean;
|
||||
var
|
||||
stat:stat64;
|
||||
begin
|
||||
fpStat64(PChar(sName),stat);
|
||||
Result:=FPS_ISDIR(stat.st_mode);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
Function LoadFilesbyDir(const sDir:String; fl:TFileList):Boolean;
|
||||
var
|
||||
fr:TFileRecItem;
|
||||
sr:TSearchRec;
|
||||
sb: stat64; //buffer for stat64
|
||||
|
||||
begin
|
||||
// writeln('Enter LoadFilesbyDir');
|
||||
Result:=True;
|
||||
fl.Clear;
|
||||
fl.CurrentDirectory := IncludeTrailingPathDelimiter(sDir);
|
||||
if FindFirst('*',faAnyFile,sr)<>0 then
|
||||
begin
|
||||
with fr do // append "blank dir"
|
||||
begin
|
||||
fr.sName:='..';
|
||||
fr.sNameNoExt:='..';
|
||||
fr.sExt:='';
|
||||
fr.iDirSize:=0;
|
||||
fr.iMode:=0;
|
||||
fr.bExecutable:=False;
|
||||
fr.bSysFile := False;
|
||||
fr.bIsLink:=False;
|
||||
fr.sLinkTo:='';
|
||||
fr.bLinkIsDir:=False;
|
||||
fr.bSelected:=False;
|
||||
fr.sModeStr:='';
|
||||
fr.iSize:=0;
|
||||
fl.AddItem(@fr);
|
||||
end;
|
||||
FindClose(sr);
|
||||
Exit;
|
||||
end;
|
||||
repeat
|
||||
if sr.Name='.' then Continue;
|
||||
if ((sDir=DirectorySeparator) or (sDir=(ExtractFileDrive(sDir)+PathDelim))) and (sr.Name='..') then Continue;
|
||||
if sr.Name='' then Continue;
|
||||
|
||||
{$IFNDEF WIN32} // *nix
|
||||
Fplstat64(sr.Name,sb);
|
||||
fr.iSize:=sb.st_size;
|
||||
|
||||
fr.iOwner:=sb.st_uid; //UID
|
||||
fr.iGroup:=sb.st_gid; //GID
|
||||
fr.sOwner:=UIDToStr(fr.iOwner);
|
||||
fr.sGroup:=GIDToStr(fr.iGroup);
|
||||
{/mate}
|
||||
fr.iMode:=sb.st_mode;
|
||||
fr.bSysFile := (sr.Name[1] = '.') and (sr.Name <> '..');
|
||||
fr.fTimeI:= FileDateToDateTime(sb.st_mtime); // EncodeDate (1970, 1, 1) + (sr.Time / 86400.0);
|
||||
{$ELSE} // Windows
|
||||
fr.iSize:= sr.Size;
|
||||
fr.iMode:= sr.Attr;
|
||||
fr.bSysFile := Boolean(sr.Attr and faSysFile) or Boolean(sr.Attr and faHidden);
|
||||
fr.fTimeI:= FileDateToDateTime(sr.Time);
|
||||
{$ENDIF}
|
||||
|
||||
if FPS_ISDIR(fr.iMode) or (sr.Name[1]='.') then //!!!!!
|
||||
fr.sExt:=''
|
||||
else
|
||||
fr.sExt:=ExtractFileExt(sr.Name);
|
||||
fr.sNameNoExt:=Copy(sr.Name,1,length(sr.Name)-length(fr.sExt));
|
||||
fr.sName:=sr.Name;
|
||||
|
||||
fr.sTime := FormatDateTime(gDateTimeFormat, fr.fTimeI);
|
||||
fr.bIsLink:=FPS_ISLNK(fr.iMode);
|
||||
fr.sLinkTo:='';
|
||||
fr.iDirSize:=0;
|
||||
|
||||
if fr.bIsLink then
|
||||
begin
|
||||
fr.sLinkTo:=ReadSymLink(sr.Name);
|
||||
end;
|
||||
{$IFDEF UNIX} // *nix
|
||||
if fr.bIsLink then
|
||||
fr.bLinkIsDir:=IsDirByName(fr.sLinkTo)
|
||||
else
|
||||
fr.bLinkIsDir:=False;
|
||||
fr.bExecutable:=(not FPS_ISDIR(fr.iMode)) and (fr.iMode AND (S_IXUSR OR S_IXGRP OR S_IXOTH)>0);
|
||||
{$ELSE} // Windows for ShellExecute
|
||||
fr.bExecutable:= not FPS_ISDIR(fr.iMode);
|
||||
if fr.bIsLink then
|
||||
fr.bLinkIsDir:=True //Because symbolic link works on Windows 2k/XP for directories only
|
||||
else
|
||||
fr.bLinkIsDir:=False;
|
||||
{$ENDIF}
|
||||
fr.bSelected:=False;
|
||||
fr.sModeStr:=AttrToStr(fr.iMode);
|
||||
fr.sPath := sDir;
|
||||
fl.AddItem(@fr);
|
||||
until FindNext(sr)<>0;
|
||||
FindClose(sr);
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
Function AttrToStr(iAttr:Cardinal):String;
|
||||
begin
|
||||
Result := '----------';
|
||||
|
||||
{$IFDEF WIN32}
|
||||
|
||||
if FPS_ISDIR(iAttr) then Result[1]:='d';
|
||||
if FPS_ISLNK(iAttr) then Result[1]:='l';
|
||||
|
||||
if Boolean(iAttr and $01) then Result[2] := 'r';
|
||||
if Boolean(iAttr and $20) then Result[3] := 'a';
|
||||
if Boolean(iAttr and $02) then Result[4] := 'h';
|
||||
if Boolean(iAttr and $04) then Result[5] := 's';
|
||||
if Boolean(iAttr and $08) then Result[6] := 'v';
|
||||
|
||||
{$ELSE}
|
||||
if FPS_ISDIR(iAttr) then Result[1]:='d';
|
||||
if FPS_ISLNK(iAttr) then Result[1]:='l';
|
||||
if FPS_ISSOCK(iAttr) then Result[1]:='s';
|
||||
if FPS_ISFIFO(iAttr) then Result[1]:='f';
|
||||
if FPS_ISBLK(iAttr) then Result[1]:='b';
|
||||
if FPS_ISCHR(iAttr) then Result[1]:='c';
|
||||
|
||||
if ((iAttr AND S_IRUSR) = S_IRUSR) then Result[2] := 'r';
|
||||
if ((iAttr AND S_IWUSR) = S_IWUSR) then Result[3] := 'w';
|
||||
if ((iAttr AND S_IXUSR) = S_IXUSR) then Result[4] := 'x';
|
||||
if ((iAttr AND S_IRGRP) = S_IRGRP) then Result[5] := 'r';
|
||||
if ((iAttr AND S_IWGRP) = S_IWGRP) then Result[6] := 'w';
|
||||
if ((iAttr AND S_IXGRP) = S_IXGRP) then Result[7] := 'x';
|
||||
if ((iAttr AND S_IROTH) = S_IROTH) then Result[8] := 'r';
|
||||
if ((iAttr AND S_IWOTH) = S_IWOTH) then Result[9] := 'w';
|
||||
if ((iAttr AND S_IXOTH) = S_IXOTH) then Result[10] := 'x';
|
||||
|
||||
if ((iAttr AND S_ISUID) = S_ISUID) then Result[4] := 's';
|
||||
if ((iAttr AND S_ISGID) = S_ISGID) then Result[7] := 's';
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
end.
|
||||
{
|
||||
Seksi Commander
|
||||
----------------------------
|
||||
Licence : GNU GPL v 2.0
|
||||
Author : radek.cervinka@centrum.cz
|
||||
|
||||
contributors:
|
||||
|
||||
Peter Cernoch 2002, pcernoch@volny.cz
|
||||
|
||||
Martin Matusu, xmat@volny.cz
|
||||
|
||||
Alexander Koblov (Alexx2000@mail.ru)
|
||||
|
||||
}
|
||||
|
||||
unit uFileOp;
|
||||
{$mode objfpc}{$H+}
|
||||
interface
|
||||
uses
|
||||
uFileList, uTypes,lclproc;
|
||||
|
||||
Function LoadFilebyName(const sFileName:String):TFileRecItem;
|
||||
Function LoadFilesbyDir(const sDir:String; fl:TFileList):Boolean;
|
||||
Function AttrToStr(iAttr:Cardinal):String;
|
||||
|
||||
//Function IsDirByName(const sName:String):Boolean;
|
||||
|
||||
const
|
||||
__S_IFMT = $F000;
|
||||
__S_IFDIR = $4000;
|
||||
__S_IFCHR = $2000;
|
||||
__S_IFBLK = $6000;
|
||||
__S_IFREG = $8000;
|
||||
__S_IFIFO = $1000;
|
||||
__S_IFLNK = $A000;
|
||||
__S_IFSOCK = $C000;
|
||||
|
||||
__S_ISUID = $800;
|
||||
__S_ISGID = $400;
|
||||
__S_ISVTX = $200;
|
||||
__S_IREAD = $100;
|
||||
__S_IWRITE = $80;
|
||||
__S_IEXEC = $40;
|
||||
|
||||
S_ISUID = __S_ISUID;
|
||||
S_ISGID = __S_ISGID;
|
||||
S_ISVTX = __S_ISVTX;
|
||||
|
||||
implementation
|
||||
uses
|
||||
SysUtils, uFileProcs, uFindEx, uGlobs, uOSUtils {$IFNDEF WIN32}, uUsersGroups, Unix, BaseUnix{$ENDIF};
|
||||
|
||||
{$IFNDEF WIN32} // *nix
|
||||
Function IsDirByName(const sName:String):Boolean;
|
||||
var
|
||||
stat:stat64;
|
||||
begin
|
||||
fpStat64(PChar(sName),stat);
|
||||
Result:=FPS_ISDIR(stat.st_mode);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
Function LoadFilebyName(const sFileName:String):TFileRecItem;
|
||||
var
|
||||
fr:TFileRecItem;
|
||||
sr:TSearchRec;
|
||||
sb: stat64; //buffer for stat64
|
||||
|
||||
begin
|
||||
// writeln('Enter LoadFilesbyDir');
|
||||
DebugLn('LoadFileByName SFileName = '+sFileName);
|
||||
if FindFirst(sFileName,faAnyFile,sr)<>0 then
|
||||
begin DebugLn('FindFirst <> 0');
|
||||
with fr do // append "blank dir"
|
||||
begin
|
||||
fr.sName:='';
|
||||
fr.sNameNoExt:='';
|
||||
fr.sExt:='';
|
||||
fr.iDirSize:=0;
|
||||
fr.iMode:=0;
|
||||
fr.bExecutable:=False;
|
||||
fr.bSysFile := False;
|
||||
fr.bIsLink:=False;
|
||||
fr.sLinkTo:='';
|
||||
fr.bLinkIsDir:=False;
|
||||
fr.bSelected:=False;
|
||||
fr.sModeStr:='';
|
||||
fr.iSize:=0;
|
||||
Result:=fr
|
||||
end;
|
||||
FindClose(sr);
|
||||
Exit;
|
||||
end;
|
||||
// repeat
|
||||
|
||||
{$IFNDEF WIN32} // *nix
|
||||
Fplstat64(sr.Name,sb);
|
||||
fr.iSize:=sb.st_size;
|
||||
|
||||
fr.iOwner:=sb.st_uid; //UID
|
||||
fr.iGroup:=sb.st_gid; //GID
|
||||
fr.sOwner:=UIDToStr(fr.iOwner);
|
||||
fr.sGroup:=GIDToStr(fr.iGroup);
|
||||
{/mate}
|
||||
fr.iMode:=sb.st_mode;
|
||||
fr.bSysFile := (sr.Name[1] = '.') and (sr.Name <> '..');
|
||||
fr.fTimeI:= FileDateToDateTime(sb.st_mtime); // EncodeDate (1970, 1, 1) + (sr.Time / 86400.0);
|
||||
{$ELSE} // Windows
|
||||
fr.iSize:= sr.Size;
|
||||
fr.iMode:= sr.Attr;
|
||||
fr.bSysFile := Boolean(sr.Attr and faSysFile) or Boolean(sr.Attr and faHidden);
|
||||
fr.fTimeI:= FileDateToDateTime(sr.Time);
|
||||
{$ENDIF}
|
||||
|
||||
if FPS_ISDIR(fr.iMode) or (sr.Name[1]='.') then //!!!!!
|
||||
fr.sExt:=''
|
||||
else
|
||||
fr.sExt:=ExtractFileExt(sr.Name);
|
||||
fr.sNameNoExt:=Copy(sr.Name,1,length(sr.Name)-length(fr.sExt));
|
||||
fr.sName:=sr.Name;
|
||||
|
||||
fr.sTime := FormatDateTime(gDateTimeFormat, fr.fTimeI);
|
||||
fr.bIsLink:=FPS_ISLNK(fr.iMode);
|
||||
fr.sLinkTo:='';
|
||||
fr.iDirSize:=0;
|
||||
|
||||
if fr.bIsLink then
|
||||
begin
|
||||
fr.sLinkTo:=ReadSymLink(sr.Name);
|
||||
end;
|
||||
{$IFDEF UNIX} // *nix
|
||||
if fr.bIsLink then
|
||||
fr.bLinkIsDir:=IsDirByName(fr.sLinkTo)
|
||||
else
|
||||
fr.bLinkIsDir:=False;
|
||||
fr.bExecutable:=(not FPS_ISDIR(fr.iMode)) and (fr.iMode AND (S_IXUSR OR S_IXGRP OR S_IXOTH)>0);
|
||||
{$ELSE} // Windows for ShellExecute
|
||||
fr.bExecutable:= not FPS_ISDIR(fr.iMode);
|
||||
if fr.bIsLink then
|
||||
fr.bLinkIsDir:=True //Because symbolic link works on Windows 2k/XP for directories only
|
||||
else
|
||||
fr.bLinkIsDir:=False;
|
||||
{$ENDIF}
|
||||
fr.bSelected:=False;
|
||||
fr.sModeStr:=AttrToStr(fr.iMode);
|
||||
fr.sPath := ExtractFilePath(fr.sName);
|
||||
Result:=fr;
|
||||
// until FindNext(sr)<>0;
|
||||
FindClose(sr);
|
||||
end;
|
||||
|
||||
|
||||
Function LoadFilesbyDir(const sDir:String; fl:TFileList):Boolean;
|
||||
var
|
||||
fr:TFileRecItem;
|
||||
sr:TSearchRec;
|
||||
sb: stat64; //buffer for stat64
|
||||
|
||||
begin
|
||||
// writeln('Enter LoadFilesbyDir');
|
||||
Result:=True;
|
||||
fl.Clear;
|
||||
fl.CurrentDirectory := IncludeTrailingPathDelimiter(sDir);
|
||||
if FindFirst('*',faAnyFile,sr)<>0 then
|
||||
begin
|
||||
with fr do // append "blank dir"
|
||||
begin
|
||||
fr.sName:='..';
|
||||
fr.sNameNoExt:='..';
|
||||
fr.sExt:='';
|
||||
fr.iDirSize:=0;
|
||||
fr.iMode:=0;
|
||||
fr.bExecutable:=False;
|
||||
fr.bSysFile := False;
|
||||
fr.bIsLink:=False;
|
||||
fr.sLinkTo:='';
|
||||
fr.bLinkIsDir:=False;
|
||||
fr.bSelected:=False;
|
||||
fr.sModeStr:='';
|
||||
fr.iSize:=0;
|
||||
fl.AddItem(@fr);
|
||||
end;
|
||||
FindClose(sr);
|
||||
Exit;
|
||||
end;
|
||||
repeat
|
||||
if sr.Name='.' then Continue;
|
||||
if ((sDir=DirectorySeparator) or (sDir=(ExtractFileDrive(sDir)+PathDelim))) and (sr.Name='..') then Continue;
|
||||
if sr.Name='' then Continue;
|
||||
|
||||
{$IFNDEF WIN32} // *nix
|
||||
Fplstat64(sr.Name,sb);
|
||||
fr.iSize:=sb.st_size;
|
||||
|
||||
fr.iOwner:=sb.st_uid; //UID
|
||||
fr.iGroup:=sb.st_gid; //GID
|
||||
fr.sOwner:=UIDToStr(fr.iOwner);
|
||||
fr.sGroup:=GIDToStr(fr.iGroup);
|
||||
{/mate}
|
||||
fr.iMode:=sb.st_mode;
|
||||
fr.bSysFile := (sr.Name[1] = '.') and (sr.Name <> '..');
|
||||
fr.fTimeI:= FileDateToDateTime(sb.st_mtime); // EncodeDate (1970, 1, 1) + (sr.Time / 86400.0);
|
||||
{$ELSE} // Windows
|
||||
fr.iSize:= sr.Size;
|
||||
fr.iMode:= sr.Attr;
|
||||
fr.bSysFile := Boolean(sr.Attr and faSysFile) or Boolean(sr.Attr and faHidden);
|
||||
fr.fTimeI:= FileDateToDateTime(sr.Time);
|
||||
{$ENDIF}
|
||||
|
||||
if FPS_ISDIR(fr.iMode) or (sr.Name[1]='.') then //!!!!!
|
||||
fr.sExt:=''
|
||||
else
|
||||
fr.sExt:=ExtractFileExt(sr.Name);
|
||||
fr.sNameNoExt:=Copy(sr.Name,1,length(sr.Name)-length(fr.sExt));
|
||||
fr.sName:=sr.Name;
|
||||
|
||||
fr.sTime := FormatDateTime(gDateTimeFormat, fr.fTimeI);
|
||||
fr.bIsLink:=FPS_ISLNK(fr.iMode);
|
||||
fr.sLinkTo:='';
|
||||
fr.iDirSize:=0;
|
||||
|
||||
if fr.bIsLink then
|
||||
begin
|
||||
fr.sLinkTo:=ReadSymLink(sr.Name);
|
||||
end;
|
||||
{$IFDEF UNIX} // *nix
|
||||
if fr.bIsLink then
|
||||
fr.bLinkIsDir:=IsDirByName(fr.sLinkTo)
|
||||
else
|
||||
fr.bLinkIsDir:=False;
|
||||
fr.bExecutable:=(not FPS_ISDIR(fr.iMode)) and (fr.iMode AND (S_IXUSR OR S_IXGRP OR S_IXOTH)>0);
|
||||
{$ELSE} // Windows for ShellExecute
|
||||
fr.bExecutable:= not FPS_ISDIR(fr.iMode);
|
||||
if fr.bIsLink then
|
||||
fr.bLinkIsDir:=True //Because symbolic link works on Windows 2k/XP for directories only
|
||||
else
|
||||
fr.bLinkIsDir:=False;
|
||||
{$ENDIF}
|
||||
fr.bSelected:=False;
|
||||
fr.sModeStr:=AttrToStr(fr.iMode);
|
||||
fr.sPath := sDir;
|
||||
fl.AddItem(@fr);
|
||||
until FindNext(sr)<>0;
|
||||
FindClose(sr);
|
||||
Result:=True;
|
||||
end;
|
||||
|
||||
Function AttrToStr(iAttr:Cardinal):String;
|
||||
begin
|
||||
Result := '----------';
|
||||
|
||||
{$IFDEF WIN32}
|
||||
|
||||
if FPS_ISDIR(iAttr) then Result[1]:='d';
|
||||
if FPS_ISLNK(iAttr) then Result[1]:='l';
|
||||
|
||||
if Boolean(iAttr and $01) then Result[2] := 'r';
|
||||
if Boolean(iAttr and $20) then Result[3] := 'a';
|
||||
if Boolean(iAttr and $02) then Result[4] := 'h';
|
||||
if Boolean(iAttr and $04) then Result[5] := 's';
|
||||
if Boolean(iAttr and $08) then Result[6] := 'v';
|
||||
|
||||
{$ELSE}
|
||||
if FPS_ISDIR(iAttr) then Result[1]:='d';
|
||||
if FPS_ISLNK(iAttr) then Result[1]:='l';
|
||||
if FPS_ISSOCK(iAttr) then Result[1]:='s';
|
||||
if FPS_ISFIFO(iAttr) then Result[1]:='f';
|
||||
if FPS_ISBLK(iAttr) then Result[1]:='b';
|
||||
if FPS_ISCHR(iAttr) then Result[1]:='c';
|
||||
|
||||
if ((iAttr AND S_IRUSR) = S_IRUSR) then Result[2] := 'r';
|
||||
if ((iAttr AND S_IWUSR) = S_IWUSR) then Result[3] := 'w';
|
||||
if ((iAttr AND S_IXUSR) = S_IXUSR) then Result[4] := 'x';
|
||||
if ((iAttr AND S_IRGRP) = S_IRGRP) then Result[5] := 'r';
|
||||
if ((iAttr AND S_IWGRP) = S_IWGRP) then Result[6] := 'w';
|
||||
if ((iAttr AND S_IXGRP) = S_IXGRP) then Result[7] := 'x';
|
||||
if ((iAttr AND S_IROTH) = S_IROTH) then Result[8] := 'r';
|
||||
if ((iAttr AND S_IWOTH) = S_IWOTH) then Result[9] := 'w';
|
||||
if ((iAttr AND S_IXOTH) = S_IXOTH) then Result[10] := 'x';
|
||||
|
||||
if ((iAttr AND S_ISUID) = S_ISUID) then Result[4] := 's';
|
||||
if ((iAttr AND S_ISGID) = S_ISGID) then Result[7] := 's';
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
|||
|
|
@ -26,11 +26,16 @@
|
|||
unit uwlxmodule;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
{$I interface.inc}
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,dynlibs,uDetectStr,uwlxprototypes,WLXPlugin,Inifiles,uDCUtils,uGlobs{,LCLProc};
|
||||
Classes, SysUtils, dynlibs, uDetectStr, uwlxprototypes, WLXPlugin,
|
||||
Inifiles, uDCUtils, uGlobs,LCLProc
|
||||
{$IFDEF GTK}
|
||||
,gtk,glib,gdk
|
||||
{$ENDIF}
|
||||
;
|
||||
|
||||
type
|
||||
|
||||
|
|
@ -81,6 +86,9 @@ type
|
|||
function CallListSearchText(SearchString: string; SearchParameter: integer): integer;
|
||||
function CallListSendCommand(Command, Parameter: integer): integer;
|
||||
//---------------------
|
||||
// function FileParamVSDetectStr(ptr:PFileRecItem):boolean; overload;
|
||||
function FileParamVSDetectStr(AFileName:String):boolean; //overload;
|
||||
//---------------------
|
||||
property IsLoaded:boolean read GIsLoaded;
|
||||
property ModuleHandle:TLibHandle read FModuleHandle write FModuleHandle;
|
||||
property Force:boolean read FForce write FForce;
|
||||
|
|
@ -108,23 +116,42 @@ type
|
|||
function Add(Item:TWLXModule):integer;overload;
|
||||
function Add(FileName:string):integer;overload;
|
||||
function Add(AName,FileName,DetectStr:string):integer;overload;
|
||||
|
||||
//---------------------
|
||||
function IsLoaded(AName:String):Boolean;overload;
|
||||
function IsLoaded(Index: integer):Boolean;overload;
|
||||
function LoadModule(AName:String):Boolean; overload;
|
||||
function LoadModule(Index: integer): Boolean; overload;
|
||||
|
||||
//---------------------
|
||||
function GetWLxModule(Index:integer):TWLXModule;overload;
|
||||
function GetWlxModule(AName:string):TWLXModule;overload;
|
||||
//---------------------
|
||||
//---------------------
|
||||
//property WlxList:TStringList read Flist;
|
||||
property Count:integer read GetCount;
|
||||
end;
|
||||
|
||||
|
||||
Function WlxPrepareContainer(Ahandle:THandle):boolean;
|
||||
|
||||
implementation
|
||||
|
||||
function WlxPrepareContainer(Ahandle: THandle): boolean;
|
||||
{$IFDEF GTK}
|
||||
var lst:PGList;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF GTK}
|
||||
//Hide controls from our gtk container
|
||||
lst:=gtk_container_children(GTK_CONTAINER(PGtkwidget(AHandle)));
|
||||
if lst<>nil then
|
||||
begin
|
||||
gtk_widget_hide(PGtkWidget(lst^.data));
|
||||
Result:=true;
|
||||
end else Result:=false;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
end;
|
||||
|
||||
{ TWLXModule }
|
||||
|
||||
function TWLXModule.GIsLoaded: boolean;
|
||||
|
|
@ -262,6 +289,20 @@ begin
|
|||
else Result:=LISTPLUGIN_ERROR;
|
||||
end;
|
||||
|
||||
{function TWLXModule.FileParamVSDetectStr(ptr: PFileRecItem): boolean;
|
||||
begin
|
||||
FParser.DetectStr:=Self.DetectStr;
|
||||
Result:=FParser.TestFileResult(ptr);
|
||||
end;}
|
||||
|
||||
function TWLXModule.FileParamVSDetectStr(AFileName: String): boolean;
|
||||
begin
|
||||
FParser.DetectStr:=Self.DetectStr;
|
||||
DebugLn('DetectStr = '+FParser.DetectStr);
|
||||
DebugLn('AFileName = '+AFileName);
|
||||
Result:=FParser.TestFileResult(AFileName);
|
||||
end;
|
||||
|
||||
function TWLXModule.CallListPrint(FileToPrint, DefPrinter: string; PrintFlags: integer; var Margins: trect): integer;
|
||||
begin
|
||||
if Assigned(ListPrint) then
|
||||
|
|
@ -475,6 +516,5 @@ begin
|
|||
Result:=TWLXModule(Flist.Objects[tmp]);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue