Fix: Bug [ 1658668 ] действия по ассоциации в системе

This commit is contained in:
Alexander Koblov 2007-02-16 22:52:22 +00:00
commit 0d261743a7
9 changed files with 112 additions and 158 deletions

BIN
XP.or

Binary file not shown.

View file

@ -23,7 +23,6 @@ uses
uConstants,
uTypes,
framePanel,
uExecCmd,
uFileOpThread,
uFileProcs,
fFileOpDlg,

View file

@ -298,7 +298,7 @@ implementation
uses
uTypes, fAbout, uGlobs, uLng, fOptions,{ fViewer,}fbtnchangedlg, fconfigtoolbar,
uCopyThread, uFileList, uDeleteThread, uExecCmd,
uCopyThread, uFileList, uDeleteThread,
fMkDir, fCopyDlg, fCompareFiles,{ fEditor,} fMoveDlg, uMoveThread, uShowMsg,
fFindDlg, uSpaceThread, fHotDir, fSymLink, fHardLink,
fMultiRename, uShowForm, uGlobsPaths, fFileOpDlg, fMsg,

Binary file not shown.

View file

@ -66,6 +66,7 @@ type
function FPS_ISDIR(iAttr:Cardinal) : Boolean;
function FPS_ISLNK(iAttr:Cardinal) : Boolean;
function ExecCmdFork(const sCmd:String):Integer;
function CreateHardLink(Path, LinkName: string) : Boolean;
function CreateSymLink(Path, LinkName: string) : Boolean;
function GetHomeDir : String;
@ -76,6 +77,9 @@ function GetAllDrives : TList;
implementation
uses
Process;
(*Is Directory*)
function FPS_ISDIR(iAttr:Cardinal) : Boolean;
@ -102,6 +106,29 @@ Result := BaseUnix.FPS_ISLNK(iAttr);
end;
{$ENDIF}
(* Execute external commands *)
function ExecCmdFork(const sCmd:String):Integer;
{$IFDEF UNIX}
var
AProcess: TProcess;
Begin
try
AProcess := TProcess.Create(nil);
AProcess.CommandLine := sCmd;
AProcess.Execute;
AProcess.Free;
Result:=0;
except
Result:=-1;
end;
end;
{$ELSE}
begin
ShellExecute(0, 'open',PChar(sCmd), nil, PChar(ExtractFilePath(sCmd)), SW_SHOW);
end;
{$ENDIF}
function CreateHardLink(Path, LinkName: string) : Boolean;
{$IFDEF WIN32}
begin

View file

@ -1,75 +0,0 @@
unit uExecCmd;
{
Execute external commands (and get there output) .
Part of Commander, realised under GNU GPL 2. (C)opyright 2003
Authors:
Radek Cervinka, radek.cervinka@centrum.cz
contributors:
Alexander Koblov (Alexx2000@mail.ru)
}
{$H+}
interface
uses
Classes;
function ExecCmdInput(const sCmd:String; var lsListing:TStringlist):Boolean;
function ExecCmdFork(const sCmd:String):Integer;
implementation
uses
SysUtils, Process;
function ExecCmdFork(const sCmd:String):Integer;
var
AProcess: TProcess;
Begin
AProcess := TProcess.Create(nil);
AProcess.CommandLine := sCmd;
AProcess.Execute;
AProcess.Free;
Result:=0;
end;
function ExecCmdInput(const sCmd:String; var lsListing:TStringlist):Boolean;
{var
OutPut:PIOFile;
rb:Integer;
sDummy:String;
c:Char;}
// i:Integer;
begin
assert(assigned(lsListing),'ExecCmdInput: lsListing=nil');
Result:=False;
// writeln(sCmd);
// replace with frepascal popen
Exit;
{ lsListing.Clear;
OutPut:=popen(PChar(sCmd),'r');
if not assigned(output) then Exit;
sDummy:='';
rb:=1;
while (FEOF(OutPut)=0) and (rb=1) do
begin
rb:=fread(@c, 1, 1, output);
if (c=#$0A) or (rb=0) then
begin
if sDummy<>'' then
lsListing.Add(sDummy);
sDummy:='';
end
else
sDummy:=sDummy+c;
end;
pclose(output);
Result:=True;}
{ for i:=0 to lsListing.Count-1 do
writeln(lsListing.Strings[i]);}
end;
end.

View file

@ -123,7 +123,7 @@ begin
fr.bIsLink:=FPS_ISLNK(fr.iMode);
fr.sLinkTo:='';
fr.iDirSize:=0;
{$IFNDEF WIN32} // *nix
{$IFDEF UNIX} // *nix
if fr.bIsLink then
begin
fr.sLinkTo:=fpReadLink(PChar(sr.Name));
@ -133,6 +133,9 @@ begin
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);
fr.bLinkIsDir:=False;
{$ENDIF}
fr.bSelected:=False;
fr.sModeStr:=AttrToStr(fr.iMode);

