i wrote simple apps to edit hosts file... but it requires elevation which i do not know how to implement elevation in mac whenever user click the button
procedure TForm1.Button3Click(Sender: TObject); var MyFile : TextFile; FileD : TStringList; FileL : string; begin if not memo1.Text.IsEmpty then begin FileL := '/etc/hosts'; FileD := Tstringlist.create(); FileD.Text := memo1.Text; Filed.SaveToFile(FileL); // Required elevation Filed.Free; end;
i want to interact with mac shell within my firemonkey apps.. in example
sudo mv /users/name/documents/temphosts /etc/hosts
so i could overwrite the hosts file after asking user permission.
Memo1.Lines.SaveToFile()
turns your function into a one-liner. I think the user should not find it too hard to edit their hosts file with a text editor. I also encourage you to give controls and variables meaningful names. Spend more time thinking about naming. Otherwise your code will be write-only. – David Heffernan Jun 9 '14 at 7:15