FIX: Also fixes for bug [2954358] error with write permissions

This commit is contained in:
Alexander Koblov 2010-02-21 12:13:34 +00:00
commit 20eb32c3bf

View file

@ -31,8 +31,8 @@ interface
uses
LResources, SysUtils, Classes, Graphics, Forms, StdCtrls, Buttons, ComCtrls,
ExtCtrls, uTypes, uFile, uFileProperty, uFileSource, uFileSourceOperation,
uFileSourceCalcStatisticsOperation;
Dialogs, Controls, ExtCtrls, uTypes, uFile, uFileProperty, uFileSource,
uFileSourceOperation, uFileSourceCalcStatisticsOperation;
type
@ -117,8 +117,7 @@ type
ChangeTriggersEnabled: Boolean;
procedure ShowAttr(Mode: TFileAttrs);
procedure ChangeMod;
procedure ChangeOwner;
function ChangeProperties: Boolean;
function GetModeFromForm: TFileAttrs;
procedure ShowFile(iIndex:Integer);
procedure AllowChange(Allow: Boolean);
@ -189,21 +188,6 @@ begin
if cbSticky.Checked then Result:=(Result OR S_ISVTX);
end;
procedure TfrmFileProperties.ChangeMod;
begin
if not fFiles[iCurrent].IsLink then
fpchmod(PChar(fFiles[iCurrent].FullPath), GetModeFromForm);
//show error
end;
procedure TfrmFileProperties.ChangeOwner;
begin
fplchown(PChar(fFiles[iCurrent].FullPath),
StrToUID(cbxUsers.Text),
StrToGID(cbxGroups.Text));
//show error
end;
procedure TfrmFileProperties.btnCloseClick(Sender: TObject);
begin
Close;
@ -239,10 +223,8 @@ end;
procedure TfrmFileProperties.btnAllClick(Sender: TObject);
begin
repeat
ChangeMod;
if(bPerm) then
ChangeOwner;
inc (iCurrent);
if not ChangeProperties then Exit;
Inc (iCurrent);
until (iCurrent = fFiles.Count);
Close;
end;
@ -266,6 +248,26 @@ begin
cbSticky.Checked:= ((Mode AND S_ISVTX) = S_ISVTX);
end;
function TfrmFileProperties.ChangeProperties: Boolean;
begin
Result:= True;
if not fFiles[iCurrent].IsLink then
begin
if fpchmod(PChar(fFiles[iCurrent].FullPath), GetModeFromForm) <> 0 then
begin
if MessageDlg(Caption, Format(rsPropsErrChMod, [fFiles[iCurrent].Name]), mtError, mbOKCancel, 0) = mrCancel then
Exit(False);
end;
end;
if not bPerm then Exit;
if fplchown(PChar(fFiles[iCurrent].FullPath), StrToUID(cbxUsers.Text),
StrToGID(cbxGroups.Text)) <> 0 then
begin
if MessageDlg(Caption, Format(rsPropsErrChOwn, [fFiles[iCurrent].Name]), mtError, mbOKCancel, 0) = mrCancel then
Exit(False);
end;
end;
procedure TfrmFileProperties.ShowFile(iIndex:Integer);
var
sb: BaseUnix.Stat;
@ -398,9 +400,7 @@ end;
procedure TfrmFileProperties.btnOKClick(Sender: TObject);
begin
ChangeMod;
if (bPerm) then
ChangeOwner;
if not ChangeProperties then Exit;
btnSkipClick(Self);
end;