View file

@ -92,7 +92,7 @@ type
implementation
uses
SysUtils, uFileOp, uGlobs, uExecCmd,
SysUtils, uFileOp, uGlobs,
uShowMsg, Controls, uFilter, uConv, uLng, uShowForm,
uOSUtils{$IFNDEF WIN32}, BaseUnix, Unix, UnixType{$ELSE}, Windows{$ENDIF};
@ -344,8 +344,8 @@ begin
begin
System.ChDir(ActiveDir);
LastActive:=sName;
ExecuteFile('./'+sName, False);
// uExecCmd.ExecCmdFork('./'+sName);
ExecuteFile(sName, False);
// ExecCmdFork('./'+sName);
LoadPanel;
Exit;
end;
@ -355,10 +355,10 @@ end;
procedure TFilePanel.ExecuteFile(const sName:String; bTerm:Boolean);
begin
if bTerm then
// uExecCmd.ExecCmdFork(Format(gTerm,[sName+'|less']))
uExecCmd.ExecCmdFork(Format(gTerm,[sName+';echo ''Press Enter'';read']))
// ExecCmdFork(Format(gTerm,[sName+'|less']))
ExecCmdFork(Format(gTerm,[sName+';echo ''Press Enter'';read']))
else
uExecCmd.ExecCmdFork(sName);
ExecCmdFork(sName);
end;
procedure TFilePanel.MarkAllFiles(bMarked:Boolean);
@ -595,7 +595,7 @@ begin
System.ChDir(ActiveDir);
// LastActive:=sName;
writeln(sCmd);
uExecCmd.ExecCmdFork(sCmd);
ExecCmdFork(sCmd);
// LoadPanel;
end;

View file

@ -1,73 +1,73 @@
{
Seksi Commander
----------------------------
Licence : GNU GPL v 2.0
Author : radek.cervinka@centrum.cz
showing editor or viewer by configuration dialog
contributors:
}
unit uShowForm;
interface
uses
Classes;
Function ShowEditorByGlob(const sFileName:String):Boolean;
Function ShowViewerByGlob(const sFileName:String):Boolean;
Function ShowViewerByGlobList(list:TStringList):Boolean;
implementation
uses
SysUtils,
uGlobs, uExecCmd, fEditor, fViewer;
Function ShowEditorByGlob(const sFileName:String):Boolean;
begin
if gUseExtEdit then
ExecCmdFork(Format(gExtEdit,[sFileName]))
else
ShowEditor(sFileName);
Result:=True;
end;
Function ShowViewerByGlob(const sFileName:String):Boolean;
var
sl:TStringList;
begin
if gUseExtView then
ExecCmdFork(Format(gExtView,[sFileName]))
else
begin
sl:=TStringList.Create;
try
sl.Add(sFileName);
ShowViewer(sl);
finally
FreeAndNil(sl);
end;
end;
Result:=True;
end;
Function ShowViewerByGlobList(list:TStringList):Boolean;
var
i:Integer;
begin
if gUseExtView then
begin
writeln('ShowViewerByGlobList - Use ExtView ');
for i:=0 to list.Count-1 do
ExecCmdFork(Format(gExtView,[List.Strings[i]]))
end
else
ShowViewer(list);
Result:=True;
end;
end.
{
Seksi Commander
----------------------------
Licence : GNU GPL v 2.0
Author : radek.cervinka@centrum.cz
showing editor or viewer by configuration dialog
contributors:
}
unit uShowForm;
interface
uses
Classes;
Function ShowEditorByGlob(const sFileName:String):Boolean;
Function ShowViewerByGlob(const sFileName:String):Boolean;
Function ShowViewerByGlobList(list:TStringList):Boolean;
implementation
uses
SysUtils,
uGlobs, uOSUtils, fEditor, fViewer;
Function ShowEditorByGlob(const sFileName:String):Boolean;
begin
if gUseExtEdit then
ExecCmdFork(Format(gExtEdit,[sFileName]))
else
ShowEditor(sFileName);
Result:=True;
end;
Function ShowViewerByGlob(const sFileName:String):Boolean;
var
sl:TStringList;
begin
if gUseExtView then
ExecCmdFork(Format(gExtView,[sFileName]))
else
begin
sl:=TStringList.Create;
try
sl.Add(sFileName);
ShowViewer(sl);
finally
FreeAndNil(sl);
end;
end;
Result:=True;
end;
Function ShowViewerByGlobList(list:TStringList):Boolean;
var
i:Integer;
begin
if gUseExtView then
begin
writeln('ShowViewerByGlobList - Use ExtView ');
for i:=0 to list.Count-1 do
ExecCmdFork(Format(gExtView,[List.Strings[i]]))
end
else
ShowViewer(list);
Result:=True;
end;
end.