doublecmd/fsymlink.pas

73 lines
1.5 KiB
ObjectPascal

unit fSymLink;
interface
uses
LResources,
SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TfrmSymLink = class(TForm)
lblNew: TLabel;
lblDst: TLabel;
edtNew: TEdit;
edtDst: TEdit;
btnOK: TBitBtn;
btnCancel: TBitBtn;
procedure btnOKClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function ShowSymLinkForm(const sNew, sDst:String): Boolean;
implementation
uses
uLng, uGlobs, uLog, uShowMsg, uOSUtils;
function ShowSymLinkForm(const sNew, sDst:String): Boolean;
begin
with TfrmSymLink.Create(Application) do
begin
try
edtDst.Text:=sDst;
edtNew.Text:=sNew;
Result:= (ShowModal = mrOK);
finally
Free;
end;
end;
end;
procedure TfrmSymLink.btnOKClick(Sender: TObject);
var
sSrc,sDst:String;
begin
inherited;
sSrc:=edtNew.Text;
sDst:=edtDst.Text;
if CreateSymLink(sSrc, sDst) then
begin
// write log
if (log_cp_mv_ln in gLogOptions) and (log_success in gLogOptions) then
logWrite(Format(rsMsgLogSuccess+rsMsgLogSymLink,[sSrc+' -> '+sDst]), lmtSuccess);
end
else
begin
// write log
if (log_cp_mv_ln in gLogOptions) and (log_errors in gLogOptions) then
logWrite(Format(rsMsgLogError+rsMsgLogSymLink,[sSrc+' -> '+sDst]), lmtError);
// Standart error modal dialog
MsgError(rsSymErrCreate);
end;
end;
initialization
{$I fsymlink.lrs}
end